Debian Codegraph @

hdlcutil/sethdlc.c

raw symbols SCIP
1 /*****************************************************************************/cxx . . $ `<file>/hdlcutil/sethdlc.c`/
2
3 /*
4 * sethdlc.c -- kernel HDLC radio modem driver setup utility.
5 *
6 * Copyright (C) 1996,1997,2000 Thomas Sailer ([email protected])
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *
23 * Please note that the GPL allows you to use the driver, NOT the radio.
24 * In order to use the radio, you need a license from the communications
25 * authority of your country.
26 *
27 *
28 * History:
29 * 0.1 16.10.1996 Adapted from setbaycom.c and setsm.c
30 * 0.2 20.11.1996 New mode set/query code
31 * 0.5 11.05.1997 introduced hdrvcomm.h
32 * 0.6 05.01.2000 glibc compile fixes
33 */
34
35 /*****************************************************************************/
36
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <errno.h>
40 #include <sys/time.h>
41 #include <sys/types.h>
42 #include <sys/stat.h>
43 #include <fcntl.h>
44 #include <unistd.h>
45 #include <string.h>
46 #include <net/if.h>
47 #include "hdrvcomm.h"cxx . . $ `<file>/hdlcutil/hdrvcomm.h`/
48
49 #include <config.h>cxx . . $ `<file>/config.h`/
50 #include <scm-version.h>cxx . . $ `<file>/scm-version.h`/
51
52 /* ---------------------------------------------------------------------- */
53
54 static unsigned char trace_statcxx . . $ trace_stat.;
55 static char *prognamecxx . . $ progname.;
56
57 /* ---------------------------------------------------------------------- */
58
59 static void display_packetcxx . . $ display_packet(2ae3250752bf8d86).(char *bp, unsigned int len)
60 {
61 unsigned char v1=1,cmd=0;
62 unsigned char i,j;
63
64 if (!bp || !len)
65 return;
66 if (len < 8)
67 return;
68 if (bp[1] & 1) {
69 /*
70 * FlexNet Header Compression
71 */
72 v1 = 0;
73 cmd = (bp[1] & 2) != 0;
74 printfcxx . . $ printf(581fddd72a8db8fc).("fm ? to ");
75 i = (bp[2] >> 2) & 0x3f;
76 if (i)
77 printfcxx . . $ printf(581fddd72a8db8fc).("%c",i+0x20);
78 i = ((bp[2] << 4) | ((bp[3] >> 4) & 0xf)) & 0x3f;
79 if (i)
80 printfcxx . . $ printf(581fddd72a8db8fc).("%c",i+0x20);
81 i = ((bp[3] << 2) | ((bp[4] >> 6) & 3)) & 0x3f;
82 if (i)
83 printfcxx . . $ printf(581fddd72a8db8fc).("%c",i+0x20);
84 i = bp[4] & 0x3f;
85 if (i)
86 printfcxx . . $ printf(581fddd72a8db8fc).("%c",i+0x20);
87 i = (bp[5] >> 2) & 0x3f;
88 if (i)
89 printfcxx . . $ printf(581fddd72a8db8fc).("%c",i+0x20);
90 i = ((bp[5] << 4) | ((bp[6] >> 4) & 0xf)) & 0x3f;
91 if (i)
92 printfcxx . . $ printf(581fddd72a8db8fc).("%c",i+0x20);
93 printfcxx . . $ printf(581fddd72a8db8fc).("-%u QSO Nr %u", bp[6] & 0xf, (bp[0] << 6) |
94 (bp[1] >> 2));
95 bp += 7;
96 len -= 7;
97 } else {
98 /*
99 * normal header
100 */
101 if (len < 15)
102 return;
103 if ((bp[6] & 0x80) != (bp[13] & 0x80)) {
104 v1 = 0;
105 cmd = (bp[6] & 0x80);
106 }
107 printfcxx . . $ printf(581fddd72a8db8fc).("fm ");
108 for (i = 7; i < 13; i++)
109 if ((bp[i] &0xfe) != 0x40)
110 printfcxx . . $ printf(581fddd72a8db8fc).("%c",bp[i] >> 1);
111 printfcxx . . $ printf(581fddd72a8db8fc).("-%u to ",(bp[13] >> 1) & 0xf);
112 for (i = 0; i < 6; i++)
113 if ((bp[i] &0xfe) != 0x40)
114 printfcxx . . $ printf(581fddd72a8db8fc).("%c", bp[i] >> 1);
115 printfcxx . . $ printf(581fddd72a8db8fc).("-%u", (bp[6] >> 1) & 0xf);
116 bp += 14;
117 len -= 14;
118 if ((!(bp[-1] & 1)) && (len >= 7))
119 printfcxx . . $ printf(581fddd72a8db8fc).(" via ");
120 while ((!(bp[-1] & 1)) && (len >= 7)) {
121 for (i = 0; i < 6; i++)
122 if ((bp[i] &0xfe) != 0x40)
123 printfcxx . . $ printf(581fddd72a8db8fc).("%c",bp[i] >> 1);
124 printfcxx . . $ printf(581fddd72a8db8fc).("-%u",(bp[6] >> 1) & 0xf);
125 bp += 7;
126 len -= 7;
127 if ((!(bp[-1] & 1)) && (len >= 7))
128 printfcxx . . $ printf(581fddd72a8db8fc).(",");
129 }
130 }
131 if (!len)
132 return;
133 i = *bp++;
134 len--;
135 j = v1 ? ((i & 0x10) ? '!' : ' ') :
136 ((i & 0x10) ? (cmd ? '+' : '-') : (cmd ? '^' : 'v'));
137 if (!(i & 1)) {
138 /*
139 * Info frame
140 */
141 printfcxx . . $ printf(581fddd72a8db8fc).(" I%u%u%c",(i >> 5) & 7,(i >> 1) & 7,j);
142 } else if (i & 2) {
143 /*
144 * U frame
145 */
146 switch (i & (~0x10)) {
147 case 0x03:
148 printfcxx . . $ printf(581fddd72a8db8fc).(" UI%c",j);
149 break;
150 case 0x2f:
151 printfcxx . . $ printf(581fddd72a8db8fc).(" SABM%c",j);
152 break;
153 case 0x43:
154 printfcxx . . $ printf(581fddd72a8db8fc).(" DISC%c",j);
155 break;
156 case 0x0f:
157 printfcxx . . $ printf(581fddd72a8db8fc).(" DM%c",j);
158 break;
159 case 0x63:
160 printfcxx . . $ printf(581fddd72a8db8fc).(" UA%c",j);
161 break;
162 case 0x87:
163 printfcxx . . $ printf(581fddd72a8db8fc).(" FRMR%c",j);
164 break;
165 default:
166 printfcxx . . $ printf(581fddd72a8db8fc).(" unknown U (0x%x)%c",i & (~0x10),j);
167 break;
168 }
169 } else {
170 /*
171 * supervisory
172 */
173 switch (i & 0xf) {
174 case 0x1:
175 printfcxx . . $ printf(581fddd72a8db8fc).(" RR%u%c",(i >> 5) & 7,j);
176 break;
177 case 0x5:
178 printfcxx . . $ printf(581fddd72a8db8fc).(" RNR%u%c",(i >> 5) & 7,j);
179 break;
180 case 0x9:
181 printfcxx . . $ printf(581fddd72a8db8fc).(" REJ%u%c",(i >> 5) & 7,j);
182 break;
183 default:
184 printfcxx . . $ printf(581fddd72a8db8fc).(" unknown S (0x%x)%u%c", i & 0xf,
185 (i >> 5) & 7, j);
186 break;
187 }
188 }
189 if (!len) {
190 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
191 return;
192 }
193 printfcxx . . $ printf(581fddd72a8db8fc).(" pid=%02X\n", *bp++);
194 len--;
195 j = 0;
196 while (len) {
197 i = *bp++;
198 if ((i >= 32) && (i < 128))
199 printfcxx . . $ printf(581fddd72a8db8fc).("%c",i);
200 else if (i == 13) {
201 if (j)
202 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
203 j = 0;
204 } else
205 printfcxx . . $ printf(581fddd72a8db8fc).(".");
206 if (i >= 32)
207 j = 1;
208 len--;
209 }
210 if (j)
211 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
212 }
213
214 /* ---------------------------------------------------------------------- */
215
216 static void print_bitscxx . . $ print_bits(231822f2a2a10318).(int (*bitproc)(void))
217 {
218 int ret;
219 int i;
220 char str[9];
221 char *cp;
222
223 for (;;) {
224 ret = bitproc();
225 if (ret < 0) {
226 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!)
227 return;
228 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error %s (%i), cannot ioctl\n",
229 prognamecxx . . $ progname., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
230 return;
231 }
232 strcpycxx . . $ strcpy(b7b3a83273496486).(cp = str, "00000000");
233 for (i = 0; i < 8; i++, cp++, ret >>= 1)
234 *cp += (ret & 1);
235 printfcxx . . $ printf(581fddd72a8db8fc).("%s", str);
236 }
237 }
238
239 /* ---------------------------------------------------------------------- */
240
241
242 static void do_set_paramscxx . . $ do_set_params(c759356ac01a31e7).(int argc, char **argv)
243 {
244 struct hdlcdrv_ioctlcxx . . $ hdlcdrv_ioctl# drvname, curm, newm, mlist, curp, newp, mpmask;
245 char set = 0;
246 int ret;
247 int mask;
248
249 ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_DRIVERNAMEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:91:9`!, &drvname);
250 if (ret < 0) {
251 perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (HDLCDRVCTL_DRIVERNAME)");
252 exitcxx . . $ exit(3ca292c338df9bb3).(1);
253 }
254 printfcxx . . $ printf(581fddd72a8db8fc).("driver name: %s\n", drvname.datacxx . . $ hdlcdrv_ioctl#data..drivernamecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#drivername.);
255
256 mask = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_MODEMPARMASKcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:72:9`!, &mpmask);
257 if (mask < 0)
258 mask = ~0;
259
260 ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_GETMODEMPARcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:70:9`!, &curp);
261 if (ret < 0) {
262 perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (HDLCDRVCTL_GETMODEMPAR)");
263 exitcxx . . $ exit(3ca292c338df9bb3).(1);
264 }
265 ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_GETMODEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:88:9`!, &curm);
266 if (ret < 0) {
267 perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (HDLCDRVCTL_GETMODE)");
268 exitcxx . . $ exit(3ca292c338df9bb3).(1);
269 }
270 newm = curm;
271 newp = curp;
272 while (argc >= 2) {
273 if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "mode")) {
274 strncpycxx . . $ strncpy(255158a415b673b0).(newm.datacxx . . $ hdlcdrv_ioctl#data..modenamecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#modename., argv[1],
275 sizeof(newm.datacxx . . $ hdlcdrv_ioctl#data..modenamecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#modename.));
276 set |= 1;
277 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "io") && mask & HDLCDRV_PARMASK_IOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:96:9`!) {
278 newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..iobasecxx . . $ hdlcdrv_params#iobase. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
279 set |= 2;
280 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "irq") && mask & HDLCDRV_PARMASK_IRQcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:97:9`!) {
281 newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..irqcxx . . $ hdlcdrv_params#irq. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
282 set |= 2;
283 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "dma") && mask & HDLCDRV_PARMASK_DMAcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:98:9`!) {
284 newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..dmacxx . . $ hdlcdrv_params#dma. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
285 set |= 2;
286 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "dma2") && mask & HDLCDRV_PARMASK_DMA2cxx . . $ `<external>/3637798386850560561/hdlcdrv.h:99:9`!) {
287 newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..dma2cxx . . $ hdlcdrv_params#dma2. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
288 set |= 2;
289 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "serio") && mask & HDLCDRV_PARMASK_SERIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:100:9`!) {
290 newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..seriobasecxx . . $ hdlcdrv_params#seriobase. = strtolcxx . . $ strtol(44bbb87609b212fc).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
291 set |= 2;
292 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "pario") && mask & HDLCDRV_PARMASK_PARIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:101:9`!) {
293 newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..pariobasecxx . . $ hdlcdrv_params#pariobase. = strtolcxx . . $ strtol(44bbb87609b212fc).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
294 set |= 2;
295 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "midiio") && mask & HDLCDRV_PARMASK_MIDIIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:102:9`!) {
296 newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..midiiobasecxx . . $ hdlcdrv_params#midiiobase. = strtolcxx . . $ strtol(44bbb87609b212fc).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
297 set |= 2;
298 } else {
299 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: invalid parameter type '%s', "
300 "valid: mode%s%s%s%s%s%s%s\n",
301 prognamecxx . . $ progname., argv[0],
302 (mask & HDLCDRV_PARMASK_IOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:96:9`!) ? " io" : "",
303 (mask & HDLCDRV_PARMASK_IRQcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:97:9`!) ? " irq" : "",
304 (mask & HDLCDRV_PARMASK_DMAcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:98:9`!) ? " dma" : "",
305 (mask & HDLCDRV_PARMASK_DMA2cxx . . $ `<external>/3637798386850560561/hdlcdrv.h:99:9`!) ? " dma2" : "",
306 (mask & HDLCDRV_PARMASK_SERIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:100:9`!) ? " serio" : "",
307 (mask & HDLCDRV_PARMASK_PARIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:101:9`!) ? " pario" : "",
308 (mask & HDLCDRV_PARMASK_MIDIIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:102:9`!) ? " midiio" : "");
309 }
310 argv += 2;
311 argc -= 2;
312 }
313 if (argc >= 1)
314 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: orphaned parameter type '%s', no data\n",
315 prognamecxx . . $ progname., argv[0]);
316 printfcxx . . $ printf(581fddd72a8db8fc).("current parameters: mode %s", curm.datacxx . . $ hdlcdrv_ioctl#data..modenamecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#modename.);
317 if (mask & HDLCDRV_PARMASK_IOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:96:9`!)
318 printfcxx . . $ printf(581fddd72a8db8fc).(" io 0x%x", curp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..iobasecxx . . $ hdlcdrv_params#iobase.);
319 if (mask & HDLCDRV_PARMASK_IRQcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:97:9`!)
320 printfcxx . . $ printf(581fddd72a8db8fc).(" irq %u", curp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..irqcxx . . $ hdlcdrv_params#irq.);
321 if (mask & HDLCDRV_PARMASK_DMAcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:98:9`!)
322 printfcxx . . $ printf(581fddd72a8db8fc).(" dma %u", curp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..dmacxx . . $ hdlcdrv_params#dma.);
323 if (mask & HDLCDRV_PARMASK_DMA2cxx . . $ `<external>/3637798386850560561/hdlcdrv.h:99:9`!)
324 printfcxx . . $ printf(581fddd72a8db8fc).(" dma2 %u", curp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..dma2cxx . . $ hdlcdrv_params#dma2.);
325 if (mask & HDLCDRV_PARMASK_SERIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:100:9`!)
326 printfcxx . . $ printf(581fddd72a8db8fc).(" serio 0x%x", curp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..seriobasecxx . . $ hdlcdrv_params#seriobase.);
327 if (mask & HDLCDRV_PARMASK_PARIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:101:9`!)
328 printfcxx . . $ printf(581fddd72a8db8fc).(" pario 0x%x", curp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..pariobasecxx . . $ hdlcdrv_params#pariobase.);
329 if (mask & HDLCDRV_PARMASK_MIDIIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:102:9`!)
330 printfcxx . . $ printf(581fddd72a8db8fc).(" midiio 0x%x", curp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..midiiobasecxx . . $ hdlcdrv_params#midiiobase.);
331 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
332
333 if (set & 1)
334 ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_SETMODEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:89:9`!, &newm);
335 if (ret < 0) {
336 perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (HDLCDRVCTL_SETMODE)");
337 ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_MODELISTcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:90:9`!, &mlist);
338 if (ret < 0) {
339 perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (HDLCDRVCTL_MODELIST)");
340 exitcxx . . $ exit(3ca292c338df9bb3).(1);
341 }
342 printfcxx . . $ printf(581fddd72a8db8fc).("driver supported modes: %s\n", mlist.datacxx . . $ hdlcdrv_ioctl#data..modenamecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#modename.);
343 exitcxx . . $ exit(3ca292c338df9bb3).(1);
344 }
345 if (set & 2) {
346 ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_SETMODEMPARcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:71:9`!, &newp);
347 if (ret < 0) {
348 perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (HDLCDRVCTL_SETMODEMPAR)");
349 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: trying to restore old "
350 "parameters\n", prognamecxx . . $ progname.);
351 ret = hdrvc_hdlcdrv_ioctlcxx . . $ hdrvc_hdlcdrv_ioctl(f1689bf36b009389).(HDLCDRVCTL_SETMODEMPARcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:71:9`!, &curp);
352 if (ret < 0)
353 perrorcxx . . $ perror(85c52e162fed56f9).("ioctl (HDLCDRVCTL_SETMODEMPAR)");
354 exitcxx . . $ exit(3ca292c338df9bb3).(1);
355 }
356 }
357 if (set & 3) {
358 printfcxx . . $ printf(581fddd72a8db8fc).("new parameters: mode %s", newm.datacxx . . $ hdlcdrv_ioctl#data..modenamecxx . . $ hdlcdrv_ioctl#$anonymous_type_0#modename.);
359 if (mask & HDLCDRV_PARMASK_IOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:96:9`!)
360 printfcxx . . $ printf(581fddd72a8db8fc).(" io 0x%x", newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..iobasecxx . . $ hdlcdrv_params#iobase.);
361 if (mask & HDLCDRV_PARMASK_IRQcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:97:9`!)
362 printfcxx . . $ printf(581fddd72a8db8fc).(" irq %u", newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..irqcxx . . $ hdlcdrv_params#irq.);
363 if (mask & HDLCDRV_PARMASK_DMAcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:98:9`!)
364 printfcxx . . $ printf(581fddd72a8db8fc).(" dma %u", newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..dmacxx . . $ hdlcdrv_params#dma.);
365 if (mask & HDLCDRV_PARMASK_DMA2cxx . . $ `<external>/3637798386850560561/hdlcdrv.h:99:9`!)
366 printfcxx . . $ printf(581fddd72a8db8fc).(" dma2 %u", newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..dma2cxx . . $ hdlcdrv_params#dma2.);
367 if (mask & HDLCDRV_PARMASK_SERIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:100:9`!)
368 printfcxx . . $ printf(581fddd72a8db8fc).(" serio 0x%x", newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..seriobasecxx . . $ hdlcdrv_params#seriobase.);
369 if (mask & HDLCDRV_PARMASK_PARIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:101:9`!)
370 printfcxx . . $ printf(581fddd72a8db8fc).(" pario 0x%x", newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..pariobasecxx . . $ hdlcdrv_params#pariobase.);
371 if (mask & HDLCDRV_PARMASK_MIDIIOBASEcxx . . $ `<external>/3637798386850560561/hdlcdrv.h:102:9`!)
372 printfcxx . . $ printf(581fddd72a8db8fc).(" midiio 0x%x", newp.datacxx . . $ hdlcdrv_ioctl#data..mpcxx . . $ hdlcdrv_ioctl#$anonymous_type_0#mp..midiiobasecxx . . $ hdlcdrv_params#midiiobase.);
373 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
374 }
375 exitcxx . . $ exit(3ca292c338df9bb3).(0);
376 }
377
378
379 /* ---------------------------------------------------------------------- */
380
381 static void display_channel_paramscxx . . $ display_channel_params(d59f5ad372dead8c).(const struct hdrvc_channel_paramscxx . . $ hdrvc_channel_params# *par)
382 {
383 printfcxx . . $ printf(581fddd72a8db8fc).("TX delay %ums, TX tail %ums, slottime %ums, p-persistence "
384 " %u/256, %s duplex\n", 10*par->tx_delaycxx . . $ hdrvc_channel_params#tx_delay., 10*par->tx_tailcxx . . $ hdrvc_channel_params#tx_tail.,
385 10*par->slottimecxx . . $ hdrvc_channel_params#slottime., par->ppersistcxx . . $ hdrvc_channel_params#ppersist.,
386 par->fulldupcxx . . $ hdrvc_channel_params#fulldup. ? "Full" : "Half");
387 }
388
389 /* ---------------------------------------------------------------------- */
390
391 static void do_set_channel_paramscxx . . $ do_set_channel_params(c759356ac01a31e7).(int argc, char **argv)
392 {
393 struct hdrvc_channel_paramscxx . . $ hdrvc_channel_params# par1, par2;
394 char set = 0;
395 int ret;
396
397 ret = hdrvc_get_channel_access_paramcxx . . $ hdrvc_get_channel_access_param(f136402c1dcd8d85).(&par1);
398 if (ret < 0) {
399 perrorcxx . . $ perror(85c52e162fed56f9).("hdrvc_get_channel_access_param");
400 exitcxx . . $ exit(3ca292c338df9bb3).(1);
401 }
402 par2 = par1;
403 while (argc > 0) {
404 if (argc >= 2 && !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "txd")) {
405 par2.tx_delaycxx . . $ hdrvc_channel_params#tx_delay. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0) / 10;
406 set = 1;
407 argv += 2;
408 argc -= 2;
409 } else if (argc >= 2 && !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "txtail")) {
410 par2.tx_tailcxx . . $ hdrvc_channel_params#tx_tail. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0) / 10;
411 set = 1;
412 argv += 2;
413 argc -= 2;
414 } else if (argc >= 2 && !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "slot")) {
415 par2.slottimecxx . . $ hdrvc_channel_params#slottime. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0) / 10;
416 set = 1;
417 argv += 2;
418 argc -= 2;
419 } else if (argc >= 2 && !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "ppersist")) {
420 par2.ppersistcxx . . $ hdrvc_channel_params#ppersist. = strtoulcxx . . $ strtoul(31746e8d6ec49860).(argv[1], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
421 set = 1;
422 argv += 2;
423 argc -= 2;
424 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "half")) {
425 par2.fulldupcxx . . $ hdrvc_channel_params#fulldup. = 0;
426 set = 1;
427 argv += 1;
428 argc -= 1;
429 } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(argv[0], "full")) {
430 par2.fulldupcxx . . $ hdrvc_channel_params#fulldup. = 1;
431 set = 1;
432 argv += 1;
433 argc -= 1;
434 } else {
435
436 argv += 1;
437 argc -= 1;
438 }
439 }
440 printfcxx . . $ printf(581fddd72a8db8fc).("current parameters: ");
441 display_channel_paramscxx . . $ display_channel_params(d59f5ad372dead8c).(&par1);
442 if (set) {
443 ret = hdrvc_set_channel_access_paramcxx . . $ hdrvc_set_channel_access_param(4ab70b5db353be76).(par2);
444 if (ret < 0) {
445 perrorcxx . . $ perror(85c52e162fed56f9).("hdrvc_set_channel_access_param");
446 exitcxx . . $ exit(3ca292c338df9bb3).(1);
447 }
448 printfcxx . . $ printf(581fddd72a8db8fc).("new parameters: ");
449 display_channel_paramscxx . . $ display_channel_params(d59f5ad372dead8c).(&par2);
450 }
451 exitcxx . . $ exit(3ca292c338df9bb3).(0);
452 }
453
454 /* ---------------------------------------------------------------------- */
455
456 static const char *usage_strcxx . . $ usage_str. =
457 "[-b] [-i] [-d] [-i <baycomif>] [-h] [-c <cal>]\n"
458 "[-p] [hw <hw>] [type <type>] [io <iobase>] [irq <irq>] [dma <dma>]\n"
459 " [options <opt>] [serio <serio>] [pario <pario>] [midiio <midiio>]\n"
460 "[-a] [txd <txdelay>] [txtail <txtail>] [slot <slottime>]\n"
461 " [ppersist <ppersistence>] [full] [half]\n"
462 " -a: set or display channel access parameters\n"
463 " -b: trace demodulated bits\n"
464 " -s: trace sampled input from tcm3105 (ser12 only)\n"
465 " -d: trace dcd and ptt status on stdout\n"
466 " -i: specify the name of the baycom kernel driver interface\n"
467 " -c: calibrate (i.e. send calibration pattern) for cal seconds\n"
468 " -p: set or display interface parameters\n"
469 " -h: this help\n\n";
470
471 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[])
472 {
473 int ret;
474 fd_setcxx . . $ fd_set# fds_read;
475 fd_setcxx . . $ fd_set# fds_write;
476 struct timevalcxx . . $ timeval# tm;
477 char getsetparams = 0;
478 char cal = 0;
479 int cal_val = 0;
480 struct sm_ioctlcxx . . $ sm_ioctl# bsi;
481 struct baycom_ioctlcxx . . $ baycom_ioctl# bbi;
482 struct hdrvc_channel_statecxx . . $ hdrvc_channel_state# chst;
483 char pktbuf[2048];
484
485 prognamecxx . . $ progname. = *argv;
486 printfcxx . . $ printf(581fddd72a8db8fc).("%s: Version " FULL_VERcxx . . $ `scm-version.h:6:9`! "; (C) 1996-1997 by Thomas Sailer HB9JNX/AE4WA\n", *argv);
487 hdrvc_argscxx . . $ hdrvc_args(de06760a4a38ab9).(&argc, argv, "bc0");
488 while ((ret = getoptcxx . . $ getopt(2483c31ff9bab884).(argc, argv, "bsdhpc:a")) != -1) {
489 switch (ret) {
490 case 'b':
491 trace_statcxx . . $ trace_stat. = 2;
492 break;
493 case 's':
494 trace_statcxx . . $ trace_stat. = 3;
495 break;
496 case 'd':
497 trace_statcxx . . $ trace_stat. = 1;
498 break;
499 case 'p':
500 getsetparams = 1;
501 break;
502 case 'a':
503 getsetparams = 2;
504 break;
505 case 'c':
506 cal = 1;
507 cal_val = strtoulcxx . . $ strtoul(31746e8d6ec49860).(optargcxx . . $ optarg., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
508 break;
509 default:
510 printfcxx . . $ printf(581fddd72a8db8fc).("usage: %s %s", *argv, usage_strcxx . . $ usage_str.);
511 exitcxx . . $ exit(3ca292c338df9bb3).(-1);
512 }
513 }
514 hdrvc_initcxx . . $ hdrvc_init(49f6e7a06ebc5aa8).();
515 if (getsetparams == 1) {
516 do_set_paramscxx . . $ do_set_params(c759356ac01a31e7).(argc - optindcxx . . $ optind., argv+optindcxx . . $ optind.);
517 exitcxx . . $ exit(3ca292c338df9bb3).(0);
518 }
519 if (getsetparams == 2) {
520 do_set_channel_paramscxx . . $ do_set_channel_params(c759356ac01a31e7).(argc - optindcxx . . $ optind., argv+optindcxx . . $ optind.);
521 exitcxx . . $ exit(3ca292c338df9bb3).(0);
522 }
523 if (cal) {
524 ret = hdrvc_calibratecxx . . $ hdrvc_calibrate(7864480464b09eea).(cal_val);
525 if (ret < 0) {
526 perrorcxx . . $ perror(85c52e162fed56f9).("hdrvc_calibrate");
527 exitcxx . . $ exit(3ca292c338df9bb3).(1);
528 }
529 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s: calibrating for %i seconds\n", *argv,
530 cal_val);
531 exitcxx . . $ exit(3ca292c338df9bb3).(0);
532 }
533 for (;;) {
534 while ((ret = hdrvc_recvpacketcxx . . $ hdrvc_recvpacket(6abd07ddb1a912f0).(pktbuf, sizeof(pktbuf))) > 1)
535 display_packetcxx . . $ display_packet(2ae3250752bf8d86).(pktbuf+1, ret-1);
536 switch (trace_statcxx . . $ trace_stat.) {
537 case 1:
538 ret = hdrvc_get_channel_statecxx . . $ hdrvc_get_channel_state(b95f36a631c52079).(&chst);
539 if (ret < 0)
540 perrorcxx . . $ perror(85c52e162fed56f9).("hdrvc_get_channel_state");
541 printfcxx . . $ printf(581fddd72a8db8fc).("%c%c rx: %lu tx: %lu rxerr: %lu txerr: %lu",
542 chst.dcdcxx . . $ hdrvc_channel_state#dcd. ? 'D' : '-', chst.pttcxx . . $ hdrvc_channel_state#ptt. ? 'P' : '-',
543 chst.rx_packetscxx . . $ hdrvc_channel_state#rx_packets., chst.tx_packetscxx . . $ hdrvc_channel_state#tx_packets., chst.rx_errorscxx . . $ hdrvc_channel_state#rx_errors.,
544 chst.tx_errorscxx . . $ hdrvc_channel_state#tx_errors.);
545 if (hdrvc_sm_ioctlcxx . . $ hdrvc_sm_ioctl(bf89a364da74a233).(SMCTL_GETDEBUGcxx . . $ `hdlcutil/soundmodem.h:84:9`!, &bsi) >= 0) {
546 printfcxx . . $ printf(581fddd72a8db8fc).(" intrate: %u modcyc: %u "
547 "demodcyc: %u dmares: %u",
548 bsi.datacxx . . $ sm_ioctl#data..dbgcxx . . $ sm_ioctl#$anonymous_type_0#dbg..int_ratecxx . . $ sm_debug_data#int_rate.,
549 bsi.datacxx . . $ sm_ioctl#data..dbgcxx . . $ sm_ioctl#$anonymous_type_0#dbg..mod_cyclescxx . . $ sm_debug_data#mod_cycles.,
550 bsi.datacxx . . $ sm_ioctl#data..dbgcxx . . $ sm_ioctl#$anonymous_type_0#dbg..demod_cyclescxx . . $ sm_debug_data#demod_cycles.,
551 bsi.datacxx . . $ sm_ioctl#data..dbgcxx . . $ sm_ioctl#$anonymous_type_0#dbg..dma_residuecxx . . $ sm_debug_data#dma_residue.);
552 }
553 if (hdrvc_baycom_ioctlcxx . . $ hdrvc_baycom_ioctl(51d393eee869daf2).(BAYCOMCTL_GETDEBUGcxx . . $ `<external>/3652170718638097837/baycom.h:34:9`!, &bbi) >= 0) {
554 printfcxx . . $ printf(581fddd72a8db8fc).(" dbg1: %lu dbg2: %lu dbg3: %li",
555 bbi.datacxx . . $ baycom_ioctl#data..dbgcxx . . $ baycom_ioctl#$anonymous_type_0#dbg..debug1cxx . . $ baycom_debug_data#debug1., bbi.datacxx . . $ baycom_ioctl#data..dbgcxx . . $ baycom_ioctl#$anonymous_type_0#dbg..debug2cxx . . $ baycom_debug_data#debug2.,
556 bbi.datacxx . . $ baycom_ioctl#data..dbgcxx . . $ baycom_ioctl#$anonymous_type_0#dbg..debug3cxx . . $ baycom_debug_data#debug3.);
557 }
558 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
559 break;
560 case 2:
561 print_bitscxx . . $ print_bits(231822f2a2a10318).(hdrvc_get_bitscxx . . $ hdrvc_get_bits(b126dc7c1de90089).);
562 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
563 break;
564 case 3:
565 print_bitscxx . . $ print_bits(231822f2a2a10318).(hdrvc_get_samplescxx . . $ hdrvc_get_samples(b126dc7c1de90089).);
566 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
567 break;
568 default:
569 break;
570 }
571 tm.tv_useccxx . . $ timeval#tv_usec. = 500000L;
572 tm.tv_seccxx . . $ timeval#tv_sec. = 0L;
573 if (hdrvc_getfdcxx . . $ hdrvc_getfd(b126dc7c1de90089).() >= 0) {
574 FD_ZEROcxx . . $ `<external>/946878812840035423/select.h:88:9`!(&fds_read);
575 FD_ZEROcxx . . $ `<external>/946878812840035423/select.h:88:9`!(&fds_write);
576 FD_SETcxx . . $ `<external>/946878812840035423/select.h:85:9`!(hdrvc_getfd(), &fds_read);
577 ret = selectcxx . . $ select(6d24c7514c8a5b88).(hdrvc_getfdcxx . . $ hdrvc_getfd(b126dc7c1de90089).()+1, &fds_read, &fds_write, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tm);
578 } else
579 ret = selectcxx . . $ select(6d24c7514c8a5b88).(0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tm);
580 if (ret < 0) {
581 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: Error %s (%i) in select\n", *argv,
582 strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!), errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
583 exitcxx . . $ exit(3ca292c338df9bb3).(-2);
584 }
585 }
586 }
587
588 /* ---------------------------------------------------------------------- */