Added loopctrl utility.

This commit is contained in:
fritz 1997-03-24 23:38:37 +00:00
parent b187e7ac01
commit 6e5ac8916f
9 changed files with 1955 additions and 18 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.11 1997/03/24 04:00:04 fritz Exp $
# $Id: Makefile,v 1.12 1997/03/24 23:38:37 fritz Exp $
#
# Toplevel Makefile for isdn4k-utils
#
@ -44,6 +44,9 @@ endif
ifeq ($(CONFIG_AVMCAPICTRL),y)
SUBDIRS := $(SUBDIRS) avmb1
endif
ifeq ($(CONFIG_LOOPCTRL),y)
SUBDIRS := $(SUBDIRS) loop
endif
ifeq ($(CONFIG_IMON),y)
SUBDIRS := $(SUBDIRS) imon
endif

47
README
View File

@ -1,22 +1,40 @@
#
# $Id: README,v 1.3 1997/03/02 19:41:57 fritz Exp $
# $Id: README,v 1.4 1997/03/24 23:38:38 fritz Exp $
#
This is the README file for the "isdn4k-utils" package from "The i4l-crew".
This package contains the following stuff:
isdnctrl, general link-level setup utility.
icnctrl, setup utility for the icn driver.
telesctrl, setup utility for the teles driver.
hisaxctrl, setup utility for the HiSax driver.
pcbitctl, setup utility for the pcbit driver.
imon, a ncurses based utility for monitoring ISDN-activities.
imontty, a tty based utility for monitoring ISDN-activities.
isdnlog, a set of utilities for connection logging.
xmonisdn, a utility for monitoring and controlling ISDN-activity.
xisdnload, an xload-like meter.
isdnmon, a Tcl/Tk based utility for monitoring ISDN-activities.
1. Runtime configuration tools:
isdnctrl, general link-level setup utility.
iprofd, daemon for realizing AT&W0 on ttyI's.
icnctrl, setup utility for the icn driver.
telesctrl, setup utility for the teles driver.
hisaxctrl, setup utility for the HiSax driver.
pcbitctl, setup utility for the pcbit driver.
avmcapictrl setup utility for the avmb1 driver.
2. Tools for monitoring activity:
imon, a ncurses based utility for monitoring ISDN-activities.
imontty, a tty based utility for monitoring ISDN-activities.
isdnlog, a set of utilities for connection logging.
ipppstats a utility for showing syncPPP statistics.
xisdnload, an xload-like meter.
xmonisdn, a utility for monitoring and controlling ISDN-activity.
isdnmon, a Tcl/Tk based utility for monitoring ISDN-activities.
3. Applications:
vbox, an answering machine/voice mailbox.
ipppd, daemon need for syncPPP and MPP.
4. Documentation:
A very detailed FAQ and the generic manpages ttyI.4, isdninfo.4,
isdn_audio.4 and isdn_cause.7.
Manpages for the above utilities:
avmcapictrl.8, hisaxctrl.8 icnctrl.8, imon.8, ipppd.8, ipppstats.8,
iprofd.8, isdnctrl.8, isdnlog.8, isdnrep.1, telesctrl.8, xisdnload.1x
and xmonisdn.1x
System prerequisites:
To use this package, you need a kernel with an ISDN-subsystem configured.
@ -70,8 +88,7 @@ System prerequisites:
Documentation/isdn subdirectory of your kernel-source-tree for
more information on configuring Lowlevel drivers.
For the utilities "isdnctrl", "icnctrl" "telesctrl" and "imon" refer to
the man pages. For the other contributed utilities, look into their
For the utilities refer to the man pages or look into their
subdirectories for Documentation.
For tips, troubleshooting etc. look into the FAQ subdirectory

72
loop/Makefile.in Normal file
View File

