2 * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 *---------------------------------------------------------------------------
27 * isdntelctl - i4b set telephone interface options
28 * ------------------------------------------------
30 * $Id: main.c,v 1.6 2008/07/15 17:51:38 perry Exp $
34 * last edit-date: [Sat Jan 6 13:05:22 2001]
36 *---------------------------------------------------------------------------*/
48 #include <sys/ioctl.h>
49 #include <sys/types.h>
52 #include <netisdn/i4b_ioctl.h>
53 #include <netisdn/i4b_tel_ioctl.h>
55 static void usage ( void );
57 #define I4BTELDEVICE "/dev/isdntel"
66 /*---------------------------------------------------------------------------*
68 *---------------------------------------------------------------------------*/
70 main(int argc
, char **argv
)
77 while ((c
= getopt(argc
, argv
, "cgu:AUN")) != -1)
90 opt_unit
= atoi(optarg
);
91 if (opt_unit
< 0 || opt_unit
> 9)
114 if (opt_get
== 0 && opt_N
== 0 && opt_U
== 0 && opt_A
== 0 && opt_C
== 0)
119 if ((opt_get
+ opt_N
+ opt_U
+ opt_A
+ opt_C
) > 1)
124 snprintf(namebuffer
, sizeof(namebuffer
), "%s%d", I4BTELDEVICE
, opt_unit
);
126 if ((telfd
= open(namebuffer
, O_RDWR
)) < 0)
128 fprintf(stderr
, "isdntelctl: cannot open %s: %s\n", namebuffer
, strerror(errno
));
136 if ((ret
= ioctl(telfd
, I4B_TEL_GETAUDIOFMT
, &format
)) < 0)
138 fprintf(stderr
, "ioctl I4B_TEL_GETAUDIOFMT failed: %s", strerror(errno
));
142 if (format
== CVT_NONE
)
144 printf("device %s does not do A-law/mu-law format conversion\n", namebuffer
);
146 else if (format
== CVT_ALAW2ULAW
)
148 printf("device %s does ISDN: A-law -> user: mu-law format conversion\n", namebuffer
);
150 else if (format
== CVT_ULAW2ALAW
)
152 printf("device %s does ISDN: mu-law -> user: A-law format conversion\n", namebuffer
);
156 printf("ERROR, device %s uses unknown format %d!\n", namebuffer
, format
);
163 int format
= CVT_ALAW2ULAW
;
165 if ((ret
= ioctl(telfd
, I4B_TEL_SETAUDIOFMT
, &format
)) < 0)
167 fprintf(stderr
, "ioctl I4B_TEL_SETAUDIOFMT failed: %s", strerror(errno
));
175 int format
= CVT_ULAW2ALAW
;
177 if ((ret
= ioctl(telfd
, I4B_TEL_SETAUDIOFMT
, &format
)) < 0)
179 fprintf(stderr
, "ioctl I4B_TEL_SETAUDIOFMT failed: %s", strerror(errno
));
186 int format
= CVT_NONE
;
188 if ((ret
= ioctl(telfd
, I4B_TEL_SETAUDIOFMT
, &format
)) < 0)
190 fprintf(stderr
, "ioctl I4B_TEL_SETAUDIOFMT failed: %s", strerror(errno
));
198 if ((ret
= ioctl(telfd
, I4B_TEL_EMPTYINPUTQUEUE
, &dummy
)) < 0)
200 fprintf(stderr
, "ioctl I4B_TEL_EMPTYINPUTQUEUE failed: %s", strerror(errno
));
208 /*---------------------------------------------------------------------------*
209 * usage display and exit
210 *---------------------------------------------------------------------------*/
214 fprintf(stderr
, "\n");
215 fprintf(stderr
, "isdntelctl - /dev/isdntel control, version %d.%d.%d\n",VERSION
, REL
, STEP
);
216 fprintf(stderr
, "usage: isdntelctl -c -g -u <unit> -A -N -U\n");
217 fprintf(stderr
, " -c clear input queue\n");
218 fprintf(stderr
, " -g get current settings\n");
219 fprintf(stderr
, " -u unit specify unit number\n");
220 fprintf(stderr
, " -A set conversion ISDN: A-law -> user: mu-law\n");
221 fprintf(stderr
, " -U set conversion ISDN: mu-law -> user: A-law\n");
222 fprintf(stderr
, " -N set conversion to no A-law/mu-law conversion\n");
223 fprintf(stderr
, "\n");