diff options
author | jkh <jkh@FreeBSD.org> | 1995-02-15 00:46:26 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-02-15 00:46:26 +0000 |
commit | 0cb129cc755064f31fb42abf2c721a8605381511 (patch) | |
tree | 87521af8f33d69817699aec072374bf2d3734e3e | |
download | FreeBSD-src-0cb129cc755064f31fb42abf2c721a8605381511.zip FreeBSD-src-0cb129cc755064f31fb42abf2c721a8605381511.tar.gz |
Import the ISDN userland utilities. Just about ready to start shaking
this baby out in earnest..
55 files changed, 3446 insertions, 0 deletions
diff --git a/gnu/usr.sbin/isdn/COPYRIGHT b/gnu/usr.sbin/isdn/COPYRIGHT new file mode 100644 index 0000000..8bbadfb --- /dev/null +++ b/gnu/usr.sbin/isdn/COPYRIGHT @@ -0,0 +1,21 @@ +The II-sources are written by Dietmar Friede and Juergen Krause. +For all these sources: + + Copyright, (c) 1995 Dietmar Friede and Juergen Krause + + These programs are free software; you can redistribute them and/or modify + them under the terms of the GNU General Public License as published by + the Free Software Foundation, version 1. + + These programs are distributed in the hope that they might be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + in the file docs/copying.doc + along with these programs; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Acknowledgement: +alaw/ulaw from isdndrv-0.1.1 (Henrik (marsu@palumbia.IN-Berlin.de)) diff --git a/gnu/usr.sbin/isdn/Makefile b/gnu/usr.sbin/isdn/Makefile new file mode 100644 index 0000000..1c8e268 --- /dev/null +++ b/gnu/usr.sbin/isdn/Makefile @@ -0,0 +1,4 @@ +SUBDIR= answ dbg iid ispy itel ittd load nsplit play rst rstcode \ + spy ulaw2alaw alaw2ulaw + +.include <bsd.subdir.mk> diff --git a/gnu/usr.sbin/isdn/Makefile.inc b/gnu/usr.sbin/isdn/Makefile.inc new file mode 100644 index 0000000..75ee577 --- /dev/null +++ b/gnu/usr.sbin/isdn/Makefile.inc @@ -0,0 +1,2 @@ +BINDIR?= /usr/sbin +LIBDIR?= /usr/share/isdn diff --git a/gnu/usr.sbin/isdn/alaw2ulaw/Makefile b/gnu/usr.sbin/isdn/alaw2ulaw/Makefile new file mode 100644 index 0000000..7962912 --- /dev/null +++ b/gnu/usr.sbin/isdn/alaw2ulaw/Makefile @@ -0,0 +1,5 @@ +PROG= alaw2ulaw +CFLAGS+= -DBSD -O +NOMAN= yes + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/alaw2ulaw/README b/gnu/usr.sbin/isdn/alaw2ulaw/README new file mode 100644 index 0000000..771e87f --- /dev/null +++ b/gnu/usr.sbin/isdn/alaw2ulaw/README @@ -0,0 +1 @@ +stolen from isdndrv-0.1.1 diff --git a/gnu/usr.sbin/isdn/alaw2ulaw/alaw2ulaw.c b/gnu/usr.sbin/isdn/alaw2ulaw/alaw2ulaw.c new file mode 100644 index 0000000..a422988 --- /dev/null +++ b/gnu/usr.sbin/isdn/alaw2ulaw/alaw2ulaw.c @@ -0,0 +1,15 @@ +#include <fcntl.h> +#include "con.h" + +main(int argc, char *argv[]) +{ + int counter; + unsigned char buffer[1024]; + + + while ((counter = read(0, buffer, sizeof(buffer))) > 0) { + translate_bytes(alaw_linear, buffer, counter); /* now linear */ + translate_bytes(linear_ulaw, buffer, counter); /* now ulaw */ + counter != write(1, buffer, counter); + } +} diff --git a/gnu/usr.sbin/isdn/alaw2ulaw/con.h b/gnu/usr.sbin/isdn/alaw2ulaw/con.h new file mode 100644 index 0000000..def02c5 --- /dev/null +++ b/gnu/usr.sbin/isdn/alaw2ulaw/con.h @@ -0,0 +1,162 @@ + +static unsigned char ulaw_linear[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, + 5, 9, 13, 17, 21, 25, 29, 33, + 37, 41, 45, 49, 53, 57, 61, 65, + 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, + 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, + 115, 116, 116, 117, 117, 118, 118, 119, + 119, 120, 120, 121, 121, 122, 122, 123, + 123, 123, 124, 124, 124, 124, 125, 125, + 125, 125, 126, 126, 126, 126, 127, 127, + 127, 127, 127, 127, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 252, 248, 244, 240, 236, 232, 228, 224, + 220, 216, 212, 208, 204, 200, 196, 192, + 189, 187, 185, 183, 181, 179, 177, 175, + 173, 171, 169, 167, 165, 163, 161, 159, + 157, 156, 155, 154, 153, 152, 151, 150, + 149, 148, 147, 146, 145, 144, 143, 142, + 142, 141, 141, 140, 140, 139, 139, 138, + 138, 137, 137, 136, 136, 135, 135, 134, + 134, 134, 133, 133, 133, 133, 132, 132, + 132, 132, 131, 131, 131, 131, 130, 130, + 130, 130, 130, 130, 129, 129, 129, 129, + 129, 129, 129, 129, 128, 128, 128, 128, +}; + +static unsigned char linear_ulaw[] = { + 31, 31, 31, 32, 32, 32, 32, 33, + 33, 33, 33, 34, 34, 34, 34, 35, + 35, 35, 35, 36, 36, 36, 36, 37, + 37, 37, 37, 38, 38, 38, 38, 39, + 39, 39, 39, 40, 40, 40, 40, 41, + 41, 41, 41, 42, 42, 42, 42, 43, + 43, 43, 43, 44, 44, 44, 44, 45, + 45, 45, 45, 46, 46, 46, 46, 47, + 47, 47, 47, 48, 48, 49, 49, 50, + 50, 51, 51, 52, 52, 53, 53, 54, + 54, 55, 55, 56, 56, 57, 57, 58, + 58, 59, 59, 60, 60, 61, 61, 62, + 62, 63, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 81, 83, 85, 87, 89, + 91, 93, 95, 99, 103, 107, 111, 119, + 255, 247, 239, 235, 231, 227, 223, 221, + 219, 217, 215, 213, 211, 209, 207, 206, + 205, 204, 203, 202, 201, 200, 199, 198, + 197, 196, 195, 194, 193, 192, 191, 191, + 190, 190, 189, 189, 188, 188, 187, 187, + 186, 186, 185, 185, 184, 184, 183, 183, + 182, 182, 181, 181, 180, 180, 179, 179, + 178, 178, 177, 177, 176, 176, 175, 175, + 175, 175, 174, 174, 174, 174, 173, 173, + 173, 173, 172, 172, 172, 172, 171, 171, + 171, 171, 170, 170, 170, 170, 169, 169, + 169, 169, 168, 168, 168, 168, 167, 167, + 167, 167, 166, 166, 166, 166, 165, 165, + 165, 165, 164, 164, 164, 164, 163, 163, + 163, 163, 162, 162, 162, 162, 161, 161, + 161, 161, 160, 160, 160, 160, 159, 159, +}; + +static unsigned char alaw_linear[] = { + 45, 214, 122, 133, 0, 255, 107, 149, + 86, 171, 126, 129, 0, 255, 117, 138, + 13, 246, 120, 135, 0, 255, 99, 157, + 70, 187, 124, 131, 0, 255, 113, 142, + 61, 198, 123, 132, 0, 255, 111, 145, + 94, 163, 127, 128, 0, 255, 119, 136, + 29, 230, 121, 134, 0, 255, 103, 153, + 78, 179, 125, 130, 0, 255, 115, 140, + 37, 222, 122, 133, 0, 255, 105, 151, + 82, 175, 126, 129, 0, 255, 116, 139, + 5, 254, 120, 135, 0, 255, 97, 159, + 66, 191, 124, 131, 0, 255, 112, 143, + 53, 206, 123, 132, 0, 255, 109, 147, + 90, 167, 127, 128, 0, 255, 118, 137, + 21, 238, 121, 134, 0, 255, 101, 155, + 74, 183, 125, 130, 0, 255, 114, 141, + 49, 210, 123, 133, 0, 255, 108, 148, + 88, 169, 127, 129, 0, 255, 118, 138, + 17, 242, 121, 135, 0, 255, 100, 156, + 72, 185, 125, 131, 0, 255, 114, 142, + 64, 194, 124, 132, 0, 255, 112, 144, + 96, 161, 128, 128, 1, 255, 120, 136, + 33, 226, 122, 134, 0, 255, 104, 152, + 80, 177, 126, 130, 0, 255, 116, 140, + 41, 218, 122, 133, 0, 255, 106, 150, + 84, 173, 126, 129, 0, 255, 117, 139, + 9, 250, 120, 135, 0, 255, 98, 158, + 68, 189, 124, 131, 0, 255, 113, 143, + 57, 202, 123, 132, 0, 255, 110, 146, + 92, 165, 127, 128, 0, 255, 119, 137, + 25, 234, 121, 134, 0, 255, 102, 154, + 76, 181, 125, 130, 0, 255, 115, 141, + +}; + + +static unsigned char linear_alaw[] = { + + 252, 172, 172, 172, 172, 80, 80, 80, + 80, 208, 208, 208, 208, 16, 16, 16, + 16, 144, 144, 144, 144, 112, 112, 112, + 112, 240, 240, 240, 240, 48, 48, 48, + 48, 176, 176, 176, 176, 64, 64, 64, + 64, 192, 192, 192, 192, 0, 0, 0, + 0, 128, 128, 128, 128, 96, 96, 96, + 96, 224, 224, 224, 224, 32, 32, 32, + 160, 160, 88, 88, 216, 216, 24, 24, + 152, 152, 120, 120, 248, 248, 56, 56, + 184, 184, 72, 72, 200, 200, 8, 8, + 136, 136, 104, 104, 232, 232, 40, 40, + 168, 86, 214, 22, 150, 118, 246, 54, + 182, 70, 198, 6, 134, 102, 230, 38, + 166, 222, 158, 254, 190, 206, 142, 238, + 210, 242, 194, 226, 218, 250, 202, 234, + 235, 203, 251, 219, 227, 195, 243, 211, + 175, 239, 143, 207, 191, 255, 159, 223, + 167, 39, 231, 103, 135, 7, 199, 71, + 183, 55, 247, 119, 151, 23, 215, 87, + 87, 169, 169, 41, 41, 233, 233, 105, + 105, 137, 137, 9, 9, 201, 201, 73, + 73, 185, 185, 57, 57, 249, 249, 121, + 121, 153, 153, 25, 25, 217, 217, 89, + 89, 89, 161, 161, 161, 161, 33, 33, + 33, 33, 225, 225, 225, 225, 97, 97, + 97, 97, 129, 129, 129, 129, 1, 1, + 1, 1, 193, 193, 193, 193, 65, 65, + 65, 65, 177, 177, 177, 177, 49, 49, + 49, 49, 241, 241, 241, 241, 113, 113, + 113, 113, 145, 145, 145, 145, 17, 17, + 17, 17, 209, 209, 209, 209, 81, 253, +}; + +inline void translate_bytes(const void *table, void *buff, unsigned long n) +{ + __asm__("cld\n" + "1:\tlodsb\n\t" + "xlatb\n\t" + "stosb\n\t" + "loop 1b\n\t" + ::"b" ((long)table), "c" (n), "D" ((long)buff), "S" ((long)buff) + :"bx","cx","di","si","ax"); +} + +void translate_ansi(unsigned char table[], unsigned char buff[], unsigned long n) +{ +register counter; + +for(counter=0; counter< n; counter++) + buff[counter] = table[buff[counter]]; +} diff --git a/gnu/usr.sbin/isdn/answ/Makefile b/gnu/usr.sbin/isdn/answ/Makefile new file mode 100644 index 0000000..62b2229 --- /dev/null +++ b/gnu/usr.sbin/isdn/answ/Makefile @@ -0,0 +1,7 @@ +NOMAN= noman + +beforeinstall: + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${.CURDIR}/answ.sh ${DESTDIR}/${BINDIR}/answ + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/answ/answ.sh b/gnu/usr.sbin/isdn/answ/answ.sh new file mode 100644 index 0000000..ea33866 --- /dev/null +++ b/gnu/usr.sbin/isdn/answ/answ.sh @@ -0,0 +1,14 @@ +# play.sh +if [ -f /isdn/msg/.num ] +then + N=`cat /isdn/msg/.num` +else + N=0 +fi +N=`printf "%.4d" $N` +D=`date +%d%H` +date >> /isdn/msg/I.$N.$D +dd of=/dev/itel00 if=/isdn/msg/msg.answ bs=1k +dd of=/dev/itel00 if=/isdn/msg/beep bs=1k +dd if=/dev/itel00 of=/isdn/msg/R.$N.$D bs=1k +echo `expr $N + 1` >/isdn/msg/.num diff --git a/gnu/usr.sbin/isdn/dbg/Makefile b/gnu/usr.sbin/isdn/dbg/Makefile new file mode 100644 index 0000000..7b1e33d --- /dev/null +++ b/gnu/usr.sbin/isdn/dbg/Makefile @@ -0,0 +1,5 @@ +CFLAGS+= -DBSD -O +PROG= dbg +SRCS= dbg.c dbg_3009.c dbg_3008.c dbg_5000.c + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/dbg/dbg.1 b/gnu/usr.sbin/isdn/dbg/dbg.1 new file mode 100644 index 0000000..b40548e --- /dev/null +++ b/gnu/usr.sbin/isdn/dbg/dbg.1 @@ -0,0 +1,19 @@ +.\" Copyright (c) 1994 Dietmar Friede +.Dd September 15, 1994 +.Os BSD +.Dt "ISDN dbg" 1 +.Sh NAME +.Nm dbg +.Nd NICCY-3008, NICCY-3009, NICCY-5000 debug programm +.Sh SYNOPSIS +.Nm dbg +.Op file +.Sh DESCRIPTION +.Nm +reads the shared memory of the NICCY-3008 and the NICCY-3009 or the status +bytes of the NICCY-5000 and displays them. The output is send to stderr. +If you give a filename the bytes are dumped to this file. +.Sh BUGS +.Nm +is only working correctly for the 3008. Some of the output for the 3009 +and 5000 are interpreted wrong. diff --git a/gnu/usr.sbin/isdn/dbg/dbg.c b/gnu/usr.sbin/isdn/dbg/dbg.c new file mode 100644 index 0000000..b57b5c7 --- /dev/null +++ b/gnu/usr.sbin/isdn/dbg/dbg.c @@ -0,0 +1,63 @@ +static char rcsid[] = "@(#)$Id: dbg.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: dbg.c,v $ + * + ******************************************************************************/ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/i386/isa/niccyreg.h" + +u_char data[10000]; +int f; +FILE *Fout; + +main(int argc, char **argv) +{ + int size = 0; + + if ((f = open("/dev/nic0", O_RDWR)) < 0) + { + perror("open"); + exit(1); + } + if (ioctl(f, NICCY_DEBUG, data) < 0) + { + perror("ioctl"); + } + switch (data[0]) + { + case 0x38: + printf("Niccy 3008\n"); + analyse_3008(data + 1); + size = 1024; + break; + case 0x39: + printf("Niccy 3009\n"); + analyse_3009(data + 1); + size = 2044; + break; + case 0x50: + printf("Niccy 5000\n"); + analyse_5000(data + 1); + size = 8; + break; + default: + printf("unknown\n"); + } + + argv++; + if (*argv && (Fout = fopen(*argv, "w")) != NULL && size) + fwrite(data + 1, size, 1, Fout); +} diff --git a/gnu/usr.sbin/isdn/dbg/dbg_3008.c b/gnu/usr.sbin/isdn/dbg/dbg_3008.c new file mode 100644 index 0000000..9452572 --- /dev/null +++ b/gnu/usr.sbin/isdn/dbg/dbg_3008.c @@ -0,0 +1,150 @@ +static char rcsid[] = "@(#)$Id: dbg_3008.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: dbg_3008.c,v $ + * + ******************************************************************************/ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/i386/isa/nic3008.h" + +static int +print_stat(status) +{ + if (status & 0x8A) + { + if (status & 0x80) + fprintf(stderr, "Software-Fehler\n"); + if (status & 8) + fprintf(stderr, "Hardware-Fehler\n"); + if (status & 2) + fprintf(stderr, "Fehler beim Selbsttest\n"); + } +} + +static int +self_test(dpr_type * dpr) +{ + int abort; + +} + +static int +prtint(i) +{ + switch (i) + { + case 0:fprintf(stderr, "5"); + break; + case 1: + fprintf(stderr, "4"); + break; + case 2: + fprintf(stderr, "3"); + break; + case 3: + fprintf(stderr, "2/9"); + break; + case 4: + fprintf(stderr, "7"); + break; + default: + fprintf(stderr, "??????????\n"); + } + fprintf(stderr, "\n"); +} + +analyse_3008(dpr_type * dpr) +{ + + print_stat(dpr->card_state); + if (dpr->card_state & 1) + { + fprintf(stderr, "Selbsttest lae„uf\n"); + exit(1); + } + self_test(dpr); + fprintf(stderr, "%s : %x %x %x %x\n", dpr->niccy_ver, dpr->card_state + ,dpr->hw_config, dpr->jmp_config, dpr->ram_config); + if (dpr->card_state & 4) + fprintf(stderr, "Layer 1 not active\n"); + if (dpr->card_state & 0x10) + fprintf(stderr, "Date/Time not set\n"); + if (dpr->card_state & 0x20) + fprintf(stderr, "ENTITY not loaded\n"); + if (dpr->card_state & 0x40) + fprintf(stderr, "out of sync.\n"); + fprintf(stderr, "Hardware Configuration:\n"); + if (dpr->hw_config & 0x80) + fprintf(stderr, "No "); + fprintf(stderr, "DRAM-Module\n"); + if (dpr->ram_config & 1) + fprintf(stderr, "256 KB SRAM\n"); + switch (dpr->ram_config) + { + case 4: + case 5: + fprintf(stderr, "1 MB DRAM\n"); + break; + case 16: + case 17: + fprintf(stderr, "1 MB DRAM\n"); + } + switch ((dpr->hw_config >> 5) & 3) + { + case 3: + fprintf(stderr, "Modem Module\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + switch ((dpr->hw_config >> 3) & 3) + { + case 3: + fprintf(stderr, "Telefon Module\n"); + break; + case 2: + fprintf(stderr, "X Interface\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + switch (dpr->hw_config & 7) + { + case 7: + fprintf(stderr, "S0 Module\n"); + break; + case 6: + fprintf(stderr, "Uk0 Module\n"); + break; + case 5: + fprintf(stderr, "Up0 Module\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + + fprintf(stderr, "Jumper:\n"); + fprintf(stderr, "COM%d\n", ((dpr->jmp_config >> 6) & 3) + 1); + fprintf(stderr, "DPRAM-IRQ"); + prtint((dpr->jmp_config >> 3) & 7); + fprintf(stderr, "COM-IRQ"); + prtint(dpr->jmp_config & 7); +} diff --git a/gnu/usr.sbin/isdn/dbg/dbg_3009.c b/gnu/usr.sbin/isdn/dbg/dbg_3009.c new file mode 100644 index 0000000..eee5932 --- /dev/null +++ b/gnu/usr.sbin/isdn/dbg/dbg_3009.c @@ -0,0 +1,151 @@ +static char rcsid[] = "@(#)$Id: dbg_3009.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: dbg_3009.c,v $ + * + ******************************************************************************/ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/i386/isa/nic3009.h" + +static int +print_stat(status) +{ + if (status & 0x8A) + { + if (status & 0x80) + fprintf(stderr, "Software-Fehler\n"); + if (status & 8) + fprintf(stderr, "Hardware-Fehler\n"); + if (status & 2) + fprintf(stderr, "Fehler beim Selbsttest\n"); + } +} + +static int +prtint(i) +{ + switch (i) + { + case 0:fprintf(stderr, "5"); + break; + case 1: + fprintf(stderr, "4"); + break; + case 2: + fprintf(stderr, "3"); + break; + case 3: + fprintf(stderr, "2/9"); + break; + case 4: + fprintf(stderr, "7"); + break; + default: + fprintf(stderr, "??????????\n"); + } + fprintf(stderr, "\n"); +} + +static +mbx_analyse(mbx_type * mbx) +{ + printf("Type %x SubType %x no %x", mbx->type, mbx->subtype, mbx->number); + if (mbx->more_data) + printf(" more"); + printf(" len %d plci %x\n", mbx->data_len, mbx->plci); +} + +analyse_3009(dpr_type * dpr) +{ + fprintf(stderr, "card state %x hw conf %x ram conf %x\n", dpr->card_state + ,dpr->hw_config, dpr->ram_config); + print_stat(dpr->card_state); + if (dpr->card_state & 4) + fprintf(stderr, "Layer 1 not active\n"); + if (dpr->card_state & 0x10) + fprintf(stderr, "Date/Time not set\n"); + if (dpr->card_state & 0x20) + fprintf(stderr, "ENTITY not loaded\n"); + if (dpr->card_state & 0x40) + fprintf(stderr, "out of sync.\n"); + fprintf(stderr, "Hardware Configuration:\n"); + if (dpr->hw_config & 0x80) + fprintf(stderr, "No "); + /* + * fprintf(stderr,"DRAM-Module\n"); if(dpr->ram_config&1) + * fprintf(stderr,"256 KB SRAM\n"); switch(dpr->ram_config) { case 4: + * case 5: fprintf(stderr,"1 MB DRAM\n"); break; case 16: case 17: + * fprintf(stderr,"1 MB DRAM\n"); } + */ + switch ((dpr->hw_config >> 5) & 3) + { + case 3: + fprintf(stderr, "Modem Module\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + switch ((dpr->hw_config >> 3) & 3) + { + case 3: + fprintf(stderr, "Telefon Module\n"); + break; + case 2: + fprintf(stderr, "X Interface\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + switch (dpr->hw_config & 7) + { + case 7: + fprintf(stderr, "S0 Module\n"); + break; + case 6: + fprintf(stderr, "Uk0 Module\n"); + break; + case 5: + fprintf(stderr, "Up0 Module\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + if (dpr->up_mbx.msg_flag) + { + printf("Up Mailbox activ:\n"); + mbx_analyse(&dpr->up_mbx); + } + if (dpr->dn_mbx.msg_flag) + { + printf("Down Mailbox activ:\n"); + mbx_analyse(&dpr->dn_mbx); + } + if (dpr->up_mbx.msg_flag == 0) + { + printf("Up Mailbox not activ:\n"); + mbx_analyse(&dpr->up_mbx); + } + if (dpr->dn_mbx.msg_flag == 0) + { + printf("Down Mailbox not activ:\n"); + mbx_analyse(&dpr->dn_mbx); + } +} diff --git a/gnu/usr.sbin/isdn/dbg/dbg_5000.c b/gnu/usr.sbin/isdn/dbg/dbg_5000.c new file mode 100644 index 0000000..8711232 --- /dev/null +++ b/gnu/usr.sbin/isdn/dbg/dbg_5000.c @@ -0,0 +1,136 @@ +static char rcsid[] = "@(#)$Id: dbg_5000.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: dbg_5000.c,v $ + * + ******************************************************************************/ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/file.h> + +static int +prtint(i) +{ + switch (i) + { + case 0:fprintf(stderr, "5"); + break; + case 1: + fprintf(stderr, "4"); + break; + case 2: + fprintf(stderr, "3"); + break; + case 3: + fprintf(stderr, "2/9"); + break; + case 4: + fprintf(stderr, "7"); + break; + default: + fprintf(stderr, "??????????\n"); + } + fprintf(stderr, "\n"); +} + +static int +print_stat(status) +{ + if (status & 0x8A) + { + if (status & 0x80) + fprintf(stderr, "Software-Fehler\n"); + if (status & 8) + fprintf(stderr, "Hardware-Fehler\n"); + if (status & 2) + fprintf(stderr, "Fehler beim Selbsttest\n"); + } +} + +analyse_5000(unsigned char *data) +{ + print_stat(data[1]); + + fprintf(stderr, "%x %x %x %x\n", data[1] + ,data[5], data[6], data[7]); + if (data[1] & 4) + fprintf(stderr, "Layer 1 not active\n"); + if (data[1] & 0x10) + fprintf(stderr, "Date/Time not set\n"); + if (data[1] & 0x20) + fprintf(stderr, "ENTITY not loaded\n"); + if (data[1] & 0x40) + fprintf(stderr, "out of sync.\n"); + fprintf(stderr, "Hardware Configuration:\n"); + if (data[5] & 0x80) + fprintf(stderr, "No "); + fprintf(stderr, "DRAM-Module\n"); + if (data[7] & 1) + fprintf(stderr, "256 KB SRAM\n"); + switch (data[7]) + { + case 4: + case 5: + fprintf(stderr, "1 MB DRAM\n"); + break; + case 16: + case 17: + fprintf(stderr, "1 MB DRAM\n"); + } + switch ((data[5] >> 5) & 3) + { + case 3: + fprintf(stderr, "Modem Module\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + switch ((data[5] >> 3) & 3) + { + case 3: + fprintf(stderr, "Telefon Module\n"); + break; + case 2: + fprintf(stderr, "X Interface\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + switch (data[5] & 7) + { + case 7: + fprintf(stderr, "S0 Module\n"); + break; + case 6: + fprintf(stderr, "Uk0 Module\n"); + break; + case 5: + fprintf(stderr, "Up0 Module\n"); + break; + case 0: + break; + default: + fprintf(stderr, "??????????\n"); + } + + fprintf(stderr, "Jumper:\n"); + fprintf(stderr, "COM%d\n", ((data[6] >> 6) & 3) + 1); + fprintf(stderr, "DPRAM-IRQ"); + prtint((data[6] >> 3) & 7); + fprintf(stderr, "COM-IRQ"); + prtint(data[6] & 7); +} diff --git a/gnu/usr.sbin/isdn/docs/INSTALL b/gnu/usr.sbin/isdn/docs/INSTALL new file mode 100644 index 0000000..9271e15 --- /dev/null +++ b/gnu/usr.sbin/isdn/docs/INSTALL @@ -0,0 +1,50 @@ +Installation notes for the ii ISDN Interface + for FreeBSD Release 1.0 + 08.Oct.1994 + +1. Login as root + +2. Use vipw to create a login isdn. It has to be an alias to root. + the login directory has to be /isdn: + isdn:*:0:0:Bourne-again Superuser:/isdn: + +3. The ISDN Interface supports the NICCY 3008 , NICCY 3009 and the + NICCY 5000. Please see /sys/i386/conf/LINT for more details on + how to enable a given ISDN adapter for your system. + +4. You have to edit some files for your local installation: +6.1 /usr/sbin/sisdn +6.2 /usr/share/isdn/isdn.ip +6.3 /etc/remote +6.4 /etc/ttys + +5. Install the new kernel and reboot your system. + +6. Login as isdn and start + sisdn + + +Configuration of NICCY 3008. + +The 3008 is an 8bit card. It uses shared memory and does not support or +is not supported by a 16bit card in the same 8 ( or 16K ) area of shared memory. + +As configured it is running using the I/O adress of COM3, Interupt 5 and +the shared memory at 0xde000. +But Interupt 5 is occupied by ne1000, ne2000 and WDxxxx ethernet cards. The +WDxxxx cards use shared memory in the 0xdxxxx region. + +That is why I configured the kernel for the 3008 to use COM3, interupt 2/9 +and shared memory at 0xe0000. You have to jumper: + +B7 B4a B4b B1a B1b B1c B1d + + +Problems with the NICCY 5000. + +The 5000 was constructed for the MAC. So it has this strange MAC-SCSI connector. +When connecting to an Adaptec you have to buy a cable which connects to MAC-SCSI +and a terminator for the MAC-SCSI. Be shure to terminate the SCSI-Bus +correctly !!!!!!!!!!!!!!!!!!!!!!!!!!! Older Versions of the NICCY will not run +on Adaptec with enabled boot rom. Disable boot rom or/and get a new set of +rom for the 5000. diff --git a/gnu/usr.sbin/isdn/docs/README b/gnu/usr.sbin/isdn/docs/README new file mode 100644 index 0000000..318df7e --- /dev/null +++ b/gnu/usr.sbin/isdn/docs/README @@ -0,0 +1,85 @@ + II ISDN Interface + +The ii packet is an ISDN interface for FreeBSD 1.x and FreeBSD 2.0. +This is a first release. It is an idea. It will - hopefully - change a lot. +It supports the EDSS1 and the 1TR6 ISDN interfaces. +EDSS1 is the "Euro-ISDN", 1TR6 is the soon obsolete german ISDN Interface. + +Copyright: Its GNU Copyright see the File COPYRIGHT. + +It contains a set of driver's: + +Low level Drivers for Dr. Neuhaus NICCY 3008, 3009 and 5000 Cards. +An intermediate level isdn driver. +Some high level drivers for ip, tty, and telephone answering. + +The ip driver is rather stable. It is used to connect to the Internet. +The tty driver is completely experimental. There are a few of them, as +with every version of *BSD there is a new tty interface. +The telephone answering is quite stable. + +Some support programs: +Daemons to handle dialing and answering. +Programs to load the intelligent cards. +Debugging help. +Programs to listen to your answering machine with soundblaster. + +What can you do with it: +You may connect to the Internet through TCP/IP and a service provider +supporting PPP or SLIP through ISDN. + +You may build up your proper ISDN TCP/IP network. + +You may use the tty interface to dial in or out. + +You may have the Unix System answering your telephone. + +The packet here includes only sources. It will compile with FreeBSD 1.x, +FreeBSD 2.1. and an old version of NetBSD 0.9, + +Restrictions: +Only one interface card ( with 2 B-channels ) is supported. + +In work: +Low level driver for teles S0/NICCY 1000. A prototype is expected to be +distributed around easter 95. Will not include X75 B-Channel support +nor any Level-3 Protocols for the B-Channels. +A complete Implementation of ip (PPP, VJ). (Might come with teles stuff) +Better error handling specially for the tty driver. +A real telephone answering machine and more telephone support. +FAX support. + +Porting the system to Unix System V and SCO. +These versions will be commercial products. + +Todo: +Documentation and a lot other stuff. + +Rules: +We want the help of as many people as possible to develop the packet. +But if you develop something inside the packet or on top of the packet +you have to put the sources to the public domain or to GNU copyright. If +you distribute a binary packet on base of these sources you have to give +complete sources to your customer, the Internet community and us. + +We charge for support. We want to be payed if you need support. We earn our +living as consultants. We want to develop the packet. + +If you are a company or a service provider and want to use or distribute +the packet please contact one of us. We want and need your support. + +Binaries and Support: +This distribution includes sources only. You will get no free support. +If you want binaries and support contact: +jkr@saarlink.de +Juergen Krause, Buchenstr. 8, D-66497 Contwig/Stambach, Germany ++49 6336 993002 ++49 6336 993003 (fax) + +Acknowledgment: +Many thanks to the people at Dr. Neuhaus, Hamburg for their support. +Specially Klaus Muehle, Stefan Nerke and Daniel Piper. + +Dietmar Friede, Las Hayas, E-38870 Valle Gran Rey, Spain +dfriede@drnhh.neuhaus.de ++34 22 804181 (Tel./Fax) (9 to 16 WET at working days) diff --git a/gnu/usr.sbin/isdn/docs/copying.doc b/gnu/usr.sbin/isdn/docs/copying.doc new file mode 100644 index 0000000..3c68f02 --- /dev/null +++ b/gnu/usr.sbin/isdn/docs/copying.doc @@ -0,0 +1,248 @@ + GNU GENERAL PUBLIC LICENSE + Version 1, February 1989 + + Copyright (C) 1989 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free +programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of a such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work based +on the Program" means either the Program or any work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this General + Public License. + + d) You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying the Program (or any work based +on the Program) you indicate your acceptance of this license to do so, +and all its terms and conditions. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these +terms and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. + + 7. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of the license which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to humanity, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19xx name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/gnu/usr.sbin/isdn/docs/prot.1 b/gnu/usr.sbin/isdn/docs/prot.1 new file mode 100644 index 0000000..c003b43 --- /dev/null +++ b/gnu/usr.sbin/isdn/docs/prot.1 @@ -0,0 +1,11 @@ +Supported protocolls are: +X X75 +u ui hdlc with UI frames +r raw hdlc without anything +C BTX-X75 german CEPT X75 stuff +t tel ISDN and a/b telefon +I ISDN telefon +a a/b a/b telefon + +No tricks and thrills. I do not need T70 or other level 3 protocols. +I use IP. diff --git a/gnu/usr.sbin/isdn/iid/Changes b/gnu/usr.sbin/isdn/iid/Changes new file mode 100644 index 0000000..49b1bbb --- /dev/null +++ b/gnu/usr.sbin/isdn/iid/Changes @@ -0,0 +1,27 @@ +1c1 +< static char rcsid[] = "@(#)$Id: iid.c,v 1.1 1994/12/19 07:25:48 jkr Exp $"; +--- +> static char rcsid[] = "@(#)$Id: iid.c,v 1.2 1994/12/22 16:53:13 jkr Exp $"; +3c3 +< * ISDN System - $Revision: 1.1 $ $State: Exp $ +--- +> * ISDN System - $Revision: 1.2 $ $State: Exp $ +13a14,17 +> * Revision 1.2 1994/12/22 16:53:13 jkr +> * changes for rescan/signal +> * next_lno = next_dno = 0 +> * +17,19d20 +< * Revision 1.1 1994/12/16 19:39:44 jkr +< * Initial revision first check in +< * +96a98 +> next_lno = next_dno = 0; /* jkr*/ +186a189,191 +> #ifdef TEST +> fprintf(stderr,"DIAL-NR:%s\n",p+1); +> #endif +203a209,211 +> #ifdef TEST +> fprintf(stderr,"LIST-NR:%s\n",p+1); +> #endif diff --git a/gnu/usr.sbin/isdn/iid/Makefile b/gnu/usr.sbin/isdn/iid/Makefile new file mode 100644 index 0000000..243bf21 --- /dev/null +++ b/gnu/usr.sbin/isdn/iid/Makefile @@ -0,0 +1,4 @@ +PROG= iid +CFLAGS+= -DBSD -O + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/iid/iid.1 b/gnu/usr.sbin/isdn/iid/iid.1 new file mode 100644 index 0000000..ab2112f --- /dev/null +++ b/gnu/usr.sbin/isdn/iid/iid.1 @@ -0,0 +1,62 @@ +.\" Copyright (c) 1994 Dietmar Friede +.Dd September 15, 1994 +.Os BSD +.Dt "ISDN iid" 1 +.Sh NAME +.Nm iid +.Nd ISDN ip daemon +.Sh SYNOPSIS +.Nm iid +[ -F ] [ -c file ] [ -l file ] + +-F do not fork + +-c file use file as source of the configuration (default /etc/isdn.ip) + +-l file use file as logfile (default /var/log/isdn.ip) + +.Sh DESCRIPTION +Die Form der Konfigurationdatei /etc/isdn.ip wird, +bis ich das mit dem Euro ISDN verstanden hab: + +1. Zeile beschreibt auf welcher Nummer (Subadresse, "EAZ") der Treiber hoert: + +An: + +Bedeutet Adresse n ("EAZ" n). + +Die folgenden Zeilen beschreiben jeweils ein Interface (ii0 - iin) + +0:d102:l102:pu:m1500:s1502:w10: +1:d133:d132:l133:pr:m500:s500:w0: +2:d134:l134:l123:pX:a3:m2048:s2048:w600: +3:d334:d335:l334:l323:pC:m1000:s1000:w30: + +Wobei die erste Spalte die Nummer des Interfaces ist. + +dn dial n waehle die Nummer n + +an adress a benutz beim Waehlen 'n' als Suffix der eigenen Adresse + +ln listen n hoere auf der Nummer n + +px protocoll x siehe oben. + +wn wait n Haeng auf wenn n Sekunden nichts uebertragen wurde, n = 0 haeng nicht auf. + +mn mtu n die maximale IP Uebertagungslaenge wird n + +sm size m Pufferlaenge der ISDN-Karte sm >= mn bei UI sm >= mn+2 + +Wobei das Maximum 2048 ist. + +Das direkte IP ISDN Interface funktioniert nur wenn, die anrufende +Gegenstelle sich mit ihrer Nummer identifiziert. Mit Hilfe dieser Nummer +wird dann das Interface iin ausgewaehlt. + +Als Protokoll wird HDLC mit UI-frames (u), HDLC roh (r), X75 (X) und BTX-X75 (C) +unterstuetzt. + +Falls irgendein Hacker gerne irgend eine andere Methode moechte sei sie +auf das tty Interface verwiesen. Nach normalen login kann dort +slip benutzt werden. Es ist keine weitere Idendifikation noetig. diff --git a/gnu/usr.sbin/isdn/iid/iid.c b/gnu/usr.sbin/isdn/iid/iid.c new file mode 100644 index 0000000..11b8c36 --- /dev/null +++ b/gnu/usr.sbin/isdn/iid/iid.c @@ -0,0 +1,464 @@ +static char rcsid[] = "@(#)$Id: iid.c,v 1.4 1995/01/25 13:42:33 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.4 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: iid.c,v $ + * + ******************************************************************************/ + +/* ISDN IP Daemon */ +/* It handles dial and accept requests for ISDN-IP Connections */ + +#include <sys/types.h> +#include <stdio.h> +#include <signal.h> +#include <errno.h> +#include <setjmp.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/isdn/isdn_ioctl.h" +#define min(a,b) ((a)<(b)?(a):(b)) + +#define NII 4 +#define N_NO (4*NII) + +telno_t dial_no[N_NO]; + +struct no +{ + u_char from, n; +} no[NII]; + +struct listen_no +{ + u_short ap; + telno_t t; +} listen_no[N_NO]; + +listen_t listen; +dial_t dial[NII]; +isdn_param ip[NII]; + +int next_lno, next_dno; + +int dofork = 1; +int quit = 0, rescan = 0; +jmp_buf context; +char *logfile = "/var/log/isdn.ip"; +char *configfile = "/etc/isdn.ip"; + +int subadr, prot, timeout, bsize, spv, ui, serv; +int def_subadr = 1; +int ind, rind; +char rbuf[2048]; +unsigned short si_mask; + +void +catchsig() +{ + quit++; + longjmp(context, 1); +} + +void +catchsighup() +{ + rescan++; + (void) signal(SIGHUP, catchsighup); + longjmp(context, 1); +} + +setdefault() +{ + subadr = -1; + prot = 2; + ui = 1; + serv = 7; + timeout = 600; + bsize = 2048; + spv = 0; + next_lno = next_dno = 0;/* jkr */ +} + +char * +gettoc() +{ + if (rind == -1) + { + rind = 0; + return (rbuf); + } + while (rbuf[++rind]); + rind++; + + if (rind >= ind) + return (NULL); + + return (&rbuf[rind]); +} + +filline(FILE * f) +{ + int c; + + ind = 1; + rbuf[0] = 'H'; + + while ((c = fgetc(f)) != EOF) + { + if (isalnum(c)) + { + rbuf[ind++] = c; + } else + switch (c) + { + case '#': + fgets(rbuf + ind, 2048 - ind, f); + if (ind == 1) + break; + /* Fall through */ + case '\n': + rbuf[ind] = 0; + rind = -1; + return (0); + case ':': + rbuf[ind++] = 0; + break; + } + } + if (ind > 1) + return (0); + return (EOF); +} + +process(FILE * f, int n) +{ + char *p; + int ap = 0; + telno_t *t; + + setdefault(); + + no[ap].from = no[ap].n = 0; + while (filline(f) != EOF) + { + while ((p = gettoc()) != NULL) + switch (p[0]) + { + case 'A': + def_subadr = p[1] - '0'; + listen.subadr_mask |= 1 << def_subadr; + break; + case 'a': + subadr = p[1] - '0'; + break; + case 'd': + if (next_dno >= N_NO) + { + fprintf(stderr, "Too many numbers to dial\n"); + exit(1); + } + t = &dial_no[next_dno++]; + no[ap].n++; + t->length = strlen(p + 1) + 1; + if (t->length > 123) + { + fprintf(stderr, "ISDN number too long\n"); + exit(1); + } + t->no[0] = 0x81; + strncpy(&t->no[1], p + 1, t->length); + break; + case 'l': + if (next_lno >= N_NO) + { + fprintf(stderr, "Too many numbers to listen\n"); + exit(1); + } + listen_no[next_lno].ap = ap; + t = &listen_no[next_lno++].t; + t->length = strlen(p + 1) + 1; + if (t->length > 123) + { + fprintf(stderr, "ISDN number too long\n"); + exit(1); + } + t->no[0] = 0x81; + strncpy(&t->no[1], p + 1, t->length); + break; + case 'p': + switch (p[1]) + { + case 'r': + serv = 7; + prot = 2; + ui = 0; + break; + case 'u': + serv = 7; + prot = 2; + ui = 1; + break; + case 'X': + serv = 7; + prot = 1; + ui = 0; + break; + case 'C': + serv = 15; + prot = 5; + ui = 0; + break; + default: + fprintf(stderr, "Protocoll not supported\n"); + exit(1); + } + break; + case 'w': + timeout = atoi(p + 1); + break; + case 's': + bsize = atoi(p + 1); + break; + case 'S': + spv++; + break; + default: + } + fillparam(ap, &ip[ap], &dial[ap]); + if (ioctl(n, ISDN_SET_PARAM, &ip[ap]) < 0) + { + perror("ioctl: Set Param"); + exit(3); + } + setdefault(); + ap++; + no[ap].from = next_dno; + no[ap].n = 0; + } + listen.si_mask = si_mask; + if (listen.subadr_mask == 0) + listen.subadr_mask |= 1 << def_subadr; + listen.inf_mask = 3; + listen.ctrl = 0; + if (ioctl(n, ISDN_LISTEN, &listen) < 0) + { + perror("ioctl: Listen"); + exit(4); + } +} + +fillparam(int ap, isdn_param * ip, dial_t * d) +{ + if (subadr == -1) + subadr = def_subadr; + si_mask |= (u_short) (1 << serv); + /* + * spv = 0; + */ + bzero(ip, sizeof(isdn_param)); + bzero(d, sizeof(dial_t)); + d->appl = ip->appl = ap; + d->b_channel = 0x83; + d->inf_mask = 3; + d->out_serv = serv; + d->src_subadr = '0' + subadr; + ip->dlpd.protokoll = prot; + ip->dlpd.length = 7; + ip->dlpd.data_length = bsize; + ip->timeout = timeout; + ip->prot = ui; + ip->ncpd.protokoll = 4; +} + +void +main(int argc, char **argv) +{ + FILE *f; + int a, n, i; + u_char buf[4]; + + dofork = 1; + + while ((i = getopt(argc, argv, "c:l:F")) != EOF) + switch (i) + { + default: + fprintf(stderr, "Usage: iid [ -F ] [ -c configfile ] [ -l logfile ]\n"); + exit(1); + case 'c': + configfile = optarg; + break; + case 'l': + logfile = optarg; + break; + case 'F': + dofork = 0; + break; + } + + if (dofork) + { + if ((i = fork()) < 0) + { + fprintf(stderr, "Can't fork, %m"); + exit(1); + } + if (i > 0) + exit(0); + } /* running as daemon now */ + if (freopen(logfile, "a", stderr) == NULL) + { + perror(logfile); + exit(1); + } + if ((n = open("/dev/isdn", O_RDWR)) < 0) + { + perror("open: /dev/isdn"); + exit(1); + } + if ((f = fopen(configfile, "r")) == NULL) + { + perror(configfile); + exit(1); + } + process(f, n); + fclose(f); + + (void) signal(SIGHUP, catchsighup); + + (void) signal(SIGTERM, catchsig); + (void) signal(SIGKILL, catchsig); + (void) signal(SIGINT, catchsig); + (void) signal(SIGQUIT, catchsig); + + rescan = quit = 0; + fprintf(stderr, "s:iid started\n"); + fflush(stderr); + while (1) + { + int l; + int an, cn, serv, serv_add, subadr; + int typ, nl, dl; + char *tn; + + (void) setjmp(context); + if ((l = read(n, rbuf, 1024)) > 0) + { + switch (rbuf[0]) + { + case 'a': + sscanf(rbuf + 2, "%d %d %d %d %d %d %d %n", + &an, &cn, &serv, &serv_add, &subadr, &typ, &nl, &l); + l += 2; + buf[0] = cn; + buf[1] = find_appl(an, rbuf + l); + buf[2] = buf[3] = 0; + if (buf[1] == 0xff) + { + buf[2] = 0x3e; /* call reject */ + } + if (ioctl(n, ISDN_ACCEPT, &buf) < 0) + { + perror("ioctl: Accept"); + } + if (buf[1] == 0xff) + fprintf(stderr, "r:%d:%s\n", an, rbuf + l); + else + fprintf(stderr, "a:%d:%s\n", an, rbuf + l); + break; + case 'd': + sscanf(rbuf + 2, "%d", &an); + dial[an].ctrl = 0; + dial[an].appl = an; + if (no[an].n) + dial[an].telno = dial_no[no[an].from]; + else + { + fprintf(stderr, "cannot dial %d\n", an); + break; + } + if (ioctl(n, ISDN_DIAL, &dial[an]) < 0) + { + perror("ioctl: Dial"); + } + fprintf(stderr, "d:%d:%s\n", an, &dial[an].telno.no[1]); + break; + case 'i': + sscanf(rbuf + 2, "%d %d %d %n", &an, &typ, &nl, &l); + fprintf(stderr, "i:%d:%x:%s\n", an, typ, rbuf + l + 2); + switch (typ) + { + case 2: + break; + } + break; + case 'C': + sscanf(rbuf + 2, "%d %d %d", &an, &cn, &dl); + if (dl) + { + buf[0] = cn; + buf[1] = an; + buf[2] = 0; + if (ioctl(n, ISDN_ACCEPT, buf) < 0) + { + perror("ioctl: Accept"); + } + } + fprintf(stderr, "C:%d:%d\n", an, cn); + break; + case 'D': + sscanf(rbuf + 2, "%d %d", &an, &cn); + fprintf(stderr, "D:%d:%d\n", an, cn); + break; + default: + break; + } + } + if (quit) + { + fprintf(stderr, "s:Quit\n"); + exit(0); + } + if (rescan) + { + fprintf(stderr, "s:rescan\n"); + rescan = 0; + if ((f = fopen(configfile, "r")) == NULL) + perror(configfile); + else + { + process(f, n); + fclose(f); + } + } + fflush(stderr); + } +} + +int +find_appl(int an, u_char * b) +{ + int i; + char *tn; + + for (i = 0; i < next_lno; i++) + { + if (((tn = strstr(b, &listen_no[i].t.no[1])) != NULL) + && (strcmp(&listen_no[i].t.no[1], tn) == 0)) + return (listen_no[i].ap); + } + + fprintf(stderr, "I?:%d:%s\n", an, b); + return (-1); +} diff --git a/gnu/usr.sbin/isdn/ispy/Makefile b/gnu/usr.sbin/isdn/ispy/Makefile new file mode 100644 index 0000000..7ac4a9a --- /dev/null +++ b/gnu/usr.sbin/isdn/ispy/Makefile @@ -0,0 +1,5 @@ +PROG= ispy +NOMAN= yes +CFLAGS+= -DBSD -O + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/ispy/ispy.c b/gnu/usr.sbin/isdn/ispy/ispy.c new file mode 100644 index 0000000..5c2ac5a --- /dev/null +++ b/gnu/usr.sbin/isdn/ispy/ispy.c @@ -0,0 +1,43 @@ +static char rcsid[] = "@(#)$Id: ispy.c,v 1.2 1995/01/25 13:41:55 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.2 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: ispy.c,v $ + * + ******************************************************************************/ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/i386/isa/niccyreg.h" + +void +main(int argc, char **argv) +{ + int f; + int v; + + if ((f = open("/dev/nic0", O_RDWR)) < 0) + { + perror("open"); + exit(1); + } + v = 0; + if (argc > 1) + v = atoi(argv[1]); + + if (ioctl(f, NICCY_SPY, &v) < 0) + { + perror("ioctl"); + } +} diff --git a/gnu/usr.sbin/isdn/itel/Makefile b/gnu/usr.sbin/isdn/itel/Makefile new file mode 100644 index 0000000..089e993 --- /dev/null +++ b/gnu/usr.sbin/isdn/itel/Makefile @@ -0,0 +1,4 @@ +PROG= iteld +CFLAGS+= -DBSD -O + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/itel/iteld.c b/gnu/usr.sbin/isdn/itel/iteld.c new file mode 100644 index 0000000..8df099c --- /dev/null +++ b/gnu/usr.sbin/isdn/itel/iteld.c @@ -0,0 +1,234 @@ +static char rcsid[] = "@(#)$Id: iteld.c,v 1.2 1995/01/25 13:58:28 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.2 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: iteld.c,v $ + * + ******************************************************************************/ + +/* This is a ISDN-Daemon */ +/* It accepts ISDN-Telefon calls */ + +#include <sys/types.h> +#include <stdio.h> +#include <signal.h> +#include <errno.h> +#include <setjmp.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/isdn/isdn_ioctl.h" +#define min(a,b) ((a)<(b)?(a):(b)) + +#define NITEL 1 +#define NR_RINGS 10 +#define ANSWER_NUM 2 /* which number we use */ +#define TEL_LOG_FILE "/var/log/isdn.tel" + +listen_t listen; +isdn_param ip; + +int dofork = 1; +int quit = 0; +int def_subadr = 2; +jmp_buf context; +char *logfile = TEL_LOG_FILE; + +struct answ +{ + char occupied; + u_char an, cn; + char no[15]; +} answ[NITEL]; + +int ind, rind; +char rbuf[2048]; + +void +catchsig() +{ + quit++; + longjmp(context, 1); +} + +process(int n) +{ + fillparam(0, &ip, &listen); + if (ioctl(n, ISDN_SET_PARAM, &ip) < 0) + { + perror("ioctl: Set Param"); + exit(3); + } + if (ioctl(n, ISDN_LISTEN, &listen) < 0) + { + perror("ioctl: Listen"); + exit(4); + } +} + +fillparam(int ap, isdn_param * ip, listen_t * t) +{ + + bzero(ip, sizeof(isdn_param)); + bzero(t, sizeof(listen_t)); + t->appl = ip->appl = ap; + t->ctrl = 0; + t->inf_mask = 3; + t->subadr_mask = (u_short) 0x3ff; + t->si_mask = (u_short) 6; + ip->dlpd.protokoll = 3; + ip->dlpd.length = 7; + ip->dlpd.data_length = 1024; + ip->timeout = 60; + ip->prot = 0; + ip->ncpd.protokoll = 4; +} + +void +main(int argc, char **argv) +{ + FILE *f; + int a, n, i; + + dofork = 1; + + while ((i = getopt(argc, argv, "c:l:F")) != EOF) + switch (i) + { + default: + fprintf(stderr, "Usage: itel [ -F ] [ -l logfile ]\n"); + exit(1); + case 'l': + logfile = optarg; + break; + case 'F': + dofork = 0; + break; + } + + if (dofork) + { + if ((i = fork()) < 0) + { + fprintf(stderr, "Can't fork, %m"); + exit(1); + } + if (i > 0) + exit(0); + } /* running as daemon now */ + if (freopen(logfile, "a", stderr) == NULL) + { + perror(logfile); + exit(1); + } + if ((n = open("/dev/isdn2", O_RDWR)) < 0) + { + perror("open: /dev/isdn2"); + exit(1); + } + process(n); + + (void) signal(SIGHUP, catchsig); + (void) signal(SIGTERM, catchsig); + (void) signal(SIGKILL, catchsig); + (void) signal(SIGINT, catchsig); + (void) signal(SIGQUIT, catchsig); + + quit = 0; + fprintf(stderr, "s:iteld started\n"); + fflush(stderr); + while (1) + { + int l; + int an, cn, serv, serv_add, subadr; + int typ, nl, dl; + char *tn; + u_char buf[4]; + u_char telnum[128]; + + (void) setjmp(context); + if ((l = read(n, rbuf, 1024)) > 0) + { + switch (rbuf[0]) + { + case 'a': + sscanf(rbuf + 2, "%d %d %d %d %d %d %d %n", + &an, &cn, &serv, &serv_add, &subadr, &typ, &nl, &l); + l += 2; + buf[0] = cn; + buf[1] = find_appl(); + buf[2] = buf[3] = 0; + if (buf[1] == 0xff) + { + buf[2] = 0x3e; /* call reject */ + fprintf(stderr, "iteld: No Application\n"); + } + if (ioctl(n, ISDN_ACCEPT, &buf) < 0) + { + perror("ioctl: Accept"); + } + if (buf[1] == 0xff) + fprintf(stderr, "r:%d:%s\n", an, rbuf + l); + else + fprintf(stderr, "a:%d:%s\n", an, rbuf + l); + break; + case 'd': + fprintf(stderr, " s:dialing?i\n"); + break; + case 'i': + sscanf(rbuf + 2, "%d %d %d %n", &an, &typ, &nl, &l); + fprintf(stderr, "i:%d:%x:%s\n", an, typ, rbuf + l + 2); + break; + case 'C': + sscanf(rbuf + 2, "%d %d %d", &an, &cn, &dl); + if (dl) + break; + fprintf(stderr, "C:%d:%d\n", an, cn); + if (subadr == def_subadr) + /* jkr */ + system("/isdn/lib/answ >/dev/null 2>&1 &"); + break; + case 'D': + sscanf(rbuf + 2, "%d %d", &an, &cn); + answ[0].occupied = 0; + fprintf(stderr, "D:%d:%d\n", an, cn); + break; + default: + break; + } + } + if (quit) + { + fprintf(stderr, "s:Quit\n"); + exit(0); + } + fflush(stderr); + } +} + +int +find_appl() +{ + int i; + struct answ *a; + + for (i = 0; i < NITEL; i++) + { + a = &answ[i]; + if (a->occupied == 0) + { + a->occupied = 1; + return (i); + } + } + return (-1); +} diff --git a/gnu/usr.sbin/isdn/ittd/Makefile b/gnu/usr.sbin/isdn/ittd/Makefile new file mode 100644 index 0000000..1e84b28 --- /dev/null +++ b/gnu/usr.sbin/isdn/ittd/Makefile @@ -0,0 +1,18 @@ +I =/isdn/bin + +OPTIONS =-DBSD -O + +OBJS = ittd + +all: $(OBJS) + +ittd: ittd.c + cc $(OPTIONS) -o ittd ittd.c + +install: all + strip ittd + install ittd $I + +clean: + @rm -f $(OBJS) a.out core.* + diff --git a/gnu/usr.sbin/isdn/ittd/ittd.1 b/gnu/usr.sbin/isdn/ittd/ittd.1 new file mode 100644 index 0000000..431808e --- /dev/null +++ b/gnu/usr.sbin/isdn/ittd/ittd.1 @@ -0,0 +1,39 @@ +.\" Copyright (c) 1994 Dietmar Friede +.Dd September 15, 1994 +.Os BSD +.Dt "ISDN ittd" 1 +.Sh NAME +.Nm ittd +.Nd ISDN tty daemon +.Sh SYNOPSIS +.Nm ittd +[ -F ] [ -c file ] [ -l file ] + +-F do not fork + +-c file use file as source of the configuration (default /etc/isdn.itt) + +-l file use file as logfile (default /var/log/isdn.itt) + +.Sh DESCRIPTION +Die Form der Konfigurationdatei /etc/isdn.itt wird, +bis ich das mit dem Euro ISDN verstanden hab: + +Der File besteht aus einer Zeile: + +A1:pr:w100: + +An Bedeutet Subadresse n ("EAZ" n). + +px protocoll x siehe oben. + +wn wait n Haeng auf wenn n Sekunden nichts uebertragen wurde, n = 0 haeng nicht auf. + +mn mtu n die maximale IP Uebertagungslaenge wird n + +sm size m Pufferlaenge der ISDN-Karte sm >= mn bei UI sm >= mn+2 + +Wobei das Maximum 2048 ist. + +Als Protokoll wird HDLC mit UI-frames (u), HDLC roh (r), X75 (X) und BTX-X75 (C) +unterstuetzt. diff --git a/gnu/usr.sbin/isdn/ittd/ittd.c b/gnu/usr.sbin/isdn/ittd/ittd.c new file mode 100644 index 0000000..efb152a7 --- /dev/null +++ b/gnu/usr.sbin/isdn/ittd/ittd.c @@ -0,0 +1,526 @@ +static char rcsid[] = "@(#)$Id: ittd.c,v 1.2 1995/01/25 14:01:28 jkr Exp jkr $"; +/******************************************************************************* + * II Version 0.1 - $Revision: 1.2 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: ittd.c,v $ + * + ******************************************************************************/ + +/* This is a ISDN-Daemon for tty dialin */ + +#include <sys/types.h> +#include <stdio.h> +#include <signal.h> +#include <errno.h> +#include <setjmp.h> +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/isdn/isdn_ioctl.h" +#define min(a,b) ((a)<(b)?(a):(b)) + +#define NITTY 2 +#define NOTTY 2 +#define NTTY (NITTY + NOTTY) + +listen_t listen; +isdn_param ip[NTTY]; +dial_t dial[NOTTY]; + +struct iline +{ + char occupied; + u_char an, cn; + char no[15]; +} iline[NTTY]; + +int dofork = 1; +int quit = 0, rescan = 0; +jmp_buf context; +char *logfile = "/var/log/isdn.itt"; +char *configfile = "/etc/isdn.itt"; + +int subadr, prot, bsize, timeout, spv, ui, serv; +int def_subadr = 3; +int ind, rind; +char rbuf[2048]; +unsigned short si_mask; + +void +catchsig() +{ + quit++; + longjmp(context, 1); +} + +void +catchsighup() +{ + rescan++; + (void) signal(SIGHUP, catchsighup); + longjmp(context, 1); +} + +setdefault() +{ + subadr = -1; + prot = 2; + ui = 1; + serv = 7; + timeout = 0; + bsize = 2048; + spv = 0; +} + +char * +gettoc() +{ + if (rind == -1) + { + rind = 0; + return (rbuf); + } + while (rbuf[++rind]); + rind++; + + if (rind >= ind) + return (NULL); + + return (&rbuf[rind]); +} + +filline(FILE * f) +{ + int c; + + ind = 1; + rbuf[0] = 'H'; + + while ((c = fgetc(f)) != EOF) + { + if (isalnum(c)) + { + rbuf[ind++] = c; + } else + switch (c) + { + case '#': + fgets(rbuf + ind, 2048 - ind, f); + if (ind == 1) + break; + /* Fall through */ + case '\n': + rbuf[ind] = 0; + rind = -1; + return (0); + case ':': + rbuf[ind++] = 0; + break; + } + } + if (ind > 1) + return (0); + return (EOF); +} + +process(FILE * f, int n) +{ + char *p; + int ap = 0; + + setdefault(); + + if (filline(f) != EOF) + { + while ((p = gettoc()) != NULL) + switch (p[0]) + { + case 'A': + def_subadr = p[1] - '0'; + listen.subadr_mask |= 1 << def_subadr; + break; + case 'p': + switch (p[1]) + { + case 'r': + serv = 7; + prot = 2; + ui = 0; + break; + case 'u': + serv = 7; + prot = 2; + ui = 1; + break; + case 'X': + serv = 7; + prot = 1; + ui = 0; + break; + case 'C': + serv = 15; + prot = 5; + ui = 0; + break; + default: + fprintf(stderr, "Protocoll not supported\n"); + exit(1); + } + break; + case 'w': + timeout = atoi(p + 1); + break; + case 's': + bsize = atoi(p + 1); + break; + case 'S': + spv++; + break; + default: + } + } + for (ap = 0; ap < NTTY; ap++) + { + fillparam(ap, &ip[ap]); + if (ioctl(n, ISDN_SET_PARAM, &ip[ap]) < 0) + { + perror("ioctl: Set Param"); + exit(3); + } + } + + listen.si_mask = si_mask; + if (listen.subadr_mask == 0) + listen.subadr_mask |= 1 << def_subadr; + listen.inf_mask = 3; + listen.ctrl = 0; + + if (ioctl(n, ISDN_LISTEN, &listen) < 0) + { + perror("ioctl: Listen"); + exit(4); + } +} + +fillparam(int ap, isdn_param * ip) +{ + if (subadr == -1) + subadr = def_subadr; + si_mask |= (u_short) (1 << serv); + /* + * spv = 0; + */ + bzero(ip, sizeof(isdn_param)); + ip->appl = ap; + ip->dlpd.protokoll = prot; + ip->dlpd.length = 7; + ip->dlpd.data_length = bsize; + ip->timeout = timeout; + ip->prot = ui; + ip->ncpd.protokoll = 4; +} + +realine(char *b) +{ + int c; + + ind = 0; + + while (c = *b & 0x7f) + { + b++; + if (isalnum(c)) + { + rbuf[ind++] = c; + } else if (c == '.') + rbuf[ind++] = 0; + } + if (ind > 1) + return (0); + return (EOF); +} + +process_dial(int n, int ap, char *b) +{ + char *p; + telno_t *t; + + setdefault(); + + if (realine(b) == EOF) + return; + + rind = -1; + + while ((p = gettoc()) != NULL) + { + switch (p[0]) + { + case 'a': + subadr = p[1] - '0'; + break; + case 'd': + t = &dial[ap - NITTY].telno; + t->length = strlen(p + 1) + 1; + if (t->length > 123) + { + fprintf(stderr, "ISDN number too long\n"); + exit(1); + } + t->no[0] = 0x81; + strncpy(&t->no[1], p + 1, t->length); + break; + case 'p': + switch (p[1]) + { + case 'r': + serv = 7; + prot = 2; + ui = 0; + break; + case 'u': + serv = 7; + prot = 2; + ui = 1; + break; + case 'X': + serv = 7; + prot = 1; + ui = 0; + break; + case 'C': + serv = 15; + prot = 5; + ui = 0; + break; + default: + fprintf(stderr, "Protocoll not supported\n"); + exit(1); + } + break; + case 'w': + timeout = atoi(p + 1); + break; + case 's': + bsize = atoi(p + 1); + break; + case 'S': + spv++; + break; + default: + } + } + filldial(ap, &ip[ap], &dial[ap - NITTY]); + if (ioctl(n, ISDN_SET_PARAM, &ip[ap]) < 0) + { + perror("ioctl: Set Param"); + exit(3); + } +} + +filldial(int ap, isdn_param * ip, dial_t * d) +{ + if (subadr == -1) + subadr = def_subadr; + /* + * spv = 0; + */ + bzero(ip, sizeof(isdn_param)); + d->appl = ip->appl = ap; + d->b_channel = 0x83; + d->inf_mask = 3; + d->out_serv = serv; + d->src_subadr = '0' + subadr; + ip->dlpd.protokoll = prot; + ip->dlpd.length = 7; + ip->dlpd.data_length = bsize; + ip->timeout = timeout; + ip->prot = ui; + ip->ncpd.protokoll = 4; +} + +void +main(int argc, char **argv) +{ + FILE *f; + int a, n, i; + u_char buf[4]; + + dofork = 1; + + while ((i = getopt(argc, argv, "c:l:F")) != EOF) + switch (i) + { + default: + fprintf(stderr, "Usage: ittd [ -F ] [ -c configfile ] [ -l logfile ]\n"); + exit(1); + case 'c': + configfile = optarg; + break; + case 'l': + logfile = optarg; + break; + case 'F': + dofork = 0; + break; + } + + if (dofork) + { + if ((i = fork()) < 0) + { + fprintf(stderr, "Can't fork, %m"); + exit(1); + } + if (i > 0) + exit(0); + } /* running as daemon now */ + if (freopen(logfile, "a", stderr) == NULL) + { + perror(logfile); + exit(1); + } + if ((n = open("/dev/isdn1", O_RDWR)) < 0) + { + perror("open: /dev/isdn1"); + exit(1); + } + if ((f = fopen(configfile, "r")) == NULL) + { + perror(configfile); + exit(1); + } + process(f, n); + fclose(f); + + (void) signal(SIGHUP, catchsighup); + + (void) signal(SIGTERM, catchsig); + (void) signal(SIGKILL, catchsig); + (void) signal(SIGINT, catchsig); + (void) signal(SIGQUIT, catchsig); + + rescan = quit = 0; + fprintf(stderr, "s:ittd started\n"); + fflush(stderr); + while (1) + { + int l; + int an, cn, serv, serv_add, subadr; + int typ, nl, dl; + char *tn; + + (void) setjmp(context); + if ((l = read(n, rbuf, 1024)) > 0) + { + switch (rbuf[0]) + { + case 'a': + sscanf(rbuf + 2, "%d %d %d %d %d %d %d %n", + &an, &cn, &serv, &serv_add, &subadr, &typ, &nl, &l); + l += 2; + buf[0] = cn; + buf[1] = find_appl(); + buf[2] = buf[3] = 0; + if (buf[1] == 0xff) + { + buf[2] = 0x3e; /* call reject */ + } + if (ioctl(n, ISDN_ACCEPT, &buf) < 0) + { + perror("ioctl: Accept"); + } + if (buf[1] == 0xff) + fprintf(stderr, "r:%d:%s\n", an, rbuf + l); + else + fprintf(stderr, "a:%d:%s\n", an, rbuf + l); + break; + case 'i': + sscanf(rbuf + 2, "%d %d %d %n", &an, &typ, &nl, &l); + fprintf(stderr, "i:%d:%x:%s\n", an, typ, rbuf + l + 2); + switch (typ) + { + case 2: + break; + } + break; + case 'C': + sscanf(rbuf + 2, "%d %d %d", &an, &cn, &dl); + if (dl) + { + buf[0] = cn; + buf[1] = an; + buf[2] = 0; + if (ioctl(n, ISDN_ACCEPT, buf) < 0) + { + perror("ioctl: Accept"); + } + } + fprintf(stderr, "C:%d:%d\n", an, cn); + break; + case 'D': + sscanf(rbuf + 2, "%d %d", &an, &cn); + iline[an].occupied = 0; + fprintf(stderr, "D:%d:%d\n", an, cn); + break; + case 'M': + sscanf(rbuf + 2, "%d %n", &an, &l); + process_dial(n, an, rbuf + l + 2); + if (ioctl(n, ISDN_DIAL, &dial[an - NITTY]) < 0) + { + perror("ioctl: Dial"); + } + fprintf(stderr, "d:%d:%s\n", an, &dial[an - NITTY].telno.no[1]); + break; + default: + break; + } + } + if (quit) + { + fprintf(stderr, "s:Quit\n"); + exit(0); + } + if (rescan) + { + fprintf(stderr, "s:rescan\n"); + rescan = 0; + if ((f = fopen(configfile, "r")) == NULL) + perror(configfile); + else + { + process(f, n); + fclose(f); + } + } + fflush(stderr); + } +} + +int +find_appl() +{ + int i; + struct iline *a; + + for (i = 0; i < NITTY; i++) + { + a = &iline[i]; + if (a->occupied == 0) + { + a->occupied = 1; + return (i); + } + } + return (-1); +} diff --git a/gnu/usr.sbin/isdn/load/Makefile b/gnu/usr.sbin/isdn/load/Makefile new file mode 100644 index 0000000..31bc381 --- /dev/null +++ b/gnu/usr.sbin/isdn/load/Makefile @@ -0,0 +1,5 @@ +PROG= load +CFLAGS+= -DBSD -O +NOMAN= yes + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/load/load.c b/gnu/usr.sbin/isdn/load/load.c new file mode 100644 index 0000000..fa9e600 --- /dev/null +++ b/gnu/usr.sbin/isdn/load/load.c @@ -0,0 +1,117 @@ +static char rcsid[] = "@(#)$Id: load.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: load.c,v $ + * + ******************************************************************************/ + +#include <sys/types.h> +#undef BSD +#include <sys/param.h> +#include <machine/endian.h> +#include <stdio.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include <time.h> +#include "../../../../sys/gnu/i386/isa/niccyreg.h" + +struct head head; +char buf[64 * 1024]; + +void +main(int argc, char **argv) +{ + FILE *f; + int n; + argv++; + + if ((n = open("/dev/nic0", O_RDWR)) < 0) + { + perror("open"); + exit(1); + } + if (!*argv) + { + process(stdin, n); + } else + while (*argv) + { + if ((f = fopen(*argv, "r")) == NULL) + { + perror(*argv); + exit(1); + } else + { + process(f, n); + fclose(f); + } + argv++; + } + exit(0); +} + +stime(int f) +{ + struct tm *t; + time_t tt; + char buf[16]; + + tt = time(NULL); + t = localtime(&tt); + sprintf(buf, "%.2d%.2d%.2d%.2d%.2d19%.2d", t->tm_hour, + t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon + 1, t->tm_year); + + if (ioctl(f, NICCY_SET_CLOCK, buf) < 0) + { + perror("ioctl"); + } +} + + +process(FILE * f, int n) +{ + long size; + int len; + int no = 0; + + while ((len = fread(buf, 1, 0x16, f)) == 0x16) + { + bcopy(buf, (char *) &head, 0x16); + head.data = buf; + size = ntohl(head.len); + if ((len = fread(&buf[0x16], 1, size - 0x16, f)) != (size - 0x16)) + { + fprintf(stderr, "Cannot read modul %.8s of length %d\n", + head.nam, size); + exit(1); + } + printf("%d\t %x %.8s %.5s %x\n", + size, head.sig, head.nam, head.ver, head.typ); + + head.d_len = size; + head.status = no++; + + if (ioctl(n, NICCY_LOAD, &head) < 0) + { + perror("load"); + exit(1); + } + if (head.status) + { + fprintf(stderr, "Error loading %d\n", head.status); + exit(1); + } + } + printf("done\n"); + + stime(n); +} diff --git a/gnu/usr.sbin/isdn/misc/Makefile b/gnu/usr.sbin/isdn/misc/Makefile new file mode 100644 index 0000000..914fddd --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/Makefile @@ -0,0 +1,21 @@ +CFLAGS+= -DBSD -O + +ETCFILES = isdn.ip remote isdn.itt ttys +CLEANFILES+= tst stime *.o + +all: tst stime + +tst: tst.c + ${CC} $(CFLAGS) -o tst tst.c + +stime: stime.c + ${CC} $(CFLAGS) -o stime stime.c + +install: all + ${INSTALL} ${COPY} tst ${BINDIR}/isdn_test + ${INSTALL} ${COPY} stime ${BINDIR}/isdn_stime + ${INSTALL} ${COPY} -m 755 setnic.sh ${LIBDIR}/setnic + ${INSTALL} ${COPY} -m 755 sisdn.sh ${LIBDIR}/sisdn.example + ${INSTALL} ${COPY} ${ETCFILES} ${LIBDIR} + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/misc/isdn.ip b/gnu/usr.sbin/isdn/misc/isdn.ip new file mode 100644 index 0000000..89b7376 --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/isdn.ip @@ -0,0 +1,3 @@ +# This is nothing but a first try. Syntax might be completly different soon. +0:d102:l102:e2:pu:s1502:w10: +1:d113:l113:e3:pu:s1502:w10: diff --git a/gnu/usr.sbin/isdn/misc/isdn.itt b/gnu/usr.sbin/isdn/misc/isdn.itt new file mode 100644 index 0000000..74a58fa --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/isdn.itt @@ -0,0 +1 @@ +0:A8:pr.:w100: diff --git a/gnu/usr.sbin/isdn/misc/remote b/gnu/usr.sbin/isdn/misc/remote new file mode 100644 index 0000000..cda70ac --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/remote @@ -0,0 +1,2 @@ +isdn:dv=/dev/ityo0:cm=d123.:pa=none: +re:dv=/dev/ityo0:cm=d133.:pa=none: diff --git a/gnu/usr.sbin/isdn/misc/setnic.sh b/gnu/usr.sbin/isdn/misc/setnic.sh new file mode 100644 index 0000000..9d2e099 --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/setnic.sh @@ -0,0 +1,84 @@ +# First Parameter one out of the following: +# 5000 Niccy 5000 +# 3008 Niccy 3008 +# 3009 Niccy 3009 +# 1000 Niccy 1000 +# tel* , TEL* TELES S0 +# +# Second Parameter is optional: +# E* e* Euro ISDN EDSS1 +# 1T* 1t* t* T* 1TR6 (old german protocol) (default for the moment) + +PATH=/sbin:/bin/:/usr/bin:/usr/sbin +SYSTEM=`uname` +VER=`uname -a | cut -d' ' -f3` +case $SYSTEM in +NetBSD) + SN=netbsd + ;; +FreeBSD) + case $VER in + 1.0*|1.1*) + SN=386bsd + ;; + 2.0*) + SN=kernel + ;; + *) + echo System $SYSTEM Version $VER not supported + exit + esac + ;; +*) + echo System $SYSTEM not supported + exit +esac + +if [ "$2" = "" ] +then + LIB=tr6 +else + case $2 in + E*|e*) + LIB=eds + ;; + 1t*|1T*|t*|T*) + LIB=tr6 + ;; + *) + echo library $2 not supported + exit + esac +fi + + +case $1 in + +5000) + rm -f /$SN /isdn/lib/all.nic + ln /$SN.5000 /$SN + ln /isdn/lib/all.$LIB.5000 /isdn/lib/all.nic + /isdn/bin/mkdev 5000 + ;; +3008) + rm -f /$SN /isdn/lib/all.nic + ln /$SN.3008 /$SN + ln /isdn/lib/all.$LIB.3008 /isdn/lib/all.nic + /isdn/bin/mkdev 3008 + ;; +3009) + rm -f /$SN /isdn/lib/all.nic + ln /$SN.3009 /$SN + ln /isdn/lib/all.$LIB.3009 /isdn/lib/all.nic + /isdn/bin/mkdev 3009 + ;; +1000|tel*|TEL*) + rm -f /$SN /isdn/lib/all.nic + ln /$SN.1000 /$SN + /isdn/bin/mkdev 1000 + ;; +esac + +ls -l /$SN* + +echo please reboot the system by typing: fastboot diff --git a/gnu/usr.sbin/isdn/misc/sisdn.sh b/gnu/usr.sbin/isdn/misc/sisdn.sh new file mode 100644 index 0000000..aca1bc7 --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/sisdn.sh @@ -0,0 +1,8 @@ +load /isdn/lib/all.nic +iid +ittd +iteld +ifconfig ii0 inet 192.192.192.2 192.192.192.1 +ifconfig ii1 inet 192.192.193.2 192.192.193.1 +route add ver 192.192.192.2 +route add ver1 192.192.193.2 diff --git a/gnu/usr.sbin/isdn/misc/stime.c b/gnu/usr.sbin/isdn/misc/stime.c new file mode 100644 index 0000000..5eb21d4 --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/stime.c @@ -0,0 +1,44 @@ +static char rcsid[] = "@(#)$Id: stime.c,v 1.1 1995/01/25 14:14:58 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: stime.c,v $ + * + ******************************************************************************/ + +#include <sys/types.h> +#include <stdio.h> +#include <time.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/i386/isa/niccyreg.h" + +main() +{ + struct tm *t; + time_t tt; + int f; + char buf[16]; + + if ((f = open("/dev/nic0", O_RDWR)) < 0) + { + perror("open"); + exit(1); + } + tt = time(NULL); + t = localtime(&tt); + sprintf(buf, "%.2d%.2d%.2d%.2d%.2d19%.2d", t->tm_hour, + t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon + 1, t->tm_year); + + if (ioctl(f, NICCY_SET_CLOCK, buf) < 0) + { + perror("ioctl"); + } +} diff --git a/gnu/usr.sbin/isdn/misc/tst.c b/gnu/usr.sbin/isdn/misc/tst.c new file mode 100644 index 0000000..535de1e --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/tst.c @@ -0,0 +1,74 @@ +static char rcsid[] = "@(#)$Id: tst.c,v 1.1 1995/01/25 14:14:58 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: tst.c,v $ + * + ******************************************************************************/ + +/* + * This program reads a 3008 or 5000 or ... download file and shows Headers + * and statistics + */ + +#include <sys/types.h> +#include <machine/endian.h> +#include <stdio.h> + +struct head +{ + u_long len; + u_long sig; + char nam[8]; + char ver[5]; + u_char typ; +} head; + +void +main(int argc, char **argv) +{ + FILE *f; + argv++; + + if (!*argv) + { + process(stdin); + } else + while (*argv) + { + if ((f = fopen(*argv, "r")) == NULL) + { + perror(*argv); + exit(1); + } else + { + process(f); + fclose(f); + } + argv++; + } + exit(0); +} + +process(FILE * f) +{ + long off; + + off = 0; + + while (fread(&head, 1, 0x16, f) == 0x16) + { + printf("%d\t %x %.8s %.5s %x\n", + ntohl(head.len), head.sig, head.nam, head.ver, head.typ); + off += ntohl(head.len); + fseek(f, off, SEEK_SET); + } + printf("%d\n", off); +} diff --git a/gnu/usr.sbin/isdn/misc/ttys b/gnu/usr.sbin/isdn/misc/ttys new file mode 100644 index 0000000..9f135c4 --- /dev/null +++ b/gnu/usr.sbin/isdn/misc/ttys @@ -0,0 +1,2 @@ +ity00 "/usr/libexec/getty Pc" unknown on secure +ity01 "/usr/libexec/getty Pc" unknown on secure diff --git a/gnu/usr.sbin/isdn/nsplit/Makefile b/gnu/usr.sbin/isdn/nsplit/Makefile new file mode 100644 index 0000000..d79b840 --- /dev/null +++ b/gnu/usr.sbin/isdn/nsplit/Makefile @@ -0,0 +1,5 @@ +PROG= nsplit +CFLAGS+= -DBSD -O +NOMAN= yes + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/nsplit/nsplit.c b/gnu/usr.sbin/isdn/nsplit/nsplit.c new file mode 100644 index 0000000..2502a58 --- /dev/null +++ b/gnu/usr.sbin/isdn/nsplit/nsplit.c @@ -0,0 +1,102 @@ +static char rcsid[] = "@(#)$Id: nsplit.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: nsplit.c,v $ + * + ******************************************************************************/ + +#include <sys/types.h> +#undef BSD +#include <sys/param.h> +#include <machine/endian.h> +#include <stdio.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include <time.h> +#include "../../../../sys/gnu/i386/isa/niccyreg.h" + +struct head head; + +void +main(int argc, char **argv) +{ + FILE *f; + int n; + argv++; + + if (!*argv) + { + process(stdin); + } else + while (*argv) + { + if ((f = fopen(*argv, "r")) == NULL) + { + perror(*argv); + exit(1); + } else + { + process(f); + fclose(f); + } + argv++; + } + exit(0); +} + +process(FILE * f) +{ + long off = 0; + long size, rest; + int len; + char buf[1024]; + int ex; + int no = 0; + char nbuf[16]; + FILE *fout; + + while ((len = fread(buf, 1, 1024, f)) >= 0x16) + { + head = *(struct head *) buf; + size = rest = ntohl(head.len); + ex = len == rest; + + sprintf(nbuf, "o%.2d", no); + if ((fout = fopen(nbuf, "w")) == NULL) + { + perror(nbuf); + exit(1); + } else + printf("%d\t %x %.8s %.5s %x\n", + rest, head.sig, head.nam, head.ver, head.typ); + + do + { + fwrite(buf, 1, MIN(len, rest), fout); + rest -= MIN(len, rest); + + if (rest > 0) + len = fread(buf, 1, MIN(rest, 1024), f); + } + while (rest > 0); + + if (ex) + break; + no++; + + off += size; + if ((size < 1024) && (size > 0x16)) + fseek(f, off, SEEK_SET); + } + printf("done\n"); + +} diff --git a/gnu/usr.sbin/isdn/play/Makefile b/gnu/usr.sbin/isdn/play/Makefile new file mode 100644 index 0000000..522673d --- /dev/null +++ b/gnu/usr.sbin/isdn/play/Makefile @@ -0,0 +1,7 @@ +NOMAN= noman + +beforeinstall: + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${.CURDIR}/play.sh ${DESTDIR}/${BINDIR}/play + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/play/play.sh b/gnu/usr.sbin/isdn/play/play.sh new file mode 100644 index 0000000..71a142d --- /dev/null +++ b/gnu/usr.sbin/isdn/play/play.sh @@ -0,0 +1,6 @@ +# play.sh +for i in /isdn/msg/R.* +do + dd of=/dev/itel00 if=$i bs=1k + dd of=/dev/itel00 if=/isdn/msg/beep bs=1k +done >/dev/null 2>&1 diff --git a/gnu/usr.sbin/isdn/rst/Makefile b/gnu/usr.sbin/isdn/rst/Makefile new file mode 100644 index 0000000..a3c6932 --- /dev/null +++ b/gnu/usr.sbin/isdn/rst/Makefile @@ -0,0 +1,4 @@ +PROG= rst +CFLAGS+= -DBSD -O + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/rst/rst.c b/gnu/usr.sbin/isdn/rst/rst.c new file mode 100644 index 0000000..331bdba --- /dev/null +++ b/gnu/usr.sbin/isdn/rst/rst.c @@ -0,0 +1,35 @@ +static char rcsid[] = "@(#)$Id: rst.c,v 1.1 1995/01/25 14:07:55 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: rst.c,v $ + * + ******************************************************************************/ + +#include <sys/types.h> +#include <stdio.h> +#include <sys/ioctl.h> +#include <sys/file.h> +#include "../../../../sys/gnu/i386/isa/niccyreg.h" + +main() +{ + int s, f; + + if ((f = open("/dev/nic0", O_RDWR)) < 0) + { + perror("open"); + exit(1); + } + if (ioctl(f, NICCY_RESET, &s) < 0) + { + perror("ioctl"); + } +} diff --git a/gnu/usr.sbin/isdn/rstcode/Makefile b/gnu/usr.sbin/isdn/rstcode/Makefile new file mode 100644 index 0000000..093f191 --- /dev/null +++ b/gnu/usr.sbin/isdn/rstcode/Makefile @@ -0,0 +1,5 @@ +PROG= rstcode +CFLAGS+= -DBSD -O +NOMAN= yes + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/rstcode/rstcode.c b/gnu/usr.sbin/isdn/rstcode/rstcode.c new file mode 100644 index 0000000..5a9970b --- /dev/null +++ b/gnu/usr.sbin/isdn/rstcode/rstcode.c @@ -0,0 +1,51 @@ +static char rcsid[] = "@(#)$Id: rstcode.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.1 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: rstcode.c,v $ + * + ******************************************************************************/ +#include <sys/types.h> +#include <machine/endian.h> +#include <stdio.h> + +struct head +{ + u_long len; + u_long sig; + char nam[8]; + char ver[5]; + u_char typ; +} head = +{ + 0, 0, "RESETCOD", "0.000", 3 +}; + + + +const char ResetCode[] = { + 0x00, 0x00, 0x00, 0x00, /* SP */ + 0x00, 0x00, 0x00, 0x08, /* PC */ + 0x20, 0x7c, 0xff, 0xff, 0xff, 0xcc, /* movea.l #0xffffffcc,a0 */ + 0x20, 0xbc, 0xff, 0xf9, 0xe6, 0xff, /* move.l #0xffff9e6ff,(a0) */ + 0x51, 0x88, /* subq.q #8,a0 */ + 0x21, 0x3c, 0x00, 0x01, 0xe6, 0xff, /* move.l #0x1e6ff,-(a0) */ + 0x20, 0x38, 0x07, 0xfc, /* move.l $7fc,d0 ; Reset PC DPRAM */ + 0x10, 0x39, 0xFF, 0xF8, 0x07, 0xff, /* move.b $fff807ff,d0 Reset + * DSP DPRAM */ + 0x42, 0xb8, 0x00, 0x04, /* clr.l $4 */ +0x4e, 0x72, 0x27, 0x00}; /* stop #$2700 */ + +main() +{ + head.len = ntohl(0x16 + sizeof(ResetCode)); + fwrite(&head, 1, 0x16, stdout); + fwrite(ResetCode, 1, sizeof(ResetCode), stdout); +} diff --git a/gnu/usr.sbin/isdn/spy/Makefile b/gnu/usr.sbin/isdn/spy/Makefile new file mode 100644 index 0000000..2a9167c --- /dev/null +++ b/gnu/usr.sbin/isdn/spy/Makefile @@ -0,0 +1,4 @@ +PROG= spy +CFLAGS+= -DBSD -O + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/spy/spy.c b/gnu/usr.sbin/isdn/spy/spy.c new file mode 100644 index 0000000..1f730c0 --- /dev/null +++ b/gnu/usr.sbin/isdn/spy/spy.c @@ -0,0 +1,108 @@ +static char rcsid[] = "@(#)$Id: spy.c,v 1.2 1995/01/25 13:41:44 jkr Exp jkr $"; +/******************************************************************************* + * II - Version 0.1 $Revision: 1.2 $ $State: Exp $ + * + * Copyright 1994 Dietmar Friede + ******************************************************************************* + * Bug reports, patches, comments, suggestions should be sent to: + * + * jkr@saarlink.de or jkrause@guug.de + * + ******************************************************************************* + * $Log: spy.c,v $ + * + ******************************************************************************/ + +#include <stdio.h> +#include <signal.h> +#include <fcntl.h> +#include <ctype.h> +#include <sys/time.h> + +#define BSIZE 1024+sizeof(struct timeval)+sizeof(unsigned long)+1 +unsigned char buf[BSIZE]; +FILE *Fout = NULL; + +static void +catchsig() +{ + printf("EXIT\n"); + exit(1); +} + +main(argc, argv) + int argc; + char **argv; +{ + int f, n; + struct timeval *t = (struct timeval *) & buf[sizeof(unsigned long) + 1]; + char *b = &buf[sizeof(struct timeval) + sizeof(unsigned long) + 1]; + struct tm *s; + + if ((f = open("/dev/ispy", O_RDONLY)) < 0) + { + perror(argv[1]); + exit(1); + } + argv++; + if (*argv) + Fout = fopen(*argv, "w"); + + (void) signal(SIGHUP, catchsig); + (void) signal(SIGTERM, catchsig); + (void) signal(SIGKILL, catchsig); + (void) signal(SIGINT, catchsig); + (void) signal(SIGQUIT, catchsig); + + for (;;) + { + n = read(f, buf, BSIZE); + n -= sizeof(struct timeval) + sizeof(unsigned long) + 1; + s = localtime(&t->tv_sec); + if (*buf) + printf("> "); + else + printf("< "); + printf("%.4d: %.2d:%.2d:%.2d.%.2d len %d:\n", *(unsigned long *) &buf[1], + s->tm_hour, s->tm_min, s->tm_sec, t->tv_usec / 10000, n); + if (Fout != NULL) + { + if (*buf) + fprintf(Fout, "> "); + else + fprintf(Fout, "< "); + fprintf(Fout, "%.4d: %.2d:%.2d:%.2d.%.2d len %d:\n", + *(unsigned long *) &buf[1], s->tm_hour, s->tm_min, + s->tm_sec, t->tv_usec / 10000, n); + } + if (n > 0) + { + dumpbuf(stdout, n, b); + if (Fout != NULL) + dumpbuf(Fout, n, b); + } + } +} + +dumpbuf(FILE * f, int n, unsigned char *buf) +{ + int i, j; + + for (i = 0; i < n; i += 16) + { + fprintf(f, "%.3x ", i); + for (j = 0; j < 16; j++) + if (i + j < n) + fprintf(f, "%02x ", buf[i + j]); + else + fprintf(f, " "); + fprintf(f, " "); + for (j = 0; j < 16 && i + j < n; j++) + if (isprint(buf[i + j])) + fprintf(f, "%c", buf[i + j]); + else + fputc('.', f); + fputc('\n', f); + } + fflush(f); +} diff --git a/gnu/usr.sbin/isdn/ulaw2alaw/Makefile b/gnu/usr.sbin/isdn/ulaw2alaw/Makefile new file mode 100644 index 0000000..494c541 --- /dev/null +++ b/gnu/usr.sbin/isdn/ulaw2alaw/Makefile @@ -0,0 +1,5 @@ +PROG= ulaw2alaw +CFLAGS+= -DBSD -O +NOMAN= yes + +.include <bsd.prog.mk> diff --git a/gnu/usr.sbin/isdn/ulaw2alaw/README b/gnu/usr.sbin/isdn/ulaw2alaw/README new file mode 100644 index 0000000..771e87f --- /dev/null +++ b/gnu/usr.sbin/isdn/ulaw2alaw/README @@ -0,0 +1 @@ +stolen from isdndrv-0.1.1 diff --git a/gnu/usr.sbin/isdn/ulaw2alaw/con.h b/gnu/usr.sbin/isdn/ulaw2alaw/con.h new file mode 100644 index 0000000..def02c5 --- /dev/null +++ b/gnu/usr.sbin/isdn/ulaw2alaw/con.h @@ -0,0 +1,162 @@ + +static unsigned char ulaw_linear[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, + 5, 9, 13, 17, 21, 25, 29, 33, + 37, 41, 45, 49, 53, 57, 61, 65, + 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, + 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, + 115, 116, 116, 117, 117, 118, 118, 119, + 119, 120, 120, 121, 121, 122, 122, 123, + 123, 123, 124, 124, 124, 124, 125, 125, + 125, 125, 126, 126, 126, 126, 127, 127, + 127, 127, 127, 127, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 252, 248, 244, 240, 236, 232, 228, 224, + 220, 216, 212, 208, 204, 200, 196, 192, + 189, 187, 185, 183, 181, 179, 177, 175, + 173, 171, 169, 167, 165, 163, 161, 159, + 157, 156, 155, 154, 153, 152, 151, 150, + 149, 148, 147, 146, 145, 144, 143, 142, + 142, 141, 141, 140, 140, 139, 139, 138, + 138, 137, 137, 136, 136, 135, 135, 134, + 134, 134, 133, 133, 133, 133, 132, 132, + 132, 132, 131, 131, 131, 131, 130, 130, + 130, 130, 130, 130, 129, 129, 129, 129, + 129, 129, 129, 129, 128, 128, 128, 128, +}; + +static unsigned char linear_ulaw[] = { + 31, 31, 31, 32, 32, 32, 32, 33, + 33, 33, 33, 34, 34, 34, 34, 35, + 35, 35, 35, 36, 36, 36, 36, 37, + 37, 37, 37, 38, 38, 38, 38, 39, + 39, 39, 39, 40, 40, 40, 40, 41, + 41, 41, 41, 42, 42, 42, 42, 43, + 43, 43, 43, 44, 44, 44, 44, 45, + 45, 45, 45, 46, 46, 46, 46, 47, + 47, 47, 47, 48, 48, 49, 49, 50, + 50, 51, 51, 52, 52, 53, 53, 54, + 54, 55, 55, 56, 56, 57, 57, 58, + 58, 59, 59, 60, 60, 61, 61, 62, + 62, 63, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 81, 83, 85, 87, 89, + 91, 93, 95, 99, 103, 107, 111, 119, + 255, 247, 239, 235, 231, 227, 223, 221, + 219, 217, 215, 213, 211, 209, 207, 206, + 205, 204, 203, 202, 201, 200, 199, 198, + 197, 196, 195, 194, 193, 192, 191, 191, + 190, 190, 189, 189, 188, 188, 187, 187, + 186, 186, 185, 185, 184, 184, 183, 183, + 182, 182, 181, 181, 180, 180, 179, 179, + 178, 178, 177, 177, 176, 176, 175, 175, + 175, 175, 174, 174, 174, 174, 173, 173, + 173, 173, 172, 172, 172, 172, 171, 171, + 171, 171, 170, 170, 170, 170, 169, 169, + 169, 169, 168, 168, 168, 168, 167, 167, + 167, 167, 166, 166, 166, 166, 165, 165, + 165, 165, 164, 164, 164, 164, 163, 163, + 163, 163, 162, 162, 162, 162, 161, 161, + 161, 161, 160, 160, 160, 160, 159, 159, +}; + +static unsigned char alaw_linear[] = { + 45, 214, 122, 133, 0, 255, 107, 149, + 86, 171, 126, 129, 0, 255, 117, 138, + 13, 246, 120, 135, 0, 255, 99, 157, + 70, 187, 124, 131, 0, 255, 113, 142, + 61, 198, 123, 132, 0, 255, 111, 145, + 94, 163, 127, 128, 0, 255, 119, 136, + 29, 230, 121, 134, 0, 255, 103, 153, + 78, 179, 125, 130, 0, 255, 115, 140, + 37, 222, 122, 133, 0, 255, 105, 151, + 82, 175, 126, 129, 0, 255, 116, 139, + 5, 254, 120, 135, 0, 255, 97, 159, + 66, 191, 124, 131, 0, 255, 112, 143, + 53, 206, 123, 132, 0, 255, 109, 147, + 90, 167, 127, 128, 0, 255, 118, 137, + 21, 238, 121, 134, 0, 255, 101, 155, + 74, 183, 125, 130, 0, 255, 114, 141, + 49, 210, 123, 133, 0, 255, 108, 148, + 88, 169, 127, 129, 0, 255, 118, 138, + 17, 242, 121, 135, 0, 255, 100, 156, + 72, 185, 125, 131, 0, 255, 114, 142, + 64, 194, 124, 132, 0, 255, 112, 144, + 96, 161, 128, 128, 1, 255, 120, 136, + 33, 226, 122, 134, 0, 255, 104, 152, + 80, 177, 126, 130, 0, 255, 116, 140, + 41, 218, 122, 133, 0, 255, 106, 150, + 84, 173, 126, 129, 0, 255, 117, 139, + 9, 250, 120, 135, 0, 255, 98, 158, + 68, 189, 124, 131, 0, 255, 113, 143, + 57, 202, 123, 132, 0, 255, 110, 146, + 92, 165, 127, 128, 0, 255, 119, 137, + 25, 234, 121, 134, 0, 255, 102, 154, + 76, 181, 125, 130, 0, 255, 115, 141, + +}; + + +static unsigned char linear_alaw[] = { + + 252, 172, 172, 172, 172, 80, 80, 80, + 80, 208, 208, 208, 208, 16, 16, 16, + 16, 144, 144, 144, 144, 112, 112, 112, + 112, 240, 240, 240, 240, 48, 48, 48, + 48, 176, 176, 176, 176, 64, 64, 64, + 64, 192, 192, 192, 192, 0, 0, 0, + 0, 128, 128, 128, 128, 96, 96, 96, + 96, 224, 224, 224, 224, 32, 32, 32, + 160, 160, 88, 88, 216, 216, 24, 24, + 152, 152, 120, 120, 248, 248, 56, 56, + 184, 184, 72, 72, 200, 200, 8, 8, + 136, 136, 104, 104, 232, 232, 40, 40, + 168, 86, 214, 22, 150, 118, 246, 54, + 182, 70, 198, 6, 134, 102, 230, 38, + 166, 222, 158, 254, 190, 206, 142, 238, + 210, 242, 194, 226, 218, 250, 202, 234, + 235, 203, 251, 219, 227, 195, 243, 211, + 175, 239, 143, 207, 191, 255, 159, 223, + 167, 39, 231, 103, 135, 7, 199, 71, + 183, 55, 247, 119, 151, 23, 215, 87, + 87, 169, 169, 41, 41, 233, 233, 105, + 105, 137, 137, 9, 9, 201, 201, 73, + 73, 185, 185, 57, 57, 249, 249, 121, + 121, 153, 153, 25, 25, 217, 217, 89, + 89, 89, 161, 161, 161, 161, 33, 33, + 33, 33, 225, 225, 225, 225, 97, 97, + 97, 97, 129, 129, 129, 129, 1, 1, + 1, 1, 193, 193, 193, 193, 65, 65, + 65, 65, 177, 177, 177, 177, 49, 49, + 49, 49, 241, 241, 241, 241, 113, 113, + 113, 113, 145, 145, 145, 145, 17, 17, + 17, 17, 209, 209, 209, 209, 81, 253, +}; + +inline void translate_bytes(const void *table, void *buff, unsigned long n) +{ + __asm__("cld\n" + "1:\tlodsb\n\t" + "xlatb\n\t" + "stosb\n\t" + "loop 1b\n\t" + ::"b" ((long)table), "c" (n), "D" ((long)buff), "S" ((long)buff) + :"bx","cx","di","si","ax"); +} + +void translate_ansi(unsigned char table[], unsigned char buff[], unsigned long n) +{ +register counter; + +for(counter=0; counter< n; counter++) + buff[counter] = table[buff[counter]]; +} diff --git a/gnu/usr.sbin/isdn/ulaw2alaw/ulaw2alaw.c b/gnu/usr.sbin/isdn/ulaw2alaw/ulaw2alaw.c new file mode 100644 index 0000000..afa0f11 --- /dev/null +++ b/gnu/usr.sbin/isdn/ulaw2alaw/ulaw2alaw.c @@ -0,0 +1,15 @@ +#include <fcntl.h> +#include "con.h" + +main(int argc, char *argv[]) +{ + int counter; + unsigned char buffer[1024]; + + + while ((counter = read(0, buffer, sizeof(buffer))) > 0) { + translate_bytes(ulaw_linear, buffer, counter); /* now linear */ + translate_bytes(linear_alaw, buffer, counter); /* now alaw */ + counter != write(1, buffer, counter); + } +} |