@ -0,0 +1,72 @@
# $Id: Makefile.in,v 1.1 1997/03/24 23:38:43 fritz Exp $
#
# Makefile for loopctrl
# (C) 1997 Fritz Elfert
#
#
SHELL = /bin/sh
CFLAGS = -Wall -O2
INCLUDES = -I. @DEBUGVAR@
DEFS =
LDFLAGS = -L../lib @LIBS@
PROGRAM = loopctrl
MODULES = loopctrl.o
MANPAGE = loopctrl.8
INSTALL = @INSTALL@
INSTALL_PROGRAM = $(INSTALL) -o 0 -g 0 -m 0750
INSTALL_MAN = $(INSTALL) -o 0 -g 0 -m 0644
prefix = @prefix@
exec_prefix = @exec_prefix@
ifeq (../.config,$(wildcard ../.config))
include ../.config
INCLUDES += -I$(shell eval echo $(CONFIG_LOOPCTRL_LOOPDIR))
ifeq ($(CONFIG_LOOPCTRL_DEBUG),y)
DEFS += -DDEBUGVAR
endif
SBINDIR = $(CONFIG_SBINDIR)
mandir = $(CONFIG_MANDIR)
else
SBINDIR = /sbin
mandir = @mandir@
endif
MAN8DIR = $(mandir)/man8
CC = @CC@
.SUFFIXES:
.SUFFIXES: .c .o
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEFS) -c -o $@ $<
all: $(PROGRAM)
config:
@./configure
Makefile: Makefile.in config.status
./config.status
config.status: configure
./config.status --recheck
$(PROGRAM): $(MODULES)
$(CC) $(CFLAGS) $(INCLUDES) $(DEFS) $? $(LDFLAGS) -o $@
install-man: $(PROGRAM).man
mkdir -p $(MAN8DIR)
$(INSTALL_MAN) $< $(MAN8DIR)/$(MANPAGE)
install: $(PROGRAM) install-man
$(INSTALL_PROGRAM) $(PROGRAM) $(SBINDIR)/$(PROGRAM)
install-strip: $(PROGRAM)
$(INSTALL_PROGRAM) -s $(PROGRAM) $(SBINDIR)/$(PROGRAM)
uninstall:
rm -f $(SBINDIR)/$(PROGRAM) $(MAN8DIR)/$(MANPAGE)
clean:
rm -f *.o *~ $(PROGRAM)
distclean: clean
rm -f config.status config.cache config.log Makefile loopctrl.man

1404
loop/configure vendored Executable file

File diff suppressed because it is too large Load Diff

44
loop/configure.in Normal file
View File

@ -0,0 +1,44 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(loopctrl.c)
AC_PREFIX_DEFAULT(/usr)
I4LCONFDIR=${I4LCONFDIR:-"/etc/isdn"}
I4LVERSION=${I4LVERSION:-"?.?"}
MANDATE=`grep CHECKIN loopctrl.man.in | awk '{print $4}'`
dnl Checks for programs.
AC_PROG_INSTALL
AC_PROG_CC
dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h sys/ioctl.h unistd.h)
dnl Find current kernel source
dnl done by dereferencing the symbolic link /usr/include/linux
dnl and then stripping off include/linux from the result.
AC_CHECK_HEADERS(linux/isdn.h,\
KERNELDIR="/usr/include/`find /usr/include/linux -maxdepth 0 -printf '%l\n' | sed -e s@include/linux@@`", \
AC_MSG_ERROR("Missing linux/isdn.h. Kernel source installed?"))
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MMAP
dnl Check, if user wants dump option for debugging
AC_ARG_ENABLE(dump,--enable-dump Enable dump feature for debugging,\
DEBUGVAR=-D__DEBUGVAR__)
AC_SUBST(INSTALL)
AC_SUBST(KERNELDIR)
AC_SUBST(DEBUGVAR)
AC_SUBST(MANDATE)
AC_SUBST(I4LCONFDIR)
AC_SUBST(I4LVERSION)
AC_OUTPUT(Makefile loopctrl.man)

2
loop/install-sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exit 0

262
loop/loopctrl.c Normal file
View File

