diff options
author | hm <hm@FreeBSD.org> | 1999-05-20 10:14:57 +0000 |
---|---|---|
committer | hm <hm@FreeBSD.org> | 1999-05-20 10:14:57 +0000 |
commit | 2077acfca034178f39e3fa4e86cb8d371f44737c (patch) | |
tree | 730187a2063473cb0d2e7cac998a9a4307285426 /usr.sbin/i4b | |
parent | 5ea75aea8a2633cc0acf9dd870c1e1db1abd6a21 (diff) | |
download | FreeBSD-src-2077acfca034178f39e3fa4e86cb8d371f44737c.zip FreeBSD-src-2077acfca034178f39e3fa4e86cb8d371f44737c.tar.gz |
upgrade isdn4bsd from version 0.71 to the just released version 0.81
Diffstat (limited to 'usr.sbin/i4b')
39 files changed, 974 insertions, 580 deletions
diff --git a/usr.sbin/i4b/Makefile b/usr.sbin/i4b/Makefile index c1d71e7..29ac75c 100644 --- a/usr.sbin/i4b/Makefile +++ b/usr.sbin/i4b/Makefile @@ -1,4 +1,4 @@ -SUBDIR = isdntrace isdndebug isdnd alawulaw man isdntest \ +SUBDIR = isdntrace isdndebug isdnd g711conv man isdntest \ isdntel isdntelctl isdnmonitor isdndecode dtmfdecode .include <bsd.subdir.mk> diff --git a/usr.sbin/i4b/alawulaw/Makefile b/usr.sbin/i4b/alawulaw/Makefile deleted file mode 100644 index 1daa481..0000000 --- a/usr.sbin/i4b/alawulaw/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -PROG = alaw2ulaw -SRC = alaw2ulaw.c -CFLAGS += -Wall -g -DDEBUG -LINKS = ${BINDIR}/alaw2ulaw ${BINDIR}/ulaw2alaw -MAN1 = alaw2ulaw.1 ulaw2alaw.1 - -.include <bsd.prog.mk> diff --git a/usr.sbin/i4b/alawulaw/alaw2ulaw.1 b/usr.sbin/i4b/alawulaw/alaw2ulaw.1 deleted file mode 100644 index a99f3ce..0000000 --- a/usr.sbin/i4b/alawulaw/alaw2ulaw.1 +++ /dev/null @@ -1,70 +0,0 @@ -.\" -.\" Copyright (c) 1998, 1999 Hellmuth Michaelis. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $Id: alaw2ulaw.1,v 1.4 1999/02/14 09:44:55 hm Exp $ -.\" -.\" last edit-date: [Sun Feb 14 10:01:36 1999] -.\" -.\" -hm writing manual pages -.\" -.\" -.Dd January 23, 1998 -.Dt alaw2ulaw 1 -.Sh NAME -.Nm alaw2ulaw -.Nd convert sound data -.Sh SYNOPSIS -.Nm -.Sh DESCRIPTION -.Nm alaw2ulaw -is part of the isdn4bsd package and is used convert sound data between -uLaw coded data to ALaw coded data and vice versa. -.Pp -It reads data from stdin and outputs converted data to stdout. -.Pp -In case it is run as -.Em alaw2ulaw -it converts ALaw input data to uLaw output. -.Pp -In case it is run as -.Em ulaw2alaw -it converts uLaw input data to ALaw output. -.Pp - -.Sh EXAMPLES -The command: -.Bd -literal -offset indent -alaw2ulaw <file.alaw >file.ulaw -.Ed -.Pp -converts ALaw input data file file.alaw to uLaw output file file.ulaw. - -.Sh STANDARDS -ITU Recommendations G.711 - -.Sh AUTHOR -The -.Nm -utility and this man page were written by Hellmuth Michaelis. He can be -contacted at hm@kts.org. diff --git a/usr.sbin/i4b/alawulaw/alaw2ulaw.c b/usr.sbin/i4b/alawulaw/alaw2ulaw.c deleted file mode 100644 index 80f1e19..0000000 --- a/usr.sbin/i4b/alawulaw/alaw2ulaw.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - *--------------------------------------------------------------------------- - * - * convert a-law / u-law sound files - * --------------------------------- - * - * last edit-date: [Tue Feb 16 11:23:27 1999] - * - * $Id: alaw2ulaw.c,v 1.4 1999/02/16 10:40:18 hm Exp $ - * - *---------------------------------------------------------------------------*/ - -#include <string.h> -#include <unistd.h> - -#define BUF_SIZ 2048 - -static unsigned char raw_ulaw[]; -static unsigned char ulaw_raw[]; - - -int main(int argc, char *argv[]) -{ - int i, j; - unsigned char buffer[BUF_SIZ]; - char *p; - unsigned char *cp; - - if((p = rindex(*argv, '/')) != NULL) - p++; - else - p = *argv; - - if(!strcmp(p, "ulaw2alaw")) - { - cp = ulaw_raw; - } - else if(!strcmp(p, "alaw2ulaw")) - { - cp = raw_ulaw; - } - else - { - return(1); - } - - while(((j = read(0, buffer, BUF_SIZ)) > 0)) - { - for(i = 0; i < j; i++) - buffer[i] = cp[buffer[i]]; - write(1, buffer, j); - } - return(0); -} - - -/*---------------------------------------------------------------------------* - * Line format to mu-law conversion - *---------------------------------------------------------------------------*/ -static unsigned char raw_ulaw[256] = { - 0x2a, 0xa9, 0x62, 0xe1, 0x0a, 0x8a, 0x48, 0xc8, 0x39, 0xb9, 0x75, 0xf3,0x1a, 0x9a, 0x56, 0xd6, - 0x22, 0xa1, 0x5d, 0xdc, 0x02, 0x82, 0x40, 0xc0, 0x31, 0xb1, 0x6a, 0xe9,0x12, 0x92, 0x4f, 0xcf, - 0x2e, 0xad, 0x66, 0xe5, 0x0e, 0x8e, 0x4c, 0xcc, 0x3d, 0xbd, 0x7d, 0xfb,0x1e, 0x9e, 0x5a, 0xda, - 0x26, 0xa5, 0x5f, 0xde, 0x06, 0x86, 0x44, 0xc4, 0x35, 0xb5, 0x6e, 0xed,0x16, 0x96, 0x52, 0xd2, - 0x28, 0xa7, 0x60, 0xdf, 0x08, 0x88, 0x46, 0xc6, 0x37, 0xb7, 0x71, 0xef,0x18, 0x98, 0x54, 0xd4, - 0x20, 0x9f, 0x5c, 0xdb, 0x00, 0x80, 0x3f, 0xbf, 0x2f, 0xaf, 0x68, 0xe7,0x10, 0x90, 0x4e, 0xce, - 0x2c, 0xab, 0x64, 0xe3, 0x0c, 0x8c, 0x4a, 0xca, 0x3b, 0xbb, 0x79, 0xf7,0x1c, 0x9c, 0x58, 0xd8, - 0x24, 0xa3, 0x5e, 0xdd, 0x04, 0x84, 0x42, 0xc2, 0x33, 0xb3, 0x6c, 0xeb,0x14, 0x94, 0x50, 0xd0, - 0x2b, 0xaa, 0x63, 0xe2, 0x0b, 0x8b, 0x49, 0xc9, 0x3a, 0xba, 0x77, 0xf5,0x1b, 0x9b, 0x57, 0xd7, - 0x23, 0xa2, 0x5d, 0xdd, 0x03, 0x83, 0x41, 0xc1, 0x32, 0xb2, 0x6b, 0xea,0x13, 0x93, 0x4f, 0xcf, - 0x2f, 0xae, 0x67, 0xe6, 0x0f, 0x8f, 0x4d, 0xcd, 0x3e, 0xbe, 0xff, 0xfd,0x1f, 0x9f, 0x5b, 0xdb, - 0x27, 0xa6, 0x5f, 0xdf, 0x07, 0x87, 0x45, 0xc5, 0x36, 0xb6, 0x6f, 0xee,0x17, 0x97, 0x53, 0xd3, - 0x29, 0xa8, 0x61, 0xe0, 0x09, 0x89, 0x47, 0xc7, 0x38, 0xb8, 0x73, 0xf1,0x19, 0x99, 0x55, 0xd5, - 0x21, 0xa0, 0x5c, 0xdc, 0x01, 0x81, 0x3f, 0xbf, 0x30, 0xb0, 0x69, 0xe8,0x11, 0x91, 0x4e, 0xce, - 0x2d, 0xac, 0x65, 0xe4, 0x0d, 0x8d, 0x4b, 0xcb, 0x3c, 0xbc, 0x7b, 0xf9,0x1d, 0x9d, 0x59, 0xd9, - 0x25, 0xa4, 0x5e, 0xde, 0x05, 0x85, 0x43, 0xc3, 0x34, 0xb4, 0x6d, 0xec,0x15, 0x95, 0x51, 0xd1 -}; - - -/*---------------------------------------------------------------------------* - * mu-law to line format conversion -*---------------------------------------------------------------------------*/ -static unsigned char ulaw_raw[256] = { - 0x54, 0xd4, 0x14, 0x94, 0x74, 0xf4, 0x34, 0xb4, 0x44, 0xc4, 0x04, 0x84,0x64, 0xe4, 0x24, 0xa4, - 0x5c, 0xdc, 0x1c, 0x9c, 0x7c, 0xfc, 0x3c, 0xbc, 0x4c, 0xcc, 0x0c, 0x8c,0x6c, 0xec, 0x2c, 0xac, - 0xd0, 0x10, 0x90, 0x70, 0xf0, 0x30, 0xb0, 0x40, 0xc0, 0x00, 0x80, 0x60,0xe0, 0x20, 0xa0, 0x58, - 0xd8, 0x18, 0x98, 0x78, 0xf8, 0x38, 0xb8, 0x48, 0xc8, 0x08, 0x88, 0x68,0xe8, 0x28, 0xa8, 0xd6, - 0x16, 0x96, 0x76, 0xf6, 0x36, 0xb6, 0x46, 0xc6, 0x06, 0x86, 0x66, 0xe6,0x26, 0xa6, 0xde, 0x9e, - 0x7e, 0xfe, 0x3e, 0xbe, 0x4e, 0xce, 0x0e, 0x8e, 0x6e, 0xee, 0x2e, 0xae,0xd2, 0x92, 0xf2, 0xb2, - 0xc2, 0x02, 0x82, 0x62, 0xe2, 0x22, 0xa2, 0x5a, 0xda, 0x1a, 0x9a, 0x7a,0xfa, 0x3a, 0xba, 0x4a, - 0x4a, 0xca, 0xca, 0x0a, 0x0a, 0x8a, 0x8a, 0x6a, 0x6a, 0xea, 0xea, 0x2a,0x2a, 0xaa, 0xab, 0xab, - 0x55, 0xd5, 0x15, 0x95, 0x75, 0xf5, 0x35, 0xb5, 0x45, 0xc5, 0x05, 0x85,0x65, 0xe5, 0x25, 0xa5, - 0x5d, 0xdd, 0x1d, 0x9d, 0x7d, 0xfd, 0x3d, 0xbd, 0x4d, 0xcd, 0x0d, 0x8d,0x6d, 0xed, 0x2d, 0xad, - 0x51, 0xd1, 0x11, 0x91, 0x71, 0xf1, 0x31, 0xb1, 0x41, 0xc1, 0x01, 0x81,0x61, 0xe1, 0x21, 0xa1, - 0xd9, 0x19, 0x99, 0x79, 0xf9, 0x39, 0xb9, 0x49, 0xc9, 0x09, 0x89, 0x69,0xe9, 0x29, 0xa9, 0x57, - 0x17, 0x97, 0x77, 0xf7, 0x37, 0xb7, 0x47, 0xc7, 0x07, 0x87, 0x67, 0xe7,0x27, 0xa7, 0x5f, 0x1f, - 0x7f, 0xff, 0x3f, 0xbf, 0x4f, 0xcf, 0x0f, 0x8f, 0x6f, 0xef, 0x2f, 0xaf,0x53, 0x13, 0x73, 0x33, - 0x43, 0xc3, 0x03, 0x83, 0x63, 0xe3, 0x23, 0xa3, 0x5b, 0xdb, 0x1b, 0x9b,0x7b, 0xfb, 0x3b, 0xbb, - 0xbb, 0x4b, 0x4b, 0xcb, 0xcb, 0x0b, 0x0b, 0x8b, 0x8b, 0x6b, 0x6b, 0xeb,0xeb, 0x2b, 0x2b, 0xab -}; - -/* EOF */ diff --git a/usr.sbin/i4b/alawulaw/ulaw2alaw.1 b/usr.sbin/i4b/alawulaw/ulaw2alaw.1 deleted file mode 100644 index 358e73b..0000000 --- a/usr.sbin/i4b/alawulaw/ulaw2alaw.1 +++ /dev/null @@ -1,70 +0,0 @@ -.\" -.\" Copyright (c) 1998, 1999 Hellmuth Michaelis. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $Id: ulaw2alaw.1,v 1.4 1999/02/14 09:44:55 hm Exp $ -.\" -.\" last edit-date: [Sun Feb 14 10:01:51 1999] -.\" -.\" -hm writing manual pages -.\" -.\" -.Dd January 23, 1998 -.Dt ulaw2alaw 1 -.Sh NAME -.Nm ulaw2alaw -.Nd convert sound data -.Sh SYNOPSIS -.Nm -.Sh DESCRIPTION -.Nm ulaw2alaw -is part of the isdn4bsd package and is used convert sound data between -uLaw coded data to ALaw coded data and vice versa. -.Pp -It reads data from stdin and outputs converted data to stdout. -.Pp -In case it is run as -.Em alaw2ulaw -it converts ALaw input data to uLaw output. -.Pp -In case it is run as -.Em ulaw2alaw -it converts uLaw input data to ALaw output. -.Pp - -.Sh EXAMPLES -The command: -.Bd -literal -offset indent -ulaw2alaw <file.ulaw >file.alaw -.Ed -.Pp -converts uLaw input data file file.ulaw to ALaw output file file.alaw. - -.Sh STANDARDS -ITU Recommendations G.711 - -.Sh AUTHOR -The -.Nm -utility and this man page were written by Hellmuth Michaelis. He can be -contacted at hm@kts.org. diff --git a/usr.sbin/i4b/dtmfdecode/Makefile b/usr.sbin/i4b/dtmfdecode/Makefile index e814285..2ce7aeb 100644 --- a/usr.sbin/i4b/dtmfdecode/Makefile +++ b/usr.sbin/i4b/dtmfdecode/Makefile @@ -1,14 +1,14 @@ #--------------------------------------------------------------------------- # -# $Id: Makefile,v 1.1 1999/02/15 19:13:47 hm Exp $ +# $Id: Makefile,v 1.1 1999/03/07 17:09:03 hm Exp $ # -# last edit-date: [Mon Feb 15 20:04:40 1999] +# last edit-date: [Thu May 20 12:04:05 1999] # #--------------------------------------------------------------------------- PROG = dtmfdecode SRC = dtmfdecode.c -LDADD += -lm +#LDADD += -lm CFLAGS += -Wall -g -DDEBUG MAN1 = dtmfdecode.1 diff --git a/usr.sbin/i4b/dtmfdecode/README b/usr.sbin/i4b/dtmfdecode/README deleted file mode 100644 index d25cbd2..0000000 --- a/usr.sbin/i4b/dtmfdecode/README +++ /dev/null @@ -1,44 +0,0 @@ - - [Note: the version included in i4b does not output any data you can - plot, but will just print the values of the tones it detected. -hm] - - -Poul-Henning Kamp wrote: ------------------------- - -I remember that somebody asked about this long time ago, so I sat -down and hacked a digital filter for that. - -The following piece of code will read a ".g711a" file, and output -9 columns of data. The first is the linear value of the sample, -the other 8 are strength of the 8 DTMF tones. - -Try to run the "beep.g711a" file from i4b through it, and plot the -output columns with gnuplot. It seems Hellmuth pressed a '1' :-) - -The implementation is a recursive resonance filter, actually 8 of -them, one for each frequency, done in floating point. With a little -attention to rounding, it can be done just as good, and much faster -in integer math, in fact 16 bit should be enough, but may not be -faster than 32bit. - -The "POLRAD" quantity determines the resonance width of the filters, -if you make it too low, it will confuse tones and recognize them -where they are not. If you make it too high (never, ever >= 1.0!) -it will take longer to react and maybe not catch a slightly offbeat -tone. If you set it above or equal to 1.0 you get a tone generator. - -This could also be a good basis for a 300Baud FSK modem emulation. - -It seems that the .g711a files are bit-flipped, therefore the flip[] -array trick in this code. The alaw->linear converter is lifted from -sox. - -Now, who writes the answering-machine to end all answering machines -for i4b ? - -Poul-Henning --- -Poul-Henning Kamp FreeBSD coreteam member -phk@FreeBSD.ORG "Real hackers run -current on their laptop." -"ttyv0" -- What UNIX calls a $20K state-of-the-art, 3D, hi-res color terminal diff --git a/usr.sbin/i4b/dtmfdecode/dtmfdecode.1 b/usr.sbin/i4b/dtmfdecode/dtmfdecode.1 index 64c6fb3..74ab112 100644 --- a/usr.sbin/i4b/dtmfdecode/dtmfdecode.1 +++ b/usr.sbin/i4b/dtmfdecode/dtmfdecode.1 @@ -22,16 +22,16 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dtmfdecode.1,v 1.1 1999/02/15 19:13:47 hm Exp $ +.\" $Id: dtmfdecode.1,v 1.4 1999/04/26 11:42:33 hm Exp $ .\" -.\" last edit-date: [Mon Feb 15 20:11:30 1999] +.\" last edit-date: [Mon Apr 26 13:42:15 1999] .\" .\" .Dd February, 15 1999 .Dt dtmfdecode 1 .Sh NAME .Nm dtmfdecode -.Nd decodes DTMF tones from i4b .g711a files +.Nd decodes DTMF tones from A-law audio data .Sh SYNOPSIS .Nm .Sh DESCRIPTION @@ -42,11 +42,14 @@ audio stream. It reads audio G.711 A-Law coded data from stdin and outputs the detected numbers values as ASCII charcters to stdout. .Pp +The detector is implemented as 8 narrow band-pass filters realized with +an integer double-cross recursive algorithm. Various ad-hoc methods are +employed to provide hysteresis and anti-bounce for the detected signals. .Sh EXAMPLES The command: .Bd -literal -offset indent -dtmfdecode < beep.g711a +dtmfdecode < beep.al .Ed .Pp will print a "1" to stdout. diff --git a/usr.sbin/i4b/dtmfdecode/dtmfdecode.c b/usr.sbin/i4b/dtmfdecode/dtmfdecode.c index 2b53fa6..589290f 100644 --- a/usr.sbin/i4b/dtmfdecode/dtmfdecode.c +++ b/usr.sbin/i4b/dtmfdecode/dtmfdecode.c @@ -6,9 +6,9 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: dtmfdecode.c,v 1.1 1999/02/15 19:13:47 hm Exp $ + * $Id: dtmfdecode.c,v 1.5 1999/04/26 11:41:49 hm Exp $ * - * Extract DTMF signalling from a .g711a file from ISDN4BSD + * Extract DTMF signalling from ISDN4BSD A-law coded audio data * * A-Law to linear conversion from the sox package. * @@ -17,22 +17,16 @@ #include <stdio.h> #include <math.h> -/* - * g711.c - * - * u-law, A-law and linear PCM conversions. - */ +/* Integer math scaling factor */ +#define FSC (1<<12) + +/* Alaw parameters */ #define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ #define QUANT_MASK (0xf) /* Quantization field mask. */ -#define NSEGS (8) /* Number of A-law segments. */ #define SEG_SHIFT (4) /* Left shift for segment number. */ #define SEG_MASK (0x70) /* Segment field mask. */ -/* - * alaw2linear() - Convert an A-law value to 16-bit linear PCM - * - */ -int +static int alaw2linear(a_val) unsigned char a_val; { @@ -57,102 +51,100 @@ alaw2linear(a_val) return ((a_val & SIGN_BIT) ? t : -t); } -int flip[256]; - -double dtmf[8] = {697, 770, 852, 941, 1209, 1336, 1477, 1633}; -double p1[8]; +#ifdef USE_COS +/* The frequencies we're trying to detect */ +static int dtmf[8] = {697, 770, 852, 941, 1209, 1336, 1477, 1633}; +#else +/* precalculated: p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0) * FSC) */ +static int p1[8] = {-3497, -3369, -3212, -3027, -2384, -2040, -1635, -1164}; +#endif -/* This is the Q of the filter (pole radius). must be less than 1.0 */ +/* This is the Q of the filter (pole radius) */ #define POLRAD .99 -#define P2 (POLRAD*POLRAD) - -#define NNN 100 - -char key [256]; +#define P2 ((int)(POLRAD*POLRAD*FSC)) int main(int argc, char **argv) { - int i, j, kk, nn, s, so = 0; - double x, a[8], b[8], c[8], d[8], e[8], f[8], g[8], h[8], k[8], l[8], m[8], n[8], y[8]; - + int i, kk, t, nn, s, so, ia; + int x, c, d, f, h[8], k[8], n, y[8]; +#ifdef USE_COS + int p1[8]; +#endif + int alaw[256]; + char key[256]; for (kk = 0; kk < 8; kk++) { - y[kk] = g[kk] = k[kk] = 0.0; - p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0)); + y[kk] = h[kk] = k[kk] = 0; +#ifdef USE_COS + p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0) * FSC); +#endif } - for (i=0;i<256;i++) { - key[i] = '\0'; - flip[i] = (i & 1) << 7; - flip[i] |= (i & 2) << 5; - flip[i] |= (i & 4) << 3; - flip[i] |= (i & 8) << 1; - flip[i] |= (i & 16) >> 1; - flip[i] |= (i & 32) << 3; - flip[i] |= (i & 64) << 5; - flip[i] |= (i & 128) << 7; + for (i = 0; i < 256; i++) { + key[i] = '?'; + alaw[i] = alaw2linear(i) / (32768/FSC); } + /* We encode the tones in 8 bits, translate those to symbol */ key[0x00] = '\0'; - key[0x11] = '1'; - key[0x12] = '4'; - key[0x14] = '7'; - key[0x18] = '*'; - - key[0x21] = '2'; - key[0x22] = '5'; - key[0x24] = '8'; - key[0x28] = '0'; - - key[0x41] = '3'; - key[0x42] = '6'; - key[0x44] = '9'; - key[0x48] = '#'; - - key[0x81] = 'A'; - key[0x82] = 'B'; - key[0x84] = 'C'; - key[0x88] = 'D'; - - x = 0.0; + + key[0x11] = '1'; key[0x12] = '4'; key[0x14] = '7'; key[0x18] = '*'; + key[0x21] = '2'; key[0x22] = '5'; key[0x24] = '8'; key[0x28] = '0'; + key[0x41] = '3'; key[0x42] = '6'; key[0x44] = '9'; key[0x48] = '#'; + key[0x81] = 'A'; key[0x82] = 'B'; key[0x84] = 'C'; key[0x88] = 'D'; + nn = 0; - while ((i = getchar()) != EOF) { - i = flip[i]; - j = alaw2linear(i); + ia = 0; + so = 0; + t = 0; + while ((i = getchar()) != EOF) + { + t++; + + /* Convert to our format */ + x = alaw[i]; + + /* Input amplitude */ + if (x > 0) + ia += (x - ia) / 128; + else + ia += (-x - ia) / 128; - x = j / 32768.0; + /* For each tone */ s = 0; for(kk = 0; kk < 8; kk++) { - a[kk] = x; - h[kk] = g[kk]; - l[kk] = k[kk]; - - b[kk] = a[kk] - l[kk]; - c[kk] = P2 * b[kk]; - d[kk] = a[kk] + c[kk]; - e[kk] = d[kk] - h[kk]; - f[kk] = p1[kk] * e[kk]; - g[kk] = f[kk] + d[kk]; - k[kk] = h[kk] + f[kk]; - m[kk] = l[kk] + c[kk]; - n[kk] = a[kk] - m[kk]; - - y[kk] += (fabs(n[kk]) - y[kk]) / 20.0; - if (y[kk] > .1) + + /* Turn the crank */ + c = (P2 * (x - k[kk])) / FSC; + d = x + c; + f = (p1[kk] * (d - h[kk])) / FSC; + n = x - k[kk] - c; + k[kk] = h[kk] + f; + h[kk] = f + d; + + /* Detect and Average */ + if (n > 0) + y[kk] += (n - y[kk]) / 64; + else + y[kk] += (-n - y[kk]) / 64; + + /* Threshold */ + if (y[kk] > FSC/10 && y[kk] > ia) s |= 1 << kk; } - if (s != so) + + /* Hysteresis and noise supressor */ + if (s != so) { +/* printf("x %d %x -> %x\n",t,so, s); */ nn = 0; - else - nn++; - if (nn == NNN) { - if (key[s]) - putchar(key[s]); + so = s; + } else if (nn++ == 520 && key[s]) { + putchar(key[s]); +/* printf(" %d %x\n",t,s); */ } - so = s; } - printf("\n"); + putchar('\n'); return (0); } diff --git a/usr.sbin/i4b/g711conv/Makefile b/usr.sbin/i4b/g711conv/Makefile new file mode 100644 index 0000000..4ea7fa0 --- /dev/null +++ b/usr.sbin/i4b/g711conv/Makefile @@ -0,0 +1,14 @@ +#--------------------------------------------------------------------------- +# +# $Id: Makefile,v 1.3 1999/04/25 12:45:26 hm Exp $ +# +# last edit-date: [Thu May 20 11:58:43 1999] +# +#--------------------------------------------------------------------------- + +PROG = g711conv +SRC = g711conv.c +CFLAGS += -Wall -g +MAN1 = g711conv.1 + +.include <bsd.prog.mk> diff --git a/usr.sbin/i4b/g711conv/g711conv.1 b/usr.sbin/i4b/g711conv/g711conv.1 new file mode 100644 index 0000000..d9b5161 --- /dev/null +++ b/usr.sbin/i4b/g711conv/g711conv.1 @@ -0,0 +1,92 @@ +.\" +.\" Copyright (c) 1999 Hellmuth Michaelis. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $Id: g711conv.1,v 1.1 1999/03/16 12:39:53 hm Exp $ +.\" +.\" last edit-date: [Mon Mar 15 16:17:23 1999] +.\" +.Dd March 15, 1999 +.Dt g711conv 1 +.Sh NAME +.Nm g711conv +.Nd conversions according to G.711 +.Sh SYNOPSIS +.Nm +.Op Fl a +.Op Fl u +.Op Fl P +.Op Fl A +.Op Fl R +.Sh DESCRIPTION +.Nm g711conv +is part of the isdn4bsd package and is used to convert between the A-Law and +u-law formats as specified in ITU G.711. It is based on a freely available +and freely usable reference implementation done by Sun Microsystems, Inc. +.Pp +The following options are available: +.Bl -tag -width Ds +.It Fl a +Convert A-law to u-law +.It Fl u +Convert u-law to A-law +.It Fl r +Reverse bits before conversion +.It Fl R +Reverse bits after conversion +.It Fl P +Print the resulting conversion tables (as C-source) to stdout instead of +doing the actual conversion. +.El +.Pp + +.Sh STANDARDS +A-Law and u-Law conversions are specified in ITU Recommendation G.711. +.Pp +The reference implementation done by Sun Microsystems, Inc. is available +from http://www.itu.int/itudoc/itu-t/rec/g/g700-799/refimpl.txt + +.Sh EXAMPLES +The command: +.Bd -literal -offset indent +g711conv -P -a +.Ed +.Pp +prints out the A-law to u-law conversion table as C-source to stdout. +.Pp +The command: +.Bd -literal -offset indent +cat max_headroom.ul | g711conv -u -R > /dev/i4btel0 +.Ed +.Pp +converts the u-law coded voice of Max Headroom to A-law, reverses the +bits of the result and moves that to an active isdn4bsd telephone connection. +.Pp + +.Sh AUTHOR +The +.Nm +utility and this manpage were written by Hellmuth Michaelis (hm@kts.org) +based on the G.711 conversion reference code written by Sun Microsystems, +Inc. and code contributed to isdn4bsd by Stefan Bethke. + diff --git a/usr.sbin/i4b/g711conv/g711conv.c b/usr.sbin/i4b/g711conv/g711conv.c new file mode 100644 index 0000000..a41ba08 --- /dev/null +++ b/usr.sbin/i4b/g711conv/g711conv.c @@ -0,0 +1,304 @@ +/* + * Copyright (c) 1999 Hellmuth Michaelis. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * --- + * + * The A-law to u-law and u-law to A-law conversion routines and tables + * were taken from the G.711 reference implementation from Sun and freely + * available as http://www.itu.int/itudoc/itu-t/rec/g/g700-799/refimpl.txt. + * + * Therefore for that part of the code, the following restrictions apply: + * + * + * This source code is a product of Sun Microsystems, Inc. and is provided + * for unrestricted use. Users may copy or modify this source code without + * charge. + * + * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING + * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun source code is provided with no support and without any obligation on + * the part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * --- + * + * The bitreverse table was contributed by Stefan Bethke. + * + *--------------------------------------------------------------------------- + * + * A-law / u-law conversions as specified in G.711 + * ----------------------------------------------- + * + * last edit-date: [Mon Apr 26 14:00:31 1999] + * + * $Id: g711conv.c,v 1.3 1999/04/26 12:10:39 hm Exp $ + * + *---------------------------------------------------------------------------*/ + +#include <stdio.h> +#include <unistd.h> +#include <machine/i4b_ioctl.h> + +/* copy from CCITT G.711 specifications */ + +/* u- to A-law conversions */ + +unsigned char _u2a[128] = { + 1, 1, 2, 2, 3, 3, 4, 4, + 5, 5, 6, 6, 7, 7, 8, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 29, 31, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, + 46, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, + 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, + 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, + 121, 122, 123, 124, 125, 126, 127, 128 +}; + +/* A- to u-law conversions */ + +unsigned char _a2u[128] = { + 1, 3, 5, 7, 9, 11, 13, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 32, 33, 33, 34, 34, 35, 35, + 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 48, 49, 49, + 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 64, + 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 79, + 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127 +}; + +/* reverse bits (7->0, 6->1, 5->2 etc) for tx to / rx from ISDN */ + +unsigned char bitreverse[256] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; + +/* A-law to u-law conversion */ + +unsigned char alaw2ulaw(unsigned char aval) +{ + aval &= 0xff; + return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) : + (0x7F ^ _a2u[aval ^ 0x55])); +} + +/* u-law to A-law conversion */ + +unsigned char ulaw2alaw(unsigned char uval) +{ + uval &= 0xff; + return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) : + (0x55 ^ (_u2a[0x7F ^ uval] - 1))); +} + +void +usage(void) +{ + fprintf(stderr, "\n"); + fprintf(stderr, "g711conv - do conversions according to ITU G.711, (version %d.%d.%d)\n",VERSION, REL, STEP); + fprintf(stderr, "usage: g711conv -a -r -R -u -P\n"); + fprintf(stderr, " -a A-law to u-law conversion\n"); + fprintf(stderr, " -r reverse bits before conversion\n"); + fprintf(stderr, " -R reverse bits after conversion\n"); + fprintf(stderr, " -u u-law to A-law conversion\n"); + fprintf(stderr, " -P print conversion table as C source\n"); + fprintf(stderr, "\n"); + exit(1); +} + +int +main(int argc, char **argv) +{ + int i; + int c; + int opt_a = 0; + int opt_u = 0; + int opt_r = 0; + int opt_P = 0; + int opt_R = 0; + unsigned char uc; + + while ((c = getopt(argc, argv, "aurPR?")) != EOF) + { + switch(c) + { + case 'a': + opt_a = 1; + break; + + case 'u': + opt_u = 1; + break; + + case 'r': + opt_r = 1; + break; + + case 'R': + opt_R = 1; + break; + + case 'P': + opt_P = 1; + break; + + case '?': + default: + usage(); + break; + } + } + + if((opt_a + opt_u) > 1) + usage(); + + if(opt_P) + { + printf("\n/* "); + + if((opt_a + opt_u) == 0) + printf("No Conversion"); + + if(opt_a) + printf("A-law to u-law conversion"); + + if(opt_u) + printf("u-law to A-law conversion"); + + if(opt_r) + printf(", reverse bits BEFORE conversion"); + + if(opt_R) + printf(", reverse bits AFTER conversion"); + + if(opt_a) + { + printf(" */\n\nunsigned char a2u_tab[256] = {"); + } + else if(opt_u) + { + printf(" */\n\nunsigned char u2a_tab[256] = {"); + } + else + { + printf(" */\n\nunsigned char table[256] = {"); + } + + for(i=0; i < 256; i++) + { + uc = i; + + if(!(i % 8)) + printf("\n/* %02x */\t", i); + + if(opt_r) + uc = bitreverse[uc]; + + if(opt_u) + uc = ulaw2alaw(uc); + + if(opt_a) + uc = alaw2ulaw(uc); + + if(opt_R) + uc = bitreverse[uc]; + + if(i == 255) + printf("0x%02x", uc); + else + printf("0x%02x, ", uc); + } + printf("\n};\n"); + } + else + { + unsigned char ib[1]; + + while(fread(ib, 1, 1, stdin) == 1) + { + if(opt_r) + ib[0] = bitreverse[ib[0]]; + + if(opt_u) + ib[0] = ulaw2alaw(ib[0]); + + if(opt_a) + ib[0] = alaw2ulaw(ib[0]); + + if(opt_R) + ib[0] = bitreverse[ib[0]]; + + fwrite(ib, 1, 1, stdout); + } + } + return(0); +} + +/* EOF */ diff --git a/usr.sbin/i4b/isdnd/controller.c b/usr.sbin/i4b/isdnd/controller.c index d34c067..ef9889a 100644 --- a/usr.sbin/i4b/isdnd/controller.c +++ b/usr.sbin/i4b/isdnd/controller.c @@ -27,9 +27,9 @@ * i4b daemon - controller state support routines * ---------------------------------------------- * - * $Id: controller.c,v 1.12 1999/02/15 16:48:04 hm Exp $ + * $Id: controller.c,v 1.16 1999/05/10 19:36:16 hm Exp $ * - * last edit-date: [Mon Feb 15 16:37:55 1999] + * last edit-date: [Mon May 10 21:35:55 1999] * *---------------------------------------------------------------------------*/ @@ -87,10 +87,23 @@ init_controller_state(int controller, int ctrl_type, int card_type, int tei) name_of_controller(isdn_ctrl_tab[controller].ctrl_type, isdn_ctrl_tab[controller].card_type)); } + else if(ctrl_type == CTRL_TINADD) + { + isdn_ctrl_tab[controller].ctrl_type = ctrl_type; + isdn_ctrl_tab[controller].card_type = 0; + isdn_ctrl_tab[controller].state = CTRL_DOWN; + isdn_ctrl_tab[controller].stateb1 = CHAN_IDLE; + isdn_ctrl_tab[controller].stateb2 = CHAN_IDLE; + isdn_ctrl_tab[controller].freechans = MAX_CHANCTRL; + isdn_ctrl_tab[controller].tei = -1; + log(LL_DMN, "init_controller_state: controller %d is %s", + controller, + name_of_controller(isdn_ctrl_tab[controller].ctrl_type, + isdn_ctrl_tab[controller].card_type)); + + } else { - /* XXX active controller init here !!! */ - log(LL_ERR, "init_controller_state: unknown controller type %d", ctrl_type); return(ERROR); } @@ -98,6 +111,34 @@ init_controller_state(int controller, int ctrl_type, int card_type, int tei) } /*--------------------------------------------------------------------------* + * init active controller + *--------------------------------------------------------------------------*/ +void +init_active_controller(void) +{ + int ret; + int unit = 0; + int controller; + char cmdbuf[MAXPATHLEN+128]; + + for(controller = 0; controller < ncontroller; controller++) + { + if(isdn_ctrl_tab[controller].ctrl_type == CTRL_TINADD) + { + DBGL(DL_RCCF, (log(LL_DBG, "init_active_controller, tina-dd %d: executing [%s %d]", unit, tinainitprog, unit))); + + sprintf(cmdbuf, "%s %d", tinainitprog, unit); + + if((ret = system(cmdbuf)) != 0) + { + log(LL_ERR, "init_active_controller, tina-dd %d: %s returned %d!", unit, tinainitprog, ret); + do_exit(1); + } + } + } +} + +/*--------------------------------------------------------------------------* * set controller state to UP/DOWN *--------------------------------------------------------------------------*/ int @@ -289,7 +330,7 @@ set_channel_idle(int controller, int channel) break; default: - log(LL_ERR, "set_channel_idle: controller [%d], invalid channel [%d]!", controller, channel); + DBGL(DL_CNST, (log(LL_DBG, "set_channel_idle: controller [%d], invalid channel [%d]!", controller, channel))); return(ERROR); break; } diff --git a/usr.sbin/i4b/isdnd/isdnd.acct.5 b/usr.sbin/i4b/isdnd/isdnd.acct.5 index 34e8cff..3ba3d09 100644 --- a/usr.sbin/i4b/isdnd/isdnd.acct.5 +++ b/usr.sbin/i4b/isdnd/isdnd.acct.5 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: isdnd.acct.5,v 1.8 1999/02/15 16:48:04 hm Exp $ +.\" $Id: isdnd.acct.5,v 1.9 1999/05/03 08:48:25 hm Exp $ .\" .\" last edit-date: [Mon Feb 15 16:54:23 1999] .\" @@ -90,6 +90,7 @@ is the (optional) number of bytes that were transferred. The default accounting information file for the .Nm isdnd ISDN daemon. +.El .Sh EXAMPLES This is a typical accounting line: diff --git a/usr.sbin/i4b/isdnd/isdnd.h b/usr.sbin/i4b/isdnd/isdnd.h index e4033ff..f630a01 100644 --- a/usr.sbin/i4b/isdnd/isdnd.h +++ b/usr.sbin/i4b/isdnd/isdnd.h @@ -27,9 +27,9 @@ * i4b daemon - main header file * ----------------------------- * - * $Id: isdnd.h,v 1.59 1999/02/15 15:02:58 hm Exp $ + * $Id: isdnd.h,v 1.62 1999/04/29 08:27:10 hm Exp $ * - * last edit-date: [Mon Feb 15 15:42:37 1999] + * last edit-date: [Thu Apr 29 09:35:01 1999] * *---------------------------------------------------------------------------*/ @@ -265,11 +265,12 @@ typedef struct cfg_entry { int idle_time_in; /* max idle time incoming calls */ int idle_time_out; /* max idle time outgoing calls */ - msg_shorthold_algorithm_t shorthold_algorithm; /* shorthold algorithm */ - int unitlength; /* length of a charging unit */ + int shorthold_algorithm; /* shorthold algorithm */ + + int unitlength; /* length of a charging unit */ #define UNITLENGTH_DEFAULT 60 /* last resort unit length */ - int earlyhangup; /* time in seconds to hangup */ + int earlyhangup; /* time in seconds to hangup */ /* before the next expected */ /* charging unit */ #define EARLYHANGUP_DEFAULT 5 @@ -547,6 +548,8 @@ int accepted = 0; int isdntime = 0; /* flag, log time from exchange */ +char tinainitprog[MAXPATHLEN] = TINA_FILE_DEF; + #else /* !MAIN */ int isdnfd; @@ -618,6 +621,8 @@ int accepted; int isdntime; +char tinainitprog[MAXPATHLEN]; + #endif /* MAIN */ char * bdrivername ( int drivertype ); @@ -645,6 +650,7 @@ int exec_answer ( cfg_entry_t *cep ); int exec_connect_prog ( cfg_entry_t *cep, const char *prog, int link_down ); pid_t exec_prog ( char *prog, char **arglist ); cfg_entry_t * find_by_device_for_dialout ( int drivertype, int driverunit ); +cfg_entry_t *find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, char *cmd); cfg_entry_t * find_matching_entry_incoming ( msg_connect_ind_t *mp ); cfg_entry_t * find_active_entry_by_driver ( int drivertype, int driverunit ); void finish_log ( void ); @@ -673,6 +679,7 @@ void msg_negcomplete_ind(msg_negcomplete_ind_t *ind); void msg_ifstatechg_ind(msg_ifstatechg_ind_t *ind); void msg_drvrdisc_req(msg_drvrdisc_req_t *mp); void msg_dialout ( msg_dialout_ind_t *mp ); +void msg_dialoutnumber(msg_dialoutnumber_ind_t *mp); void msg_disconnect_ind ( msg_disconnect_ind_t *mp ); void msg_idle_timeout_ind ( msg_idle_timeout_ind_t *mp ); void msg_l12stat_ind(msg_l12stat_ind_t *ml); @@ -736,6 +743,7 @@ void monitor_evnt_log(int prio, const char * what, const char * msg); /* controller.c */ int init_controller_state(int controller, int ctrl_type, int card_type, int tei); +void init_active_controller(void); int set_controller_state(int controller, int state); int get_controller_state(int controller); int decr_free_channels(int controller); diff --git a/usr.sbin/i4b/isdnd/isdnd.rates.5 b/usr.sbin/i4b/isdnd/isdnd.rates.5 index 4a8cc94..60abb26 100644 --- a/usr.sbin/i4b/isdnd/isdnd.rates.5 +++ b/usr.sbin/i4b/isdnd/isdnd.rates.5 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: isdnd.rates.5,v 1.7 1999/02/14 09:44:56 hm Exp $ +.\" $Id: isdnd.rates.5,v 1.8 1999/05/03 08:48:25 hm Exp $ .\" .\" last edit-date: [Sun Feb 14 10:11:05 1999] .\" @@ -88,6 +88,7 @@ lasts 90 seconds. The default rates specification file for the .Nm isdnd ISDN daemon. +.El .Sh EXAMPLES The line: diff --git a/usr.sbin/i4b/isdnd/isdnd.rc.5 b/usr.sbin/i4b/isdnd/isdnd.rc.5 index 4e21b46..42af1db 100644 --- a/usr.sbin/i4b/isdnd/isdnd.rc.5 +++ b/usr.sbin/i4b/isdnd/isdnd.rc.5 @@ -22,9 +22,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: isdnd.rc.5,v 1.31 1999/02/25 19:16:53 hm Exp $ +.\" $Id: isdnd.rc.5,v 1.34 1999/05/03 08:48:25 hm Exp $ .\" -.\" last edit-date: [Thu Feb 25 20:15:38 1999] +.\" last edit-date: [Thu Apr 8 18:29:22 1999] .\" .Dd February, 23, 1999 .Dt isdnd.rc 5 @@ -299,7 +299,6 @@ Normal behavior, call the remote site which is supposed to accept the call. .It Ar calledback Callback behavior, call the remote side which rejects the call and calls us back. -.El .It Li dialrandincr When dialing or re-dialing and this parameter is set to @@ -316,6 +315,7 @@ This keyword is used to configure if incoming and outgoing, incoming-only or outgoing only connections are possible. The keyword is optional, the default is .Em inout . +.El .Pp The currently supported parameters are: .Pp @@ -365,10 +365,12 @@ units time has expired. .It Li idletime-outgoing The time in seconds an outgoing connection must be idle before hanging up. +An idle timeout of zero disables this functionality. (optional) .It Li idletime-incoming The time in seconds an incoming connection must be idle before hanging up. +An idle timeout of zero disables this functionality. (optional) .It Li isdncontroller @@ -415,8 +417,7 @@ out to a remote site, the number specified here is put into the .Em "Calling Party Number Information Element" . .Pp This keyword is mandatory for the -.em -ipr +.Em ipr userland interfaces. .It Li local-phone-incoming @@ -466,8 +467,7 @@ out to a remote site, the number specified here is put into the .Em "Called Party Number Information Element" . .Pp This keyword is mandatory for the -.em -ipr +.Em ipr interfaces. It may be specified more than once to try to dial to several numbers until one succeeds. @@ -707,6 +707,7 @@ network will cause a new call to be placed. The default configuration file for the .Nm isdnd ISDN daemon. +.El .Sh SEE ALSO .Xr isdnd 8 diff --git a/usr.sbin/i4b/isdnd/main.c b/usr.sbin/i4b/isdnd/main.c index eb6ae5c..d43c13f 100644 --- a/usr.sbin/i4b/isdnd/main.c +++ b/usr.sbin/i4b/isdnd/main.c @@ -27,9 +27,9 @@ * i4b daemon - main program entry * ------------------------------- * - * $Id: main.c,v 1.34 1999/02/23 16:25:49 hm Exp $ + * $Id: main.c,v 1.36 1999/04/29 08:27:10 hm Exp $ * - * last edit-date: [Tue Feb 23 16:47:33 1999] + * last edit-date: [Thu Apr 29 09:41:21 1999] * *---------------------------------------------------------------------------*/ @@ -306,6 +306,14 @@ main(int argc, char **argv) exit(1); } + /* init active controllers, if any */ + + signal(SIGCHLD, SIG_IGN); /*XXX*/ + + init_active_controller(); + + signal(SIGCHLD, sigchild_handler); /*XXX*/ + /* handle the rates stuff */ if((i = readrates(ratesfile)) == ERROR) @@ -622,6 +630,10 @@ isdnrdhdl(void) msg_ifstatechg_ind((msg_ifstatechg_ind_t *)msg_rd_buf); break; + case MSG_DIALOUTNUMBER_IND: + msg_dialoutnumber((msg_dialoutnumber_ind_t *)msg_rd_buf); + break; + default: log(LL_WRN, "ERROR, unknown message received from /dev/isdn (0x%x)", msg_rd_buf[0]); break; diff --git a/usr.sbin/i4b/isdnd/monitor.c b/usr.sbin/i4b/isdnd/monitor.c index 53beb43..9bc09f6 100644 --- a/usr.sbin/i4b/isdnd/monitor.c +++ b/usr.sbin/i4b/isdnd/monitor.c @@ -33,7 +33,7 @@ * i4b daemon - network monitor server module * ------------------------------------------ * - * $Id: monitor.c,v 1.8 1999/02/15 16:48:04 hm Exp $ + * $Id: monitor.c,v 1.9 1999/05/06 08:24:45 hm Exp $ * * last edit-date: [Mon Feb 15 16:42:18 1999] * @@ -351,10 +351,11 @@ int monitor_create_local_socket() sa.sun_len = sizeof sa; sa.sun_family = AF_LOCAL; strcpy(sa.sun_path, VARA_AT(rights, local_rights).name); - if (bind(s, (struct sockaddr *)&sa, sizeof sa)) { + if (bind(s, (struct sockaddr *)&sa, SUN_LEN(&sa))) { log(LL_ERR, "could not bind local monitor socket [%s], errno = %d", VARA_AT(rights, local_rights).name, errno); exit(1); } + chmod(VARA_AT(rights, local_rights).name, 0500); if (listen(s, 0)) { log(LL_ERR, "could not listen on local monitor socket, errno = %d", errno); exit(1); diff --git a/usr.sbin/i4b/isdnd/msghdl.c b/usr.sbin/i4b/isdnd/msghdl.c index b24ac24..4d59c26 100644 --- a/usr.sbin/i4b/isdnd/msghdl.c +++ b/usr.sbin/i4b/isdnd/msghdl.c @@ -27,9 +27,9 @@ * i4b daemon - message from kernel handling routines * -------------------------------------------------- * - * $Id: msghdl.c,v 1.57 1999/02/25 12:45:41 hm Exp $ + * $Id: msghdl.c,v 1.60 1999/05/10 19:34:54 hm Exp $ * - * last edit-date: [Thu Feb 25 13:43:46 1999] + * last edit-date: [Mon May 10 21:32:46 1999] * *---------------------------------------------------------------------------*/ @@ -526,8 +526,7 @@ msg_disconnect_ind(msg_disconnect_ind_t *mp) mp->header.cdid))); cep->saved_call.cdid = CDID_UNUSED; - if((set_channel_idle(cep->saved_call.controller, cep->saved_call.channel)) == ERROR) - log(LL_ERR, "msg_disconnect_ind: set_channel_idle failed!"); + set_channel_idle(cep->saved_call.controller, cep->saved_call.channel); incr_free_channels(cep->saved_call.controller); return; @@ -630,8 +629,7 @@ msg_disconnect_ind(msg_disconnect_ind_t *mp) /* set the B-channel inactive */ - if((set_channel_idle(cep->isdncontrollerused, cep->isdnchannelused)) == ERROR) - log(LL_ERR, "msg_disconnect_ind: set_channel_idle failed!"); + set_channel_idle(cep->isdncontrollerused, cep->isdnchannelused); incr_free_channels(cep->isdncontrollerused); @@ -675,6 +673,40 @@ msg_dialout(msg_dialout_ind_t *mp) } /*---------------------------------------------------------------------------* + * handle incoming DIALOUTNUMBER message + *---------------------------------------------------------------------------*/ +void +msg_dialoutnumber(msg_dialoutnumber_ind_t *mp) +{ + cfg_entry_t *cep; + + DBGL(DL_DRVR, (log(LL_DBG, "msg_dialoutnumber: dial req from %s, unit %d", bdrivername(mp->driver), mp->driver_unit))); + + if((cep = find_by_device_for_dialoutnumber(mp->driver, mp->driver_unit, mp->cmdlen, mp->cmd)) == NULL) + { + DBGL(DL_DRVR, (log(LL_DBG, "msg_dialoutnumber: config entry reserved or no match"))); + return; + } + + if(cep->inout == DIR_INONLY) + { + dialresponse(cep, DSTAT_INONLY); + return; + } + + if((cep->cdid = get_cdid()) == 0) + { + DBGL(DL_DRVR, (log(LL_DBG, "msg_dialoutnumber: get_cdid() returned 0!"))); + return; + } + + cep->charge = 0; + cep->last_charge = 0; + + next_state(cep, EV_MDO); +} + +/*---------------------------------------------------------------------------* * handle incoming DRVRDISC_REQ message *---------------------------------------------------------------------------*/ void diff --git a/usr.sbin/i4b/isdnd/pathnames.h b/usr.sbin/i4b/isdnd/pathnames.h index f986116..d656825 100644 --- a/usr.sbin/i4b/isdnd/pathnames.h +++ b/usr.sbin/i4b/isdnd/pathnames.h @@ -27,9 +27,9 @@ * i4b daemon - location of files * ------------------------------ * - * $Id: pathnames.h,v 1.7 1999/02/14 19:51:01 hm Exp $ + * $Id: pathnames.h,v 1.8 1999/04/29 08:27:10 hm Exp $ * - * last edit-date: [Sun Feb 14 10:11:43 1999] + * last edit-date: [Thu Apr 29 09:07:29 1999] * *---------------------------------------------------------------------------*/ @@ -42,6 +42,8 @@ #define CONFIG_FILE_DEF "/etc/isdn/isdnd.rc" #define RATES_FILE_DEF "/etc/isdn/isdnd.rates" +#define TINA_FILE_DEF "/etc/isdn/tinainitprog" + #define LIBDIR "/usr/local/lib/isdn" #define LOG_FILE_DEF "/var/log/isdnd.log" diff --git a/usr.sbin/i4b/isdnd/rc_config.c b/usr.sbin/i4b/isdnd/rc_config.c index 3fa3ef5..b2861a4 100644 --- a/usr.sbin/i4b/isdnd/rc_config.c +++ b/usr.sbin/i4b/isdnd/rc_config.c @@ -27,9 +27,9 @@ * i4b daemon - config file processing * ----------------------------------- * - * $Id: rc_config.c,v 1.40 1999/02/23 16:25:49 hm Exp $ + * $Id: rc_config.c,v 1.42 1999/04/29 08:27:10 hm Exp $ * - * last edit-date: [Tue Feb 23 16:43:56 1999] + * last edit-date: [Thu Apr 29 08:49:46 1999] * *---------------------------------------------------------------------------*/ @@ -380,11 +380,11 @@ cfg_setval(int keyword) if(!(strcmp(yylval.str, "fix-unit-size"))) { - cfg_entry_tab[entrycount].shorthold_algorithm = msg_alg__fix_unit_size; + cfg_entry_tab[entrycount].shorthold_algorithm = SHA_FIXU; } else if(!(strcmp(yylval.str, "var-unit-size"))) { - cfg_entry_tab[entrycount].shorthold_algorithm = msg_alg__var_unit_size; + cfg_entry_tab[entrycount].shorthold_algorithm = SHA_VARU; } else { @@ -644,6 +644,11 @@ cfg_setval(int keyword) #endif break; + case TINAINITPROG: + strcpy(tinainitprog, yylval.str); + DBGL(DL_RCCF, (log(LL_DBG, "system: tinainitprog = %s", yylval.str))); + break; + case UNITLENGTH: DBGL(DL_RCCF, (log(LL_DBG, "entry %d: unitlength = %d", entrycount, yylval.num))); cfg_entry_tab[entrycount].unitlength = yylval.num; @@ -1099,18 +1104,26 @@ print_config(void) } if(!((cep->inout == DIR_INONLY) || (cep->usrdevicename == BDRV_TEL))) - { + { char *s; fprintf(PFILE, "idletime-outgoing = %d\t\t# outgoing call idle timeout\n", cep->idle_time_out); switch( cep->shorthold_algorithm ) - { - case msg_alg__fix_unit_size: s = "fix-unit-size"; break; - case msg_alg__var_unit_size: s = "var-unit-size"; break; - default: s = "error!!!"; break; - } - fprintf(PFILE, "idle-algorithm-outgoing = %s\t\t# outgoing call idle algorithm\n", s); + { + case SHA_FIXU: + s = "fix-unit-size"; + break; + case SHA_VARU: + s = "var-unit-size"; + break; + default: + s = "error!!!"; + break; } + + fprintf(PFILE, "idle-algorithm-outgoing = %s\t\t# outgoing call idle algorithm\n", s); + } + if(!(cep->inout == DIR_OUTONLY)) fprintf(PFILE, "idletime-incoming = %d\t\t# incoming call idle timeout\n", cep->idle_time_in); diff --git a/usr.sbin/i4b/isdnd/rc_parse.y b/usr.sbin/i4b/isdnd/rc_parse.y index 8e00b78..2c001c9 100644 --- a/usr.sbin/i4b/isdnd/rc_parse.y +++ b/usr.sbin/i4b/isdnd/rc_parse.y @@ -30,9 +30,9 @@ * i4b daemon - runtime configuration parser * ----------------------------------------- * - * $Id: rc_parse.y,v 1.18 1999/02/23 16:25:49 hm Exp $ + * $Id: rc_parse.y,v 1.19 1999/04/29 08:27:10 hm Exp $ * - * last edit-date: [Tue Feb 23 16:42:02 1999] + * last edit-date: [Thu Apr 29 08:46:01 1999] * *---------------------------------------------------------------------------*/ @@ -124,6 +124,7 @@ int entrycount = -1; %token REGPROG %token RTPRIO %token SYSTEM +%token TINAINITPROG %token UNITLENGTH %token UNITLENGTHSRC %token USEACCTFILE @@ -287,6 +288,7 @@ boolean: NO { $$ = FALSE; } sysfilekeyword: RATESFILE { $$ = RATESFILE; } | ACCTFILE { $$ = ACCTFILE; } | ALIASFNAME { $$ = ALIASFNAME; } + | TINAINITPROG { $$ = TINAINITPROG; } ; sysboolkeyword: USEACCTFILE { $$ = USEACCTFILE; } diff --git a/usr.sbin/i4b/isdnd/rc_scan.l b/usr.sbin/i4b/isdnd/rc_scan.l index 2a286c9..66512d8 100644 --- a/usr.sbin/i4b/isdnd/rc_scan.l +++ b/usr.sbin/i4b/isdnd/rc_scan.l @@ -30,9 +30,9 @@ * i4b daemon - runtime configuration lexical analyzer * --------------------------------------------------- * - * $Id: rc_scan.l,v 1.22 1999/02/23 16:25:49 hm Exp $ + * $Id: rc_scan.l,v 1.23 1999/04/29 08:27:10 hm Exp $ * - * last edit-date: [Tue Feb 23 16:41:02 1999] + * last edit-date: [Thu Apr 29 08:46:36 1999] * *---------------------------------------------------------------------------*/ @@ -140,6 +140,7 @@ remote-phone-dialout { return REMOTE_PHONE_DIALOUT; } remote-phone-incoming { return REMOTE_PHONE_INCOMING; } rtprio { return RTPRIO; } system { return SYSTEM; } +tinainitprog { return TINAINITPROG; } unitlength { return UNITLENGTH; } unitlengthsrc { return UNITLENGTHSRC; } useacctfile { return USEACCTFILE; } diff --git a/usr.sbin/i4b/isdnd/support.c b/usr.sbin/i4b/isdnd/support.c index ac3ca1b..8c11259 100644 --- a/usr.sbin/i4b/isdnd/support.c +++ b/usr.sbin/i4b/isdnd/support.c @@ -27,16 +27,13 @@ * i4b daemon - misc support routines * ---------------------------------- * - * $Id: support.c,v 1.48 1999/02/17 14:31:42 hm Exp $ + * $Id: support.c,v 1.56 1999/04/28 15:37:02 hm Exp $ * - * last edit-date: [Mon Feb 15 16:40:05 1999] + * last edit-date: [Wed Apr 28 17:13:36 1999] * *---------------------------------------------------------------------------*/ #include "isdnd.h" - -#define SRC (aliasing == 0 ? mp->src_telno : src_tela) -#define DST (aliasing == 0 ? mp->dst_telno : dst_tela) /*---------------------------------------------------------------------------* * find an active entry by driver type and driver unit @@ -132,6 +129,76 @@ find_by_device_for_dialout(int drivertype, int driverunit) /*---------------------------------------------------------------------------* * find entry by drivertype and driverunit and setup for dialing out *---------------------------------------------------------------------------*/ +cfg_entry_t * +find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, char *cmd) +{ + cfg_entry_t *cep = NULL; + int i, j; + + for(i=0; i < nentries; i++) + { + cep = &cfg_entry_tab[i]; /* ptr to config entry */ + + /* compare driver type and unit */ + + if(!((cep->usrdevicename == drivertype) && + (cep->usrdeviceunit == driverunit))) + { + continue; + } + + /* found, check if already reserved */ + + if(cep->cdid == CDID_RESERVED) + { + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialoutnumber: entry %d, cdid reserved!", i))); + return(NULL); + } + + /* check if this entry is already in use ? */ + + if(cep->cdid != CDID_UNUSED) + { + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialoutnumber: entry %d, cdid in use", i))); + return(NULL); + } + + /* check number and copy to cep->remote_numbers[] */ + + for(j = 0; j < cmdlen; j++) + { + if(!(isdigit(*(cmd+j)))) + { + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialoutnumber: entry %d, dial string contains non-digit at pos %d", i, j))); + return(NULL); + } + /* fill in number to dial */ + cep->remote_numbers[0].number[j] = *(cmd+j); + } + cep->remote_numbers[0].number[j] = '\0'; + cep->remote_numbers_count = 1; + + if((setup_dialout(cep)) == GOOD) + { + /* found an entry to be used for calling out */ + + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialoutnumber: found entry %d!", i))); + return(cep); + } + else + { + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialoutnumber: entry %d, setup_dialout() failed!", i))); + return(NULL); + } + } + + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialoutnumber: no entry found!"))); + return(NULL); +} + +/*---------------------------------------------------------------------------* + * find entry by drivertype and driverunit and setup for dialing out + *---------------------------------------------------------------------------*/ int setup_dialout(cfg_entry_t *cep) { @@ -221,9 +288,30 @@ find_matching_entry_incoming(msg_connect_ind_t *mp) { cfg_entry_t *cep = NULL; int i; - char *src_tela = "ERROR-src_tela"; - char *dst_tela = "ERROR-dst_tela"; + /* check for CW (call waiting) early */ + + if(mp->channel == CHAN_NO) + { + if(aliasing) + { + char *src_tela = "ERROR-src_tela"; + char *dst_tela = "ERROR-dst_tela"; + + src_tela = get_alias(mp->src_telno); + dst_tela = get_alias(mp->dst_telno); + + log(LL_CHD, "%05d <unknown> CW from %s to %s (no channel free)", + mp->header.cdid, src_tela, dst_tela); + } + else + { + log(LL_CHD, "%05d <unknown> call waiting from %s to %s (no channel free)", + mp->header.cdid, mp->src_telno, mp->dst_telno); + } + return(NULL); + } + for(i=0; i < nentries; i++) { int n; @@ -427,21 +515,20 @@ find_matching_entry_incoming(msg_connect_ind_t *mp) if(aliasing) { + char *src_tela = "ERROR-src_tela"; + char *dst_tela = "ERROR-dst_tela"; + src_tela = get_alias(mp->src_telno); dst_tela = get_alias(mp->dst_telno); - } - log(LL_CHD, /* A number not listed in /etc/isdn/isdnd.rc */ - ( (!aliasing) ? - "%05d <unknown> incoming call from %s to %s" : - /* Probably a phone call, likely from someone - in phone book /etc/isdn/isdntel.alias, so - avoid looking silly by saying "unknown", - & allow more space to print names. - */ - "%05d Call from %s to %s" - ) , - mp->header.cdid, SRC, DST, mp->dst_telno); + log(LL_CHD, "%05d Call from %s to %s", + mp->header.cdid, src_tela, dst_tela); + } + else + { + log(LL_CHD, "%05d <unknown> incoming call from %s to %s", + mp->header.cdid, mp->src_telno, mp->dst_telno); + } return(NULL); } @@ -504,7 +591,7 @@ name_of_controller(int ctrl_type, int card_type) "Dr. Neuhaus NICCY Go@", "Sedlbauer win speed", "Dynalink IS64PH", - "ISDN Master or Blaster", + "ISDN Master, MasterII or Blaster", "AVM PCMCIA Fritz!Card", "ELSA QuickStep 1000pro/ISA", "ELSA QuickStep 1000pro/PCI", @@ -512,8 +599,10 @@ name_of_controller(int ctrl_type, int card_type) "ELSA MicroLink ISDN/MC", "ELSA MicroLink MCall", "ITK ix1 micro", - "AVM Fritz!Card PCI" + "AVM Fritz!Card PCI", + "ELSA PCC-16" }; + static char *daic_card[] = { "EICON.Diehl S", "EICON.Diehl SX/SXn", @@ -521,15 +610,22 @@ name_of_controller(int ctrl_type, int card_type) "EICON.Diehl QUADRO", }; - if (ctrl_type == CTRL_PASSIVE) { + if(ctrl_type == CTRL_PASSIVE) + { int index = card_type - CARD_TYPEP_8; if (index >= 0 && index < (sizeof passive_card / sizeof passive_card[0])) return passive_card[index]; - } else if (ctrl_type == CTRL_DAIC) { + } + else if(ctrl_type == CTRL_DAIC) + { int index = card_type - CARD_TYPEA_DAIC_S; if (index >= 0 && index < (sizeof daic_card / sizeof daic_card[0] )) return daic_card[index]; } + else if(ctrl_type == CTRL_TINADD) + { + return "Stollmann tina-dd"; + } return "unknown card type"; } @@ -651,38 +747,36 @@ handle_charge(cfg_entry_t *cep) } /*---------------------------------------------------------------------------* - * + * update kernel idle_time, earlyhup_time and unitlen_time *---------------------------------------------------------------------------*/ void unitlen_chkupd(cfg_entry_t *cep) { msg_timeout_upd_t tupd; -/* XXX check if the values are possible, if not, adjust them */ - tupd.cdid = cep->cdid; /* init the short hold data based on the shorthold algorithm type */ - switch( cep->shorthold_algorithm ) + switch(cep->shorthold_algorithm) { + case SHA_FIXU: + tupd.shorthold_data.shorthold_algorithm = SHA_FIXU; + tupd.shorthold_data.unitlen_time = cep->unitlength; + tupd.shorthold_data.idle_time = cep->idle_time_out; + tupd.shorthold_data.earlyhup_time = cep->earlyhangup; + break; - case msg_alg__fix_unit_size: - tupd.shorthold_data.shorthold_algorithm = msg_alg__fix_unit_size; - tupd.shorthold_data.unitlen_time = cep->unitlength; - tupd.shorthold_data.idle_time = cep->idle_time_out; - tupd.shorthold_data.earlyhup_time = cep->earlyhangup; - break; - - case msg_alg__var_unit_size: - tupd.shorthold_data.shorthold_algorithm = msg_alg__var_unit_size; - tupd.shorthold_data.unitlen_time = cep->unitlength; - tupd.shorthold_data.idle_time = cep->idle_time_out; - tupd.shorthold_data.earlyhup_time = 0; - break; - default: - log(LL_ERR, "unitlen_chkupd bad shorthold_algorithm %d", cep->shorthold_algorithm ); - + case SHA_VARU: + tupd.shorthold_data.shorthold_algorithm = SHA_VARU; + tupd.shorthold_data.unitlen_time = cep->unitlength; + tupd.shorthold_data.idle_time = cep->idle_time_out; + tupd.shorthold_data.earlyhup_time = 0; + break; + default: + log(LL_ERR, "unitlen_chkupd bad shorthold_algorithm %d", cep->shorthold_algorithm ); + return; + break; } if((ioctl(isdnfd, I4B_TIMEOUT_UPD, &tupd)) < 0) @@ -840,6 +934,7 @@ dialresponse(cfg_entry_t *cep, int dstat) mdr.driver = cep->usrdevicename; mdr.driver_unit = cep->usrdeviceunit; mdr.stat = dstat; + mdr.cause = cep->disc_cause; if((ioctl(isdnfd, I4B_DIALOUT_RESP, &mdr)) < 0) { diff --git a/usr.sbin/i4b/isdndebug/isdndebug.8 b/usr.sbin/i4b/isdndebug/isdndebug.8 index 23f4b56..ccbcc90 100644 --- a/usr.sbin/i4b/isdndebug/isdndebug.8 +++ b/usr.sbin/i4b/isdndebug/isdndebug.8 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: isdndebug.8,v 1.6 1999/02/15 16:48:04 hm Exp $ +.\" $Id: isdndebug.8,v 1.7 1999/05/03 08:48:25 hm Exp $ .\" .\" last edit-date: [Mon Feb 15 17:05:41 1999] .\" @@ -83,6 +83,7 @@ Set the unit numbers for the -h and -H flags. Set debugging mask for the selected layer(s) to no output at all (zero). .It Fl H Reset the HSCX error counters to zero. +.El .Pp .Sh FILES /dev/i4bctl diff --git a/usr.sbin/i4b/isdndebug/main.c b/usr.sbin/i4b/isdndebug/main.c index 91c1e66..7eba58c 100644 --- a/usr.sbin/i4b/isdndebug/main.c +++ b/usr.sbin/i4b/isdndebug/main.c @@ -27,9 +27,9 @@ * main.c - i4b set debug options * ------------------------------ * - * $Id: main.c,v 1.14 1999/02/14 09:44:57 hm Exp $ + * $Id: main.c,v 1.17 1999/04/28 14:48:06 hm Exp $ * - * last edit-date: [Sun Feb 14 10:13:25 1999] + * last edit-date: [Wed Apr 28 16:47:28 1999] * *---------------------------------------------------------------------------*/ @@ -517,14 +517,19 @@ void printl4(unsigned long val) { printf("\nLayer 4: %s = 0x%lX\n", bin_str(val, 32), val); - printf(" || ||||\n"), - printf(" || |||+- general error messages\n"); - printf(" || ||+-- general messages\n"); - printf(" || |+--- B-ch timeout messages\n"); - printf(" || +---- network driver dial state\n"); - printf(" |+------ ipr driver debug messages\n"); - printf(" +------- rbch driver debug messages\n"); - printf(" ++++-++++-++++-++++-++++-++++-++-------- unassigned\n"); + printf(" ||| |||| ||||\n"), + printf(" ||| |||| |||+- general error messages\n"); + printf(" ||| |||| ||+-- general messages\n"); + printf(" ||| |||| |+--- B-ch timeout messages\n"); + printf(" ||| |||| +---- network driver dial state\n"); + printf(" ||| |||+------ ipr driver debug messages\n"); + printf(" ||| ||+------- rbch driver debug messages\n"); + printf(" ||| |+-------- isp driver debug messages\n"); + printf(" ||| +--------- tel driver debug messages\n"); + printf(" ||+----------- tina driver debug messages\n"); + printf(" |+------------ tina driver messages\n"); + printf(" +------------- tina driver error messages\n"); + printf(" ++++-++++-++++-++++-++++-+-------------- unassigned\n"); } /*---------------------------------------------------------------------------* @@ -534,7 +539,7 @@ static void usage(void) { fprintf(stderr, "\n"); - fprintf(stderr, "isdndebug - i4b set debug level, version %02d.%02d, compiled %s %s\n", VERSION, REL, __DATE__, __TIME__); + fprintf(stderr, "isdndebug - i4b set debug level, version %d.%d.%d, compiled %s %s\n", VERSION, REL, STEP, __DATE__, __TIME__); fprintf(stderr, "usage: isdndebug -e -h -g -l <layer> -m -r -s <value> -u <unit> -z -H\n"); fprintf(stderr, " -e set error only debugging output\n"); fprintf(stderr, " -g get current debugging values\n"); diff --git a/usr.sbin/i4b/isdndecode/isdndecode.8 b/usr.sbin/i4b/isdndecode/isdndecode.8 index 0de016d..a1d6846 100644 --- a/usr.sbin/i4b/isdndecode/isdndecode.8 +++ b/usr.sbin/i4b/isdndecode/isdndecode.8 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: isdndecode.8,v 1.4 1999/02/14 09:44:57 hm Exp $ +.\" $Id: isdndecode.8,v 1.5 1999/05/03 08:48:25 hm Exp $ .\" .\" last edit-date: [Sun Feb 14 10:16:25 1999] .\" @@ -128,6 +128,7 @@ as the receiving interface unit number in analyze mode. Use .Ar unit as the transmitting interface unit number in analyze mode. +.El .Pp When the USR1 signal is sent to a diff --git a/usr.sbin/i4b/isdndecode/main.c b/usr.sbin/i4b/isdndecode/main.c index fd3774a..15e24f4 100644 --- a/usr.sbin/i4b/isdndecode/main.c +++ b/usr.sbin/i4b/isdndecode/main.c @@ -27,9 +27,9 @@ * main.c - isdndecode main program file * ------------------------------------- * - * $Id: main.c,v 1.7 1999/02/14 09:44:57 hm Exp $ + * $Id: main.c,v 1.8 1999/04/26 12:10:39 hm Exp $ * - * last edit-date: [Sun Feb 14 10:17:04 1999] + * last edit-date: [Mon Apr 26 14:02:44 1999] * *---------------------------------------------------------------------------*/ @@ -750,7 +750,7 @@ void usage(void) { fprintf(stderr,"\n"); - fprintf(stderr,"isdndecode - isdn4bsd package ISDN decoder for passive cards (%02d.%02d)\n", VERSION, REL); + fprintf(stderr,"isdndecode - isdn4bsd package ISDN decoder for passive cards (%d.%d.%d)\n", VERSION, REL, STEP); fprintf(stderr,"usage: isdntrace -a -b -d -f <file> -h -i -l -n <val> -o -p <file> -r -u <unit>\n"); fprintf(stderr," -B -P -R <unit> -T <unit>\n"); fprintf(stderr," -a analyzer mode ................................... (default off)\n"); diff --git a/usr.sbin/i4b/isdnmonitor/main.c b/usr.sbin/i4b/isdnmonitor/main.c index 0ecdb69..3bd31b1 100644 --- a/usr.sbin/i4b/isdnmonitor/main.c +++ b/usr.sbin/i4b/isdnmonitor/main.c @@ -33,9 +33,9 @@ * i4b daemon - network monitor client * ----------------------------------- * - * $Id: main.c,v 1.2 1999/03/07 16:12:43 hm Exp $ + * $Id: main.c,v 1.12 1999/05/11 08:15:59 hm Exp $ * - * last edit-date: [Tue Oct 27 11:53:12 1998] + * last edit-date: [Tue Apr 20 14:14:26 1999] * * -mh created * -hm checking in @@ -303,7 +303,7 @@ static void mloop() if (FD_ISSET(monsock, &rd)) { - BYTE buf[1024]; + BYTE buf[4096]; u_long u; int bytes, ret; diff --git a/usr.sbin/i4b/isdntel/alias.c b/usr.sbin/i4b/isdntel/alias.c index 95ca985..e97e4b0 100644 --- a/usr.sbin/i4b/isdntel/alias.c +++ b/usr.sbin/i4b/isdntel/alias.c @@ -27,9 +27,9 @@ * isdntel - isdn4bsd telephone answering machine support * ====================================================== * - * $Id: alias.c,v 1.6 1999/02/14 09:44:57 hm Exp $ + * $Id: alias.c,v 1.7 1999/04/26 12:10:39 hm Exp $ * - * last edit-date: [Sun Feb 14 10:19:13 1999] + * last edit-date: [Mon Apr 26 13:53:13 1999] * *----------------------------------------------------------------------------*/ @@ -55,7 +55,7 @@ init_alias(char *filename) struct alias *lasta = NULL; if((fp = fopen(filename, "r")) == NULL) - fatal("cannot open aliasfile %s!", filename); + return; while((fgets(buffer, MAXBUFSZ, fp)) != NULL) { diff --git a/usr.sbin/i4b/isdntel/defs.h b/usr.sbin/i4b/isdntel/defs.h index 35d1b1e..34d4741 100644 --- a/usr.sbin/i4b/isdntel/defs.h +++ b/usr.sbin/i4b/isdntel/defs.h @@ -27,9 +27,9 @@ * isdntel - isdn4bsd telephone answering support * ============================================== * - * $Id: defs.h,v 1.7 1999/02/14 09:44:57 hm Exp $ + * $Id: defs.h,v 1.9 1999/04/26 12:10:39 hm Exp $ * - * last edit-date: [Sun Feb 14 10:19:26 1999] + * last edit-date: [Mon Apr 26 13:55:35 1999] * *----------------------------------------------------------------------------*/ @@ -51,15 +51,14 @@ #endif #include <sys/param.h> -#define VERSION "1" /* version number */ -#define REL "11" /* release number */ +#include <machine/i4b_ioctl.h> #define GOOD 0 #define ERROR (-1) #define WARNING (-2) #define SPOOLDIR "/var/isdn" -#define PLAYCMD "cat %s | alaw2ulaw >/dev/audio" +#define PLAYCMD "cat %s | g711conv -a >/dev/audio" /* reread timeout in seconds */ diff --git a/usr.sbin/i4b/isdntel/display.c b/usr.sbin/i4b/isdntel/display.c index 8b837dd..cddcba2 100644 --- a/usr.sbin/i4b/isdntel/display.c +++ b/usr.sbin/i4b/isdntel/display.c @@ -27,9 +27,9 @@ * isdntel - isdn4bsd telephone answering machine support * ====================================================== * - * $Id: display.c,v 1.5 1999/02/14 09:44:57 hm Exp $ + * $Id: display.c,v 1.6 1999/04/26 12:10:39 hm Exp $ * - * last edit-date: [Sun Feb 14 10:19:32 1999] + * last edit-date: [Mon Apr 26 13:57:08 1999] * *----------------------------------------------------------------------------*/ @@ -60,7 +60,7 @@ init_screen(void) keypad(main_w, TRUE); /* use special keys */ scrollok(main_w, TRUE); - sprintf(buffer, " isdntel %s.%s ", VERSION, REL); + sprintf(buffer, " isdntel %d.%d.%d ", VERSION, REL, STEP); move(0, 0); standout(); diff --git a/usr.sbin/i4b/isdntel/main.c b/usr.sbin/i4b/isdntel/main.c index 5f80440..d8bb502 100644 --- a/usr.sbin/i4b/isdntel/main.c +++ b/usr.sbin/i4b/isdntel/main.c @@ -27,9 +27,9 @@ * isdntel - isdn4bsd telephone answering machine support * ====================================================== * - * $Id: main.c,v 1.7 1999/02/14 09:44:57 hm Exp $ + * $Id: main.c,v 1.8 1999/04/26 12:10:39 hm Exp $ * - * last edit-date: [Sun Feb 14 10:19:50 1999] + * last edit-date: [Mon Apr 26 13:56:35 1999] * *----------------------------------------------------------------------------*/ @@ -278,7 +278,7 @@ static void usage(void) { fprintf(stderr, "\n"); - fprintf(stderr, "isdntel - isdn telephone answering management support utility (version %s.%s)\n", VERSION, REL); + fprintf(stderr, "isdntel - isdn telephone answering management support utility (version %d.%d.%d)\n", VERSION, REL, STEP); fprintf(stderr, " usage: isdntel -a <filename> -d <directory> -p <command> -t <timeout>\n"); fprintf(stderr, " -a <filename> use filename as alias file\n"); fprintf(stderr, " -d <directory> use directory as spool directory\n"); diff --git a/usr.sbin/i4b/isdntelctl/isdntelctl.8 b/usr.sbin/i4b/isdntelctl/isdntelctl.8 index 945bfc2..6f006fe 100644 --- a/usr.sbin/i4b/isdntelctl/isdntelctl.8 +++ b/usr.sbin/i4b/isdntelctl/isdntelctl.8 @@ -22,11 +22,11 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: isdntelctl.8,v 1.6 1999/02/16 10:40:18 hm Exp $ +.\" $Id: isdntelctl.8,v 1.7 1999/04/21 10:06:32 hm Exp $ .\" -.\" last edit-date: [Sun Feb 14 10:20:38 1999] +.\" last edit-date: [Wed Apr 21 11:27:34 1999] .\" -.Dd December 14, 1998 +.Dd April 21, 1999 .Dt isdntelctl 8 .Sh NAME .Nm isdntelctl @@ -38,7 +38,7 @@ .Op Fl u Ar unit .Op Fl A .Op Fl U -.Op Fl R +.Op Fl N .Sh DESCRIPTION .Nm isdntelctl is part of the isdn4bsd package and is used to configure the sound format @@ -54,24 +54,27 @@ Get the sound format currently in use. Set the /dev/i4btel unit number. The default value is zero to access device /dev/i4btel0. .It Fl A -Set sound format to A-Law. +Do A-law (ISDN line) -> u-law (userland) conversion. .It Fl U -Set sound format to u-Law. -.It Fl R -Set sound format to canonical (regular) A-Law format. +Do u-law (ISDN line) -> A-law (userland) conversion. +.It Fl N +Set sound conversion to do no format conversion. .El .Pp -By default, isdn4bsd sends and receives audio in A-Law as provided by the -hardware. However, these samples cannot easily be processed further as the -sample word is bit-reversed. Both the u-Law and canonical A-Law formats -store samples in a way suitable for post-processing by e.\ g. sox(1). +The telephony data stream comes out of the line in a bit-reversed format, +so the +.Xr i4btel 4 +driver does the bit-reversion process in any case. +.Pp +Additionally, the user can specify to do A-law to u-law, u-law to A-law +or no conversion at all in the i4btel driver by using the +.Nm +utility. .Pp .Sh FILES /dev/i4btel<n> - .Sh STANDARDS A-Law and u-Law are specified in ITU Recommendation G.711. - .Sh EXAMPLES The command: .Bd -literal -offset indent @@ -79,7 +82,11 @@ isdntelctl -g .Ed .Pp displays the currently used sound format for device /dev/i4btel0. - +.Sh SEE ALSO +.Xr i4btel 4 +.Xr g711conv 1 +.Xr isdnd 8 +.Xr isdnd.rc 5 .Sh AUTHOR The .Nm diff --git a/usr.sbin/i4b/isdntelctl/main.c b/usr.sbin/i4b/isdntelctl/main.c index aec72f6..52875f6 100644 --- a/usr.sbin/i4b/isdntelctl/main.c +++ b/usr.sbin/i4b/isdntelctl/main.c @@ -27,9 +27,9 @@ * isdntelctl - i4b set telephone interface options * ------------------------------------------------ * - * $Id: main.c,v 1.7 1999/02/16 10:40:18 hm Exp $ + * $Id: main.c,v 1.9 1999/04/26 12:10:39 hm Exp $ * - * last edit-date: [Tue Feb 16 11:32:09 1999] + * last edit-date: [Mon Apr 26 14:07:06 1999] * *---------------------------------------------------------------------------*/ @@ -47,6 +47,7 @@ #include <sys/types.h> #include <sys/time.h> +#include <machine/i4b_ioctl.h> #include <machine/i4b_tel_ioctl.h> static void usage ( void ); @@ -58,7 +59,7 @@ int opt_unit = 0; int opt_U = 0; int opt_A = 0; int opt_C = 0; -int opt_R = 0; +int opt_N = 0; /*---------------------------------------------------------------------------* * program entry @@ -71,7 +72,7 @@ main(int argc, char **argv) int telfd; char namebuffer[128]; - while ((c = getopt(argc, argv, "cgu:AUR?")) != EOF) + while ((c = getopt(argc, argv, "cgu:AUN?")) != EOF) { switch(c) { @@ -97,8 +98,8 @@ main(int argc, char **argv) opt_U = 1; break; - case 'R': - opt_R = 1; + case 'N': + opt_N = 1; break; case '?': @@ -108,12 +109,12 @@ main(int argc, char **argv) } } - if(opt_get == 0 && opt_R == 0 && opt_U == 0 && opt_A == 0 && opt_C == 0) + if(opt_get == 0 && opt_N == 0 && opt_U == 0 && opt_A == 0 && opt_C == 0) { opt_get = 1; } - if((opt_get + opt_R + opt_U + opt_A + opt_C) > 1) + if((opt_get + opt_N + opt_U + opt_A + opt_C) > 1) { usage(); } @@ -138,15 +139,15 @@ main(int argc, char **argv) if(format == CVT_NONE) { - printf("device %s uses A-Law sound format\n", namebuffer); + printf("device %s does not do A-law/u-law format conversion\n", namebuffer); } else if(format == CVT_ALAW2ULAW) { - printf("device %s uses u-Law sound format\n", namebuffer); + printf("device %s does ISDN: A-law -> user: u-law format conversion\n", namebuffer); } - else if(format == CVT_ALAW_CANON) + else if(format == CVT_ULAW2ALAW) { - printf("device %s uses canonical A-Law sound format\n", namebuffer); + printf("device %s does ISDN: u-law -> user: A-law format conversion\n", namebuffer); } else { @@ -157,7 +158,7 @@ main(int argc, char **argv) if(opt_A) { - int format = CVT_NONE; + int format = CVT_ALAW2ULAW; if((ret = ioctl(telfd, I4B_TEL_SETAUDIOFMT, &format)) < 0) { @@ -169,7 +170,7 @@ main(int argc, char **argv) if(opt_U) { - int format = CVT_ALAW2ULAW; + int format = CVT_ULAW2ALAW; if((ret = ioctl(telfd, I4B_TEL_SETAUDIOFMT, &format)) < 0) { @@ -178,9 +179,9 @@ main(int argc, char **argv) } exit(0); } - if(opt_R) + if(opt_N) { - int format = CVT_ALAW_CANON; + int format = CVT_NONE; if((ret = ioctl(telfd, I4B_TEL_SETAUDIOFMT, &format)) < 0) { @@ -209,14 +210,14 @@ static void usage(void) { fprintf(stderr, "\n"); - fprintf(stderr, "isdntelctl - i4b telephone i/f control, compiled %s %s\n",__DATE__, __TIME__); - fprintf(stderr, "usage: isdntelctl -g -u <unit> -A -U -c\n"); + fprintf(stderr, "isdntelctl - /dev/i4btel control, version %d.%d.%d (%s %s)\n",VERSION, REL, STEP, __DATE__, __TIME__); + fprintf(stderr, "usage: isdntelctl -c -g -u <unit> -A -N -U\n"); + fprintf(stderr, " -c clear input queue\n"); fprintf(stderr, " -g get current settings\n"); fprintf(stderr, " -u unit specify unit number\n"); - fprintf(stderr, " -A set interface to A-Law coding\n"); - fprintf(stderr, " -U set interface to u-Law coding\n"); - fprintf(stderr, " -R set interface to canonical (regular) A-Law coding\n"); - fprintf(stderr, " -c clear input queue\n"); + fprintf(stderr, " -A set conversion ISDN: A-law -> user: u-law\n"); + fprintf(stderr, " -U set conversion ISDN: u-law -> user: A-law\n"); + fprintf(stderr, " -N set conversion to no A-law/u-law conversion\n"); fprintf(stderr, "\n"); exit(1); } diff --git a/usr.sbin/i4b/isdntest/main.c b/usr.sbin/i4b/isdntest/main.c index 1ac2d91..e4cd4ee 100644 --- a/usr.sbin/i4b/isdntest/main.c +++ b/usr.sbin/i4b/isdntest/main.c @@ -27,9 +27,9 @@ * main.c - i4b selftest utility * ----------------------------- * - * $Id: main.c,v 1.10 1999/02/14 09:44:58 hm Exp $ + * $Id: main.c,v 1.11 1999/04/26 12:10:39 hm Exp $ * - * last edit-date: [Sun Feb 14 10:21:23 1999] + * last edit-date: [Mon Apr 26 14:08:40 1999] * *---------------------------------------------------------------------------*/ @@ -307,7 +307,7 @@ static void usage(void) { fprintf(stderr, "\n"); - fprintf(stderr, "isdntest - i4b selftest, compiled %s %s\n",__DATE__, __TIME__); + fprintf(stderr, "isdntest - i4b selftest, version %d.%d.%d, compiled %s %s\n",VERSION, REL, STEP, __DATE__, __TIME__); fprintf(stderr, "usage: isdntest -c <ctrl> -h -i <telno> -o <telno>\n"); fprintf(stderr, " -c <ctrl> specify controller to use\n"); fprintf(stderr, " -h use HDLC as Bchannel protocol\n"); diff --git a/usr.sbin/i4b/man/i4btel.4 b/usr.sbin/i4b/man/i4btel.4 index 54518aa..598f003 100644 --- a/usr.sbin/i4b/man/i4btel.4 +++ b/usr.sbin/i4b/man/i4btel.4 @@ -22,11 +22,11 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: i4btel.4,v 1.6 1999/02/14 09:45:02 hm Exp $ +.\" $Id: i4btel.4,v 1.7 1999/04/21 10:06:32 hm Exp $ .\" -.\" last edit-date: [Sun Feb 14 10:37:09 1999] +.\" last edit-date: [Wed Apr 21 12:03:34 1999] .\" -.Dd February 3, 1998 +.Dd April 21, 1999 .Dt i4btel 4 .Sh NAME .Nm i4btel @@ -42,7 +42,88 @@ driver provides an interface to the B-channel for telephony applications and is currently used by the .Xr isdnd 8 for answering machine support. The driver is part of the isdn4bsd package. +.Pp +The lower six bits of the drivers's minor number is used to specify a +unit number, wheras the upper two bits specify a functionality. +.Pp +Functionality zero is the usual telephony data stream i/o driver. +.Pp +Functionality one is used to enable commands to dial out and hang up and +receive responses about the state of the dial out progress and status. +This commands may change in the future, for details see the file +.Em i4b_tel_ioctl.h +and the +.Xr isdnphone 1 +utility. +.Pp +The telephony data stream comes out of the line in a bit-reversed format, +so the +.Nm +driver does the bit-reversion process in any case. +.Pp +Additionally, the user can specify to do A-law to u-law, u-law to A-law +or no conversion at all in the i4btel driver by using the +.Xr isdntelctl 8 +utility. +.Pp +The driver is able to process several ioctl's: +.Pp +.Bl -tag -width Ds -compact -offset indent +.It Ar I4B_TEL_GETAUDIOFMT +get currently used audio format conversion. +.It Ar I4B_TEL_SETAUDIOFMT +set currently used audio format conversion. +.It Ar I4B_TEL_EMPTYINPUTQUEUE +clear the input queue. +.El +.Pp +For the I4B_TEL_GETAUDIOFMT and I4B_TEL_SETAUDIOFMT, the following +parameters are available: +.Pp +.Bl -tag -width Ds -compact -offset indent +.It Ar CVT_NONE +do no A-law/u-law audio format conversion. The conversion path looks like +this: +.Pp +USER <--> bitreversing <--> ISDN-line +.Pp +.It Ar CVT_ALAW2ULAW +set set audio format conversion to do an audio conversion from A-law +(on the ISDN line) to u-law (in the userland). +The +.Xr read 2 +conversion path looks like this: +.Pp +USER <-- u-law/A-law <-- bitreversing <-- ISDN-line +.Pp +and the +.Xr write 2 +conversion path looks like this: +.Pp +USER --> u-law/A-law --> bitreversing --> ISDN-line +.Pp +.It Ar CVT_ULAW2ALAW +set set audio format conversion to do an audio conversion from u-law +(on the ISDN line) to A-law (in the userland). +The +.Xr read 2 +conversion path looks like this: +.Pp +USER <-- A-law/u-law <-- bitreversing <-- ISDN-line +.Pp +and the +.Xr write 2 +conversion path looks like this: +.Pp +USER --> A-law/u-law --> bitreversing --> ISDN-line +.Pp +.El +.Sh STANDARDS +A-Law and u-Law are specified in ITU Recommendation G.711. .Sh SEE ALSO +.Xr isdntelctl 8 +.Xr g711conv 1 +.Xr isdnphone 1 .Xr isdnd 8 .Xr isdnd.rc 5 .Sh AUTHOR diff --git a/usr.sbin/i4b/man/isic.4 b/usr.sbin/i4b/man/isic.4 index 6fa565e..e7f66ff 100644 --- a/usr.sbin/i4b/man/isic.4 +++ b/usr.sbin/i4b/man/isic.4 @@ -22,9 +22,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: isic.4,v 1.16 1999/02/14 09:45:02 hm Exp $ +.\" $Id: isic.4,v 1.18 1999/05/03 08:48:25 hm Exp $ .\" -.\" last edit-date: [Sun Feb 14 10:37:21 1999] +.\" last edit-date: [Tue Apr 20 14:08:35 1999] .\" .Dd December 22, 1998 .Dt isic 4 @@ -169,7 +169,7 @@ For an ELSA QuickStep 1000pro (PCI version) Cards on the PCMCIA or PCCARD bus: .Pp For an AVM Fritz!Card PCMCIA -.Cd options \&"AVM_PCMCIA\&" +.Cd options \&"AVM_A1_PCMCIA\&" .Cd "isic* at pcmcia? function ?" .Pp For an ELSA MicroLink ISDN/MC @@ -347,6 +347,7 @@ value is 18. Valid i/o port values must be in the range (<unknown>). .Pp Valid interrupt configurations are (<unknown>). +.El .Pp .Sh CAVEATS Note that all of the boards with I/O ports actually use several ranges |