@ -0,0 +1,262 @@
/* $Id: loopctrl.c,v 1.1 1997/03/24 23:38:46 fritz Exp $
* loop-ISDN driver for Linux. (Control-Utility)
*
* Copyright 1994,95 by Fritz Elfert (fritz@wuemaus.franken.de)
*
* This file is part of Isdn4Linux.
*
* Isdn4Linux is distributed with NO WARRANTY OF ANY KIND. No author
* or distributor accepts any responsibility for the consequences of using it,
* or for whether it serves any particular purpose or works at all, unless he
* or she says so in writing. Refer to the Isdn4Linux Free Public
* License (the "License") for full details.
*
* Every copy of Isdn4Linux must include a copy of the License,
* normally in a plain ASCII text file named LICENSE. The License grants you
* the right to copy, modify and redistribute Isdn4Linux, but only
* under certain conditions described in the License. Among other things, the
* License requires that the copyright notice and this notice be preserved on
* all copies.
*
* $Log: loopctrl.c,v $
* Revision 1.1 1997/03/24 23:38:46 fritz
* Added loopctrl utility.
*
*/
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <linux/isdn.h>
#include <linux/isdnif.h>
#ifdef __DEBUGVAR__
#define __KERNEL__
#endif
#include <isdnloop.h>
#ifdef __DEBUGVAR__
typedef struct dbgstruct {
ulong card;
ulong dev;
} dbgstruct;
dbgstruct dbg;
#endif
int mem_fd;
char *cmd;
char *ctrldev;
int arg_ofs;
#if 0
/* #ifdef _POSIX_MAPPED_FILES */
#define DO_VIA_MMAP
#else
#include <malloc.h>
#endif
void
usage()
{
fprintf(stderr, "usage: %s [-d Id] add [Id] (Add a new card\n", cmd);
#ifdef __DEBUGVAR__
fprintf(stderr, " or: %s [-d Id] dump (dump driver data)\n", cmd);
#endif
fprintf(stderr, " or: %s [-d Id] start <1tr6|dss1> n1 [n2 n3] (start driver)\n", cmd);
fprintf(stderr, " or: %s [-d Id] leased <on|off> (Switch interface,\n",cmd);
fprintf(stderr, " Channel n\n");
fprintf(stderr, " into Leased-Line-Mode)\n");
exit(-1);
}
#ifdef __DEBUGVAR__
u_char *
mapmem(ulong where, long size)
{
u_char *addr;
#ifdef DO_VIA_MMAP
ulong realw;
long ofs;
#endif
if ((mem_fd = open("/dev/mem", O_RDWR)) < 0) {
perror("open /dev/mem");
exit(1);
}
#ifdef DO_VIA_MMAP
size = ((size / PAGE_SIZE) + 2) * PAGE_SIZE;
realw = PAGE_ALIGN(where) - PAGE_SIZE;
ofs = where - realw;
printf("%08lx - %08lx = %08x\n", where, realw, ofs);
addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED,
mem_fd, realw);
if ((int) addr < 0) {
perror("mmap");
exit(1);
}
return (addr + ofs);
#else
addr = malloc(size);
lseek(mem_fd, where, SEEK_SET);
read(mem_fd, addr, size);
return addr;
#endif
}
void
qdump(ulong queue)
{
struct sk_buff_head *p;
p = (struct sk_buff_head *) mapmem(queue, sizeof(struct sk_buff_head));
printf(" len: %d\n", p->qlen);
}
void
dump_card(icn_card * p)
{
printf("card struct at: %p\n", p);
printf("phys. card struct at: 0x%08lx\n", dbg.card);
printf("next: %p\n", p->next);
printf("other: %p\n", p->other);
printf("port: 0x%04x\n", p->port);
printf("myid: %d\n", p->myid);
printf("rvalid: %d\n", p->rvalid);
printf("leased: %d\n", p->leased);
printf("flags: 0x%04x\n", p->flags);
printf("doubleS0: %d\n", p->doubleS0);
printf("secondhalf: %d\n", p->secondhalf);
printf("fw_rev: %d\n", p->fw_rev);
printf("ptype: %d\n", p->ptype);
printf("st_timer\n");
printf("rb_timer\n");
printf("rcvbuf\n");
printf("rcvidx[0]: %d\n", p->rcvidx[0]);
printf("rcvidx[1]: %d\n", p->rcvidx[1]);
printf("l2_proto[0] %d\n", p->l2_proto[0]);
printf("l2_proto[1] %d\n", p->l2_proto[1]);
printf("interface:\n");
printf("iptr: %d\n", p->iptr);
printf("imsg: %s\n", p->imsg);
printf("msg_buf: %p\n", p->msg_buf);
printf("msg_buf_write: %p\n", p->msg_buf_write);
printf("msg_buf_read: %p\n", p->msg_buf_read);
printf("msg_buf_end: %p\n", p->msg_buf_end);
printf("sndcount[0]: %d\n", p->sndcount[0]);
printf("sndcount[1]: %d\n", p->sndcount[1]);
printf("spqueue[0]: %p\n", &p->spqueue[0]);
qdump((ulong) & p->spqueue[0]);
printf("spqueue[1]: %p\n", &p->spqueue[1]);
qdump((ulong) & p->spqueue[1]);
printf("regname: %s\n", p->regname);
printf("xmit_lock[0]: %d\n", p->xmit_lock[0]);
printf("xmit_lock[1]: %d\n", p->xmit_lock[1]);
}
#endif
int
main(int argc, char **argv)
{
int fd;
int ac;
isdn_ioctl_struct ioctl_s;
isdnloop_cdef newcard;
isdnloop_sdef startparm;
cmd = strrchr(argv[0], '/');
cmd = (cmd == NULL) ? argv[0] : ++cmd;
if (argc > 1) {
if (!strcmp(argv[1], "-d")) {
strcpy(ioctl_s.drvid, argv[2]);
arg_ofs = 3;
} else {
ioctl_s.drvid[0] = '\0';
arg_ofs = 1;
}
} else
usage();
ac = argc - (arg_ofs - 1);
fd = open("/dev/isdnctrl", O_RDWR);
if (fd < 0) {
perror(ctrldev);
exit(-1);
}
#ifdef __DEBUGVAR__
if (!strcmp(argv[arg_ofs], "dump")) {
char *p;
ioctl_s.arg = (ulong) & dbg;
if ((ioctl(fd, ISDNLOOP_IOCTL_DEBUGVAR + IIOCDRVCTL, &ioctl_s)) < 0) {
perror("ioctl DEBUGVAR");
exit(-1);
}
close(fd);
p = mapmem(dbg.dev, sizeof(icn_dev));
dump_dev((icn_dev *) p);
p = mapmem(dbg.card, sizeof(icn_card));
dump_card((icn_card *) p);
return 0;
}
#endif
if (!strcmp(argv[arg_ofs], "leased")) {
if (ac == 3) {
ioctl_s.arg = 0;
if ((!strcmp(argv[arg_ofs + 1], "on")) ||
(!strcmp(argv[arg_ofs + 1], "yes")))
ioctl_s.arg = 1;
if ((ioctl(fd, ISDNLOOP_IOCTL_LEASEDCFG + IIOCDRVCTL, &ioctl_s)) < 0) {
perror("ioctl LEASEDCFG");
exit(-1);
}
close(fd);
return 0;
}
}
if (!strcmp(argv[arg_ofs], "add")) {
if (ac >= 2) {
ioctl_s.arg = (unsigned long) &newcard;
newcard.id1[0] = 0;
strncpy(newcard.id1, argv[arg_ofs + 1], sizeof(newcard.id1) - 1);
if ((ioctl(fd, ISDNLOOP_IOCTL_ADDCARD + IIOCDRVCTL, &ioctl_s)) < 0) {
perror("ioctl ADDCARD");
exit(-1);
}
close(fd);
return 0;
}
}
if (!strcmp(argv[arg_ofs], "start")) {
int needed = 99;
if (ac > 2) {
if (!(strcmp(argv[arg_ofs + 1], "1tr6"))) {
needed = 4;
startparm.ptype = ISDN_PTYPE_1TR6;
}
if (!(strcmp(argv[arg_ofs + 1], "dss1"))) {
needed = 6;
startparm.ptype = ISDN_PTYPE_EURO;
}
if (ac >= needed) {
strcpy(startparm.num[0], argv[arg_ofs + 2]);
if (needed > 4) {
strcpy(startparm.num[1], argv[arg_ofs + 3]);
strcpy(startparm.num[2], argv[arg_ofs + 4]);
}
ioctl_s.arg = (unsigned long) &startparm;
if (ioctl(fd, ISDNLOOP_IOCTL_STARTUP + IIOCDRVCTL, &ioctl_s) < 0) {
perror("\nioctl STARTUP");
exit(-1);
}
printf("done\n");
close(fd);
return 0;
}
}
usage();
}
usage();
return 0;
}

128
loop/loopctrl.man.in Normal file
View File

@ -0,0 +1,128 @@
.\" $Id: loopctrl.man.in,v 1.1 1997/03/24 23:38:46 fritz Exp $
.\"
.\" CHECKIN $Date: 1997/03/24 23:38:46 $
.\"
.\" Process this file with
.\" groff -man -Tascii icnctrl.1 for ASCII output, or
.\" groff -man -Tps loopctrl.1 for PostScript output
.\"
.TH LOOPCTRL 8 "@MANDATE@" isdn4k-utils-@I4LVERSION@ "Linux System Administration"
.SH NAME
loopctrl \- configure isdnloop ISDN driver
.SH SYNOPSIS
.B loopctrl [-d
.IB Driver-Id ]
.I action options
.B ...
.SH DESCRIPTION
.B loopctrl
is used to setup the isdnloop
.SM ISDN
driver.
.LP
.SH OPTIONS
.TP
.BI "-d " Driver-Id
selects the virtual S0 interface named by
.IR Driver-Id .
Driver-Ids are defined during driver initialisation. See
.BR isdnloop (4)
for a description of the syntax to be used for modularised and
monolithic driver versions.
This option
.B must
be used to identify the virtual S0 interface if more than one S0 interface is
existent. If a single virtual S0 interface is used, it may be omitted.
If using more than one virtual card, support for the other cards is enabled
with the
.B add
action of loopctrl. Ids may
.B not
start with
.B digits
or small
.BR x ,
because these values are misinterpreted
as numeric parameters by
.BR insmod .
For loading the module, always the
newest
.B modutils
package should be used to avoid problems during load.
.LP
The following
.I actions
may be given to
.BR loopctrl .
.TP
.BI "add [" id ]
enables support for an additional virtual card in the driver. If
.I id
is missing, adds a card with an id given by the system. with
.I id
given, adds a card with an Id given by the user. Ids are
checked against conflicts, and if a conflict happens, replaced by the
system in the same manner as if no Id was supplied.
.TP
.B leased on|off
switches between normal (dialup) and leased-line mode. Leased-line mode
is intended for usage with S64K-lines or - if both channels are used -
for S02. These lines do not have a D-channel. When leased-line mode is
enabled, the driver simulates incoming calls using special "phone-numbers"
for calling and called address which are generated as follows:
.ie 1
.RS
Calling number:
.RS
.BI LEASED x
.RS
where
.I x
is the internal slot-number of the S0 interface. This number starts with
.I 0
for the first S0 interface and is incremented by one for every S0 interface
configured using the
.B add
action.
.RE
.RE
.ie 1
Called number:
.RS
.I x
.RS
where
.I x
is equal to the channel number of the calling S0 interface starting with
.IR 1 .
.RE
.RE
.RE
.TP
.BI "start " protocol " " phone1 " [" "phone2 phone3" ]
starts the driver with the given D-channel protocol. If
.I protocol
.RB "is " 1tr6 ,
.RI only " phone1"
has to be given. It is meant to be the base number of the virtual
S0 interface to which the EAZ is appended. If
.I protocol
.RB "is " dss1 ,
.IR "phone1, phone2 " and " phone3
have to be given and represent the three MSNs of the virtual
S0 interface.
.TP
.B dump
is available if the program is configured using the
.B --enable-dump
option only. The contents of internal driver variables is dumped on stdout.
.SH BUGS
This program and the isdnloop driver are
.B ALPHA
code. The main intention for this driver is for testing the link level
and applications.
.SH AUTHOR
\(co 1997 by Fritz Elfert <fritz@wuemaus.franken.de>
.LP
.SH SEE ALSO
.BR isdnctrl "(8), " isdnloop "(4), " isdninfo "(4), " isdnctrl "(4), " ttyI (4).

View File

@ -1,5 +1,5 @@
#
# $Id: config.in,v 1.11 1997/03/24 01:39:06 fritz Exp $
# $Id: config.in,v 1.12 1997/03/24 23:38:52 fritz Exp $
#
# The whole configuration stuff is borrowed from the kernel
# configuration.
@ -57,10 +57,15 @@ bool 'telesctrl' CONFIG_TELESCTRL
bool 'hisaxctrl' CONFIG_HISAXCTRL
bool 'icnctrl' CONFIG_ICNCTRL
if [ "$CONFIG_ICNCTRL" = "y" ]; then
bool 'Enable icnctl debug-option' CONFIG_ICNCTRL_DEBUG
bool 'Enable icnctrl debug-option' CONFIG_ICNCTRL_DEBUG
fi
bool 'pcbitctl' CONFIG_PCBITCTL
bool 'avmcapictrl' CONFIG_AVMCAPICTRL
bool 'loopctrl' CONFIG_LOOPCTRL
if [ "$CONFIG_LOOPCTRL" = "y" ]; then
string 'Sourcedir of isdnloop module' CONFIG_LOOPCTRL_LOOPDIR '\~/isdn/drivers/isdn/isdnloop'
bool 'Enable loopctrl debug-option' CONFIG_LOOPCTRL_DEBUG
fi
endmenu
mainmenu_option nextcomment
comment 'Tools for monitoring activity'