summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>1999-01-21 00:55:32 +0000
committercvs2svn <cvs2svn@FreeBSD.org>1999-01-21 00:55:32 +0000
commit76b5366091f76c9bc73570149ef5055648fc2c39 (patch)
tree590d020e0f2a5bea6e09d66d951a674443b21d67 /usr.sbin
parent4b4d01da6f07f7754ff6a6e4f5223e9f0984d1a6 (diff)
This commit was manufactured by cvs2svn to create tagrelease/3.0.0
'RELENG_3_0_0_RELEASE'.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/Makefile70
-rw-r--r--usr.sbin/adduser/adduser.perl3
-rw-r--r--usr.sbin/amd/amd/Makefile6
-rw-r--r--usr.sbin/amd/fixmount/Makefile6
-rw-r--r--usr.sbin/amd/hlfsd/Makefile6
-rw-r--r--usr.sbin/amd/include/config.h4
-rw-r--r--usr.sbin/atm/atmarpd/atmarpd.86
-rw-r--r--usr.sbin/config/configvers.h4
-rw-r--r--usr.sbin/config/lang.l6
-rw-r--r--usr.sbin/config/main.c4
-rw-r--r--usr.sbin/config/mkioconf.c78
-rw-r--r--usr.sbin/cron/cron/cron.c44
-rw-r--r--usr.sbin/cron/lib/misc.c9
-rw-r--r--usr.sbin/ctm/mkCTM/mkCTM2
-rw-r--r--usr.sbin/edquota/edquota.c10
-rw-r--r--usr.sbin/i4b/Makefile4
-rw-r--r--usr.sbin/i4b/Makefile.inc14
-rw-r--r--usr.sbin/i4b/alawulaw/Makefile7
-rw-r--r--usr.sbin/i4b/alawulaw/alaw2ulaw.170
-rw-r--r--usr.sbin/i4b/alawulaw/alaw2ulaw.c151
-rw-r--r--usr.sbin/i4b/alawulaw/ulaw2alaw.170
-rw-r--r--usr.sbin/i4b/isdnd/Makefile34
-rw-r--r--usr.sbin/i4b/isdnd/alias.c191
-rw-r--r--usr.sbin/i4b/isdnd/config.h61
-rw-r--r--usr.sbin/i4b/isdnd/controller.c329
-rw-r--r--usr.sbin/i4b/isdnd/curses.c633
-rw-r--r--usr.sbin/i4b/isdnd/dial.c153
-rw-r--r--usr.sbin/i4b/isdnd/exec.c280
-rw-r--r--usr.sbin/i4b/isdnd/fsm.c446
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.8419
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.acct.5108
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.h754
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.rates.5115
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.rc.5642
-rw-r--r--usr.sbin/i4b/isdnd/log.c242
-rw-r--r--usr.sbin/i4b/isdnd/main.c707
-rw-r--r--usr.sbin/i4b/isdnd/monitor.c811
-rw-r--r--usr.sbin/i4b/isdnd/msghdl.c983
-rw-r--r--usr.sbin/i4b/isdnd/pathnames.h54
-rw-r--r--usr.sbin/i4b/isdnd/pcause.c227
-rw-r--r--usr.sbin/i4b/isdnd/process.c219
-rw-r--r--usr.sbin/i4b/isdnd/rates.c473
-rw-r--r--usr.sbin/i4b/isdnd/rc_config.c1140
-rw-r--r--usr.sbin/i4b/isdnd/rc_parse.y388
-rw-r--r--usr.sbin/i4b/isdnd/rc_scan.l170
-rw-r--r--usr.sbin/i4b/isdnd/support.c831
-rw-r--r--usr.sbin/i4b/isdnd/timer.c411
-rw-r--r--usr.sbin/i4b/isdnd/vararray.h120
-rw-r--r--usr.sbin/i4b/isdndebug/Makefile5
-rw-r--r--usr.sbin/i4b/isdndebug/isdndebug.8102
-rw-r--r--usr.sbin/i4b/isdndebug/main.c553
-rw-r--r--usr.sbin/i4b/isdndecode/Makefile7
-rw-r--r--usr.sbin/i4b/isdndecode/decode.h74
-rw-r--r--usr.sbin/i4b/isdndecode/facility.c906
-rw-r--r--usr.sbin/i4b/isdndecode/facility.h154
-rw-r--r--usr.sbin/i4b/isdndecode/isdndecode.8190
-rw-r--r--usr.sbin/i4b/isdndecode/layer1.c80
-rw-r--r--usr.sbin/i4b/isdndecode/layer2.c298
-rw-r--r--usr.sbin/i4b/isdndecode/layer3.c508
-rw-r--r--usr.sbin/i4b/isdndecode/layer3_subr.c1045
-rw-r--r--usr.sbin/i4b/isdndecode/main.c774
-rw-r--r--usr.sbin/i4b/isdndecode/pcause.c328
-rw-r--r--usr.sbin/i4b/isdndecode/pcause.h109
-rw-r--r--usr.sbin/i4b/isdnmonitor/Makefile8
-rw-r--r--usr.sbin/i4b/isdnmonitor/isdnmonitor.840
-rw-r--r--usr.sbin/i4b/isdnmonitor/main.c675
-rw-r--r--usr.sbin/i4b/isdnmonitor/monitor.h263
-rw-r--r--usr.sbin/i4b/isdntel/Makefile9
-rw-r--r--usr.sbin/i4b/isdntel/alias.c139
-rw-r--r--usr.sbin/i4b/isdntel/alias.h49
-rw-r--r--usr.sbin/i4b/isdntel/defs.h156
-rw-r--r--usr.sbin/i4b/isdntel/display.c252
-rw-r--r--usr.sbin/i4b/isdntel/files.c306
-rw-r--r--usr.sbin/i4b/isdntel/isdntel.894
-rw-r--r--usr.sbin/i4b/isdntel/main.c395
-rw-r--r--usr.sbin/i4b/isdntelctl/Makefile5
-rw-r--r--usr.sbin/i4b/isdntelctl/isdntelctl.878
-rw-r--r--usr.sbin/i4b/isdntelctl/main.c203
-rw-r--r--usr.sbin/i4b/isdntest/Makefile8
-rw-r--r--usr.sbin/i4b/isdntest/isdntest.8103
-rw-r--r--usr.sbin/i4b/isdntest/main.c738
-rw-r--r--usr.sbin/i4b/isdntrace/1tr6.c754
-rw-r--r--usr.sbin/i4b/isdntrace/Makefile8
-rw-r--r--usr.sbin/i4b/isdntrace/cable.txt60
-rw-r--r--usr.sbin/i4b/isdntrace/isdntrace.8205
-rw-r--r--usr.sbin/i4b/isdntrace/pcause_1tr6.c164
-rw-r--r--usr.sbin/i4b/isdntrace/pcause_1tr6.h68
-rw-r--r--usr.sbin/i4b/isdntrace/pcause_q850.c328
-rw-r--r--usr.sbin/i4b/isdntrace/pcause_q850.h109
-rw-r--r--usr.sbin/i4b/isdntrace/q921.c275
-rw-r--r--usr.sbin/i4b/isdntrace/q931.c783
-rw-r--r--usr.sbin/i4b/isdntrace/q931_util.c697
-rw-r--r--usr.sbin/i4b/isdntrace/q932_fac.c926
-rw-r--r--usr.sbin/i4b/isdntrace/q932_fac.h174
-rw-r--r--usr.sbin/i4b/isdntrace/trace.c809
-rw-r--r--usr.sbin/i4b/isdntrace/trace.h90
-rw-r--r--usr.sbin/i4b/man/Makefile5
-rw-r--r--usr.sbin/i4b/man/daic.498
-rw-r--r--usr.sbin/i4b/man/i4b.4108
-rw-r--r--usr.sbin/i4b/man/i4bctl.450
-rw-r--r--usr.sbin/i4b/man/i4bipr.498
-rw-r--r--usr.sbin/i4b/man/i4bisppp.4107
-rw-r--r--usr.sbin/i4b/man/i4bq921.449
-rw-r--r--usr.sbin/i4b/man/i4bq931.449
-rw-r--r--usr.sbin/i4b/man/i4brbch.450
-rw-r--r--usr.sbin/i4b/man/i4btel.452
-rw-r--r--usr.sbin/i4b/man/i4btrc.452
-rw-r--r--usr.sbin/i4b/man/isic.4380
-rw-r--r--usr.sbin/inetd/inetd.c130
-rw-r--r--usr.sbin/kbdcontrol/kbdcontrol.14
-rw-r--r--usr.sbin/kbdcontrol/kbdcontrol.c125
-rw-r--r--usr.sbin/kvm_mkdb/nlist.c71
-rw-r--r--usr.sbin/lpr/lpr/lpr.c12
-rw-r--r--usr.sbin/lptcontrol/lptcontrol.c10
-rw-r--r--usr.sbin/moused/moused.814
-rw-r--r--usr.sbin/moused/moused.c174
-rw-r--r--usr.sbin/mrouted/RELEASE191
-rw-r--r--usr.sbin/mrouted/VERSION1
-rw-r--r--usr.sbin/mrouted/callout.c154
-rw-r--r--usr.sbin/mrouted/cfparse.y441
-rw-r--r--usr.sbin/mrouted/config.c66
-rw-r--r--usr.sbin/mrouted/defs.h293
-rw-r--r--usr.sbin/mrouted/dvmrp.h20
-rw-r--r--usr.sbin/mrouted/icmp.c225
-rw-r--r--usr.sbin/mrouted/igmp.c266
-rw-r--r--usr.sbin/mrouted/igmpv2.h42
-rw-r--r--usr.sbin/mrouted/inet.c5
-rw-r--r--usr.sbin/mrouted/ipip.c145
-rw-r--r--usr.sbin/mrouted/kern.c117
-rw-r--r--usr.sbin/mrouted/main.c689
-rw-r--r--usr.sbin/mrouted/mapper.c6
-rw-r--r--usr.sbin/mrouted/mrinfo.c21
-rw-r--r--usr.sbin/mrouted/mrouted.8359
-rw-r--r--usr.sbin/mrouted/mrouted.conf3
-rw-r--r--usr.sbin/mrouted/mrouted/Makefile10
-rw-r--r--usr.sbin/mrouted/mtrace.84
-rw-r--r--usr.sbin/mrouted/mtrace.c965
-rw-r--r--usr.sbin/mrouted/mtrace.h34
-rw-r--r--usr.sbin/mrouted/pathnames.h3
-rw-r--r--usr.sbin/mrouted/prune.c1270
-rw-r--r--usr.sbin/mrouted/prune.h15
-rw-r--r--usr.sbin/mrouted/route.c889
-rw-r--r--usr.sbin/mrouted/route.h12
-rw-r--r--usr.sbin/mrouted/rsrr.c90
-rw-r--r--usr.sbin/mrouted/vif.c896
-rw-r--r--usr.sbin/mrouted/vif.h200
-rw-r--r--usr.sbin/mtree/create.c15
-rw-r--r--usr.sbin/mtree/spec.c10
-rw-r--r--usr.sbin/newsyslog/newsyslog.c4
-rw-r--r--usr.sbin/pccard/Makefile4
-rw-r--r--usr.sbin/pccard/pccardd/cardd.c7
-rw-r--r--usr.sbin/pciconf/pciconf.818
-rw-r--r--usr.sbin/pciconf/pciconf.c10
-rw-r--r--usr.sbin/pcvt/Makefile.inc2
-rw-r--r--usr.sbin/pcvt/Misc/Etc/Makefile2
-rw-r--r--usr.sbin/pcvt/fonts/Makefile2
-rw-r--r--usr.sbin/pcvt/kbdio/kbdio.y7
-rw-r--r--usr.sbin/pcvt/kbdio/lex.l7
-rw-r--r--usr.sbin/pcvt/keycap/man5/keycap.52
-rw-r--r--usr.sbin/pcvt/set2061/compiler.h2
-rw-r--r--usr.sbin/pcvt/vgaio/Makefile2
-rw-r--r--usr.sbin/pcvt/vgaio/lex.l6
-rw-r--r--usr.sbin/pcvt/vgaio/vgaio.82
-rw-r--r--usr.sbin/pcvt/vgaio/vgaio.h3
-rw-r--r--usr.sbin/pcvt/vgaio/vgaio.y6
-rw-r--r--usr.sbin/periodic/periodic.84
-rw-r--r--usr.sbin/periodic/periodic.sh6
-rw-r--r--usr.sbin/pkg_install/add/extract.c4
-rw-r--r--usr.sbin/pkg_install/add/main.c52
-rw-r--r--usr.sbin/pkg_install/add/perform.c48
-rw-r--r--usr.sbin/pkg_install/add/pkg_add.183
-rw-r--r--usr.sbin/pkg_install/create/create.h4
-rw-r--r--usr.sbin/pkg_install/create/main.c23
-rw-r--r--usr.sbin/pkg_install/create/perform.c40
-rw-r--r--usr.sbin/pkg_install/create/pkg_create.153
-rw-r--r--usr.sbin/pkg_install/delete/perform.c76
-rw-r--r--usr.sbin/pkg_install/delete/pkg_delete.186
-rw-r--r--usr.sbin/pkg_install/info/perform.c6
-rw-r--r--usr.sbin/pkg_install/info/pkg_info.14
-rw-r--r--usr.sbin/pkg_install/lib/file.c6
-rw-r--r--usr.sbin/pkg_install/lib/lib.h4
-rw-r--r--usr.sbin/ppp/Makefile5
-rw-r--r--usr.sbin/ppp/README.changes3
-rw-r--r--usr.sbin/ppp/arp.c52
-rw-r--r--usr.sbin/ppp/auth.c4
-rw-r--r--usr.sbin/ppp/bundle.c200
-rw-r--r--usr.sbin/ppp/bundle.h30
-rw-r--r--usr.sbin/ppp/cbcp.c55
-rw-r--r--usr.sbin/ppp/chat.c3
-rw-r--r--usr.sbin/ppp/command.c511
-rw-r--r--usr.sbin/ppp/datalink.c30
-rw-r--r--usr.sbin/ppp/filter.c14
-rw-r--r--usr.sbin/ppp/filter.h4
-rw-r--r--usr.sbin/ppp/iface.c481
-rw-r--r--usr.sbin/ppp/iface.h60
-rw-r--r--usr.sbin/ppp/ip.c14
-rw-r--r--usr.sbin/ppp/ipcp.c305
-rw-r--r--usr.sbin/ppp/ipcp.h8
-rw-r--r--usr.sbin/ppp/lcp.c29
-rw-r--r--usr.sbin/ppp/main.c122
-rw-r--r--usr.sbin/ppp/modem.c25
-rw-r--r--usr.sbin/ppp/mp.c19
-rw-r--r--usr.sbin/ppp/physical.c9
-rw-r--r--usr.sbin/ppp/physical.h9
-rw-r--r--usr.sbin/ppp/ppp.8441
-rw-r--r--usr.sbin/ppp/route.c7
-rw-r--r--usr.sbin/ppp/systems.c44
-rw-r--r--usr.sbin/ppp/systems.h4
-rw-r--r--usr.sbin/ppp/timer.c85
-rw-r--r--usr.sbin/ppp/timer.h4
-rw-r--r--usr.sbin/ppp/tun.c5
-rw-r--r--usr.sbin/pw/README4
-rw-r--r--usr.sbin/pw/pw.c14
-rw-r--r--usr.sbin/pw/pw_user.c4
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.87
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c50
-rw-r--r--usr.sbin/quot/quot.c7
-rw-r--r--usr.sbin/rarpd/rarpd.c4
-rw-r--r--usr.sbin/rwhod/rwhod.827
-rw-r--r--usr.sbin/rwhod/rwhod.c18
-rw-r--r--usr.sbin/sendmail/Makefile7
-rw-r--r--usr.sbin/slstat/slstat.84
-rw-r--r--usr.sbin/stallion/bootcode/stl.48
-rw-r--r--usr.sbin/sysctl/sysctl.89
-rw-r--r--usr.sbin/sysctl/sysctl.c60
-rw-r--r--usr.sbin/syslogd/syslog.conf.516
-rw-r--r--usr.sbin/syslogd/syslogd.c35
-rw-r--r--usr.sbin/tcpdump/tcpslice/tcpslice.c12
-rw-r--r--usr.sbin/traceroute/Makefile8
-rw-r--r--usr.sbin/tzsetup/paths.h1
-rw-r--r--usr.sbin/tzsetup/tzsetup.c15
-rw-r--r--usr.sbin/usbd/Makefile7
-rw-r--r--usr.sbin/usbd/usbd.881
-rw-r--r--usr.sbin/usbd/usbd.c184
-rw-r--r--usr.sbin/usbdevs/Makefile8
-rw-r--r--usr.sbin/usbdevs/usbdevs.868
-rw-r--r--usr.sbin/usbdevs/usbdevs.c213
-rw-r--r--usr.sbin/vidcontrol/vidcontrol.c22
-rw-r--r--usr.sbin/vipw/pw_util.c35
-rw-r--r--usr.sbin/wlconfig/wlconfig.82
-rw-r--r--usr.sbin/xntpd/include/ntp_machine.h1
-rw-r--r--usr.sbin/xntpd/parse/util/dcfd.c10
-rw-r--r--usr.sbin/xntpd/parse/util/testdcf.c3
-rw-r--r--usr.sbin/xntpd/xntpd/ntp_unixclock.c28
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_acts.c4
-rw-r--r--usr.sbin/xntpd/xntpd/refclock_heath.c2
-rw-r--r--usr.sbin/xten/README6
247 files changed, 3311 insertions, 35554 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index f10bd2057dee..0ac014277abb 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -1,9 +1,8 @@
# From: @(#)Makefile 5.20 (Berkeley) 6/12/93
-# $Id: Makefile,v 1.146 1999/01/11 08:06:04 msmith Exp $
+# $Id: Makefile,v 1.132 1998/09/17 08:55:02 dfr Exp $
# XXX MISSING: mkproto
-SUBDIR= IPXrouted \
- ac \
+SUBDIR= ac \
accton \
adduser \
amd \
@@ -14,32 +13,21 @@ SUBDIR= IPXrouted \
chkgrp \
chown \
chroot \
+ crunch \
ckdist \
config \
cron \
- crunch \
ctm \
dev_mkdb \
diskpart \
edquota \
inetd \
- iostat \
- ipfstat \
- ipftest \
- ipmon \
- ipnat \
- ipresend \
- ipsend \
- iptest \
- kbdcontrol \
- kbdmap \
kernbb \
keyadmin \
keyserv \
kvm_mkdb \
lpr \
manctl \
- moused \
mrouted \
mtest \
mtree \
@@ -72,9 +60,8 @@ SUBDIR= IPXrouted \
rpc.lockd \
rpc.statd \
rpc.yppasswdd \
- rpc.ypupdated \
rpc.ypxfrd \
- rtprio \
+ rpc.ypupdated \
rwhod \
sa \
sliplogin \
@@ -87,23 +74,28 @@ SUBDIR= IPXrouted \
traceroute \
trpt \
tzsetup \
- usbd \
- usbdevs \
- vidcontrol \
vipw \
vnconfig \
watch \
wormcontrol \
xntpd \
xten \
- yp_mkdb \
ypbind \
+ yp_mkdb \
yppoll \
yppush \
- ypserv \
ypset \
+ ypserv \
zic
+SUBDIR+=ipfstat \
+ ipftest \
+ ipmon \
+ ipnat \
+ ipresend \
+ ipsend \
+ iptest
+
.if !defined(NO_SENDMAIL)
SUBDIR+=mailstats \
makemap \
@@ -112,26 +104,44 @@ SUBDIR+=mailstats \
.endif
.if ${MACHINE_ARCH} == "i386"
+SUBDIR+=btxld \
+ kgmon \
+ pcvt \
+ pnpinfo \
+ rndcontrol \
+ wlconfig \
+ IPXrouted
+
SUBDIR+=apm \
apmconf \
bad144 \
- btxld \
- fdcontrol \
fdformat \
fdwrite \
- i4b \
- kgmon \
+ fdcontrol \
+ iostat \
+ kbdcontrol \
+ kbdmap \
lptcontrol \
mixer \
+ moused \
mptable \
- pcvt \
- pnpinfo \
- rndcontrol \
+ rtprio \
sgsc \
sicontrol \
spkrtest \
stallion \
- wlconfig
+ vidcontrol
+.endif
+
+.if ${MACHINE_ARCH} == "alpha"
+SUBDIR+=kvm_mkdb \
+ natd \
+ kbdcontrol \
+ kbdmap \
+ moused \
+ pstat \
+ rtprio \
+ vidcontrol
.endif
.include <bsd.subdir.mk>
diff --git a/usr.sbin/adduser/adduser.perl b/usr.sbin/adduser/adduser.perl
index 256e27c50e3b..b6e572848488 100644
--- a/usr.sbin/adduser/adduser.perl
+++ b/usr.sbin/adduser/adduser.perl
@@ -24,7 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $Id: adduser.perl,v 1.41 1998/08/17 18:50:29 wosch Exp $
+# $Id: adduser.perl,v 1.40 1998/06/07 18:38:32 wosch Exp $
# read variables
@@ -895,7 +895,6 @@ sub adduser_log {
return 1 if $logfile eq "no";
local($sec, $min, $hour, $mday, $mon, $year) = localtime;
- $year += 1900;
$mon++;
foreach $e ('sec', 'min', 'hour', 'mday', 'mon', 'year') {
diff --git a/usr.sbin/amd/amd/Makefile b/usr.sbin/amd/amd/Makefile
index 48a3ec2154d4..49bdcacc31a6 100644
--- a/usr.sbin/amd/amd/Makefile
+++ b/usr.sbin/amd/amd/Makefile
@@ -3,7 +3,7 @@
# Makefile for amd
# This file is under a "BSD" copyright (c) by David O'Brien 1998
#
-# $Id: Makefile,v 1.15 1998/08/30 19:59:49 gpalmer Exp $
+# $Id: Makefile,v 1.14 1998/08/27 08:09:40 obrien Exp $
#
.PATH: ${.CURDIR}/../../../contrib/amd/amd
@@ -25,8 +25,8 @@ SRCS+= srvr_amfs_auto.c srvr_nfs.c
CFLAGS+= -I${.CURDIR}/../../../contrib/amd/amd
-DPADD= ${LIBAMU} ${LIBRPCSVC}
-LDADD= ${LIBAMU} -lrpcsvc
+DPADD+= ${LIBAMU}
+LDADD+= ${LIBAMU} -lrpcsvc
CLEANFILES+= conf_parse.c conf_parse.h conf_tok.c
diff --git a/usr.sbin/amd/fixmount/Makefile b/usr.sbin/amd/fixmount/Makefile
index 3ea214fa59c1..b1c2a97a901f 100644
--- a/usr.sbin/amd/fixmount/Makefile
+++ b/usr.sbin/amd/fixmount/Makefile
@@ -3,7 +3,7 @@
# Makefile for amd
# This file is under a "BSD" copyright (c) by David O'Brien 1998
#
-# $Id: Makefile,v 1.2 1998/08/30 19:59:52 gpalmer Exp $
+# $Id: Makefile,v 1.1 1998/08/27 08:09:41 obrien Exp $
#
.PATH: ${.CURDIR}/../../../contrib/amd/fixmount \
@@ -20,7 +20,7 @@ SRCS+= mount.h nfs_prot.h
# These would be links created by the GNU-style configure
SRCS+= checkmount_bsd44.c
-DPADD= ${LIBAMU} ${LIBRPCSVC}
-LDADD= ${LIBAMU} -lrpcsvc
+DPADD+= ${LIBAMU}
+LDADD+= ${LIBAMU} -lrpcsvc
.include <bsd.prog.mk>
diff --git a/usr.sbin/amd/hlfsd/Makefile b/usr.sbin/amd/hlfsd/Makefile
index 3cf19bcda20c..693b509e1e5d 100644
--- a/usr.sbin/amd/hlfsd/Makefile
+++ b/usr.sbin/amd/hlfsd/Makefile
@@ -3,7 +3,7 @@
# Makefile for amd
# This file is under a "BSD" copyright (c) by David O'Brien 1998
#
-# $Id: Makefile,v 1.2 1998/08/30 19:59:52 gpalmer Exp $
+# $Id: Makefile,v 1.1 1998/08/27 08:09:41 obrien Exp $
#
.PATH: ${.CURDIR}/../../../contrib/amd/hlfsd
@@ -15,7 +15,7 @@ SRCS= hlfsd.c homedir.c nfs_prot_svc.c stubs.c
CFLAGS+= -I${.CURDIR}/../../../contrib/amd/hlfsd
-DPADD= ${LIBAMU} ${LIBRPCSVC}
-LDADD= ${LIBAMU} -lrpcsvc
+DPADD+= ${LIBAMU}
+LDADD+= ${LIBAMU} -lrpcsvc
.include <bsd.prog.mk>
diff --git a/usr.sbin/amd/include/config.h b/usr.sbin/amd/include/config.h
index cc3dad823aee..c36021fba7fa 100644
--- a/usr.sbin/amd/include/config.h
+++ b/usr.sbin/amd/include/config.h
@@ -1,4 +1,4 @@
-/* $Id: config.h,v 1.8 1998/11/20 05:18:34 obrien Exp $ */
+/* $Id: config.h,v 1.6 1998/08/27 08:09:41 obrien Exp $ */
/* portions derived from
$NetBSD: config.h,v 1.11 1998/08/08 22:33:37 christos Exp $ */
/* config.h. Generated automatically by configure. */
@@ -927,7 +927,7 @@
#define PACKAGE "am-utils"
/* Define version of package (must be defined by configure.in) */
-#define VERSION "6.0"
+#define VERSION "6.0a16"
/* We pick some parameters from our local config file */
#include "config_local.h"
diff --git a/usr.sbin/atm/atmarpd/atmarpd.8 b/usr.sbin/atm/atmarpd/atmarpd.8
index 7aabddf55308..fe3f751566b2 100644
--- a/usr.sbin/atm/atmarpd/atmarpd.8
+++ b/usr.sbin/atm/atmarpd/atmarpd.8
@@ -22,7 +22,7 @@
.\" Copies of this Software may be made, however, the above copyright
.\" notice must be reproduced on all copies.
.\"
-.\" @(#) $Id: atmarpd.8,v 1.1 1998/09/15 08:23:15 phk Exp $
+.\" @(#) $Id: atmarpd.1,v 1.2 1998/08/26 21:39:39 johnc Exp $
.\"
.\"
.de EX \"Begin example
@@ -67,7 +67,7 @@ itself into the background.
The command-line options are:
.IP "\fB-l\fP <log file>" 15
-Specifies that \fIatmarpd\fP is to write log messages to the
+Specifies that \fIatmarpd\fP is to write log messages to the the
file named <log file> rather than to the system log.
.IP "\fB-d\fP" 15
Specifies that \fIatmarpd\fP is to be run in debug mode.
@@ -77,7 +77,7 @@ the log file.
.IP "<netif>" 15
Specifies the network interface(s) for which the host is providing
ATMARP service and whose caches are to be synchronized using SCSP.
-If multiple network interface names are specified, \fIatmarpd\fP
+If multiple network interface names are be specified, \fIatmarpd\fP
will provide an interface to \fIscspd\fP for the servers on all the
specified interfaces.
diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h
index c43c00036906..44ac3d0dd69d 100644
--- a/usr.sbin/config/configvers.h
+++ b/usr.sbin/config/configvers.h
@@ -6,6 +6,6 @@
* The numbering scheme is inspired by the sys/conf/newvers.sh RELDATE
* and <osreldate.h> system.
*
- * $Id: configvers.h,v 1.7 1998/10/23 17:05:06 bde Exp $
+ * $Id: configvers.h,v 1.5 1998/09/03 21:03:43 nsouch Exp $
*/
-#define CONFIGVERS 300009
+#define CONFIGVERS 300007
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index b3c0f8fe08a6..aaefd51f7afa 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -55,7 +55,8 @@ struct kt {
#if MACHINE_I386
{ "bio", BIO },
{ "bus", BUS },
- { "cam", CAM },
+ { "cam", CAM},
+ { "ha", HA},
{ "conflicts", CONFLICTS },
#endif
{ "config", CONFIG },
@@ -73,9 +74,6 @@ struct kt {
#endif
{ "dumps", DUMPS },
{ "flags", FLAGS },
-#if MACHINE_I386
- { "ha", HA },
-#endif
{ "ident", IDENT },
{ "interleave", INTERLEAVE },
#if MACHINE_I386
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 0c0535882f41..7fd3bfcb9647 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: main.c,v 1.25 1998/06/09 14:02:03 dfr Exp $";
+ "$Id: main.c,v 1.24 1998/05/02 01:57:38 kato Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -358,7 +358,7 @@ configfile()
err(2, "%s", p);
fprintf(fo,"#include \"opt_config.h\"\n");
fprintf(fo,"#ifdef INCLUDE_CONFIG_FILE \n");
- fprintf(fo,"static const char config[] = \"\\\n");
+ fprintf(fo,"static char *config = \"\\\n");
fprintf(fo,"START CONFIG FILE %s\\n\\\n___",PREFIX);
while (EOF != (i=getc(fi))) {
if(i == '\n') {
diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c
index 27053a799118..ea29c2accb61 100644
--- a/usr.sbin/config/mkioconf.c
+++ b/usr.sbin/config/mkioconf.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mkioconf.c 8.2 (Berkeley) 1/21/94";
#endif
static const char rcsid[] =
- "$Id: mkioconf.c,v 1.44 1998/10/23 17:05:06 bde Exp $";
+ "$Id: mkioconf.c,v 1.41 1998/09/15 10:29:32 gibbs Exp $";
#endif /* not lint */
#include <err.h>
@@ -52,7 +52,7 @@ char *intv();
char *wnum();
void pseudo_ioconf();
void comp_config __P((FILE *));
-void scbus_devtab __P((FILE *, int *));
+void scbus_devtab __P((FILE *, FILE *, int *));
void isa_devtab __P((FILE *, char *, int *));
void isa_biotab __P((FILE *, char *));
void i386_ioconf __P((void));
@@ -608,6 +608,7 @@ hpbadslave(mp, dp)
#endif
#if MACHINE_I386
+char *shandler();
char *sirq();
void
@@ -615,7 +616,7 @@ i386_ioconf()
{
register struct device *dp, *mp;
int dev_id;
- FILE *fp;
+ FILE *fp, *fp1;
static char *old_d_name;
int count;
@@ -628,8 +629,19 @@ i386_ioconf()
fprintf(fp, " */\n");
fprintf(fp, "\n");
fprintf(fp, "#include <sys/param.h>\n");
+ fprintf(fp, "#include \"ioconf.h\"\n");
fprintf(fp, "\n");
fprintf(fp, "#define C (caddr_t)\n");
+ fp1 = fopen(path("ioconf.h.new"), "w");
+ if (fp1 == 0)
+ err(1, "%s", path("ioconf.h.new"));
+ fprintf(fp1, "/*\n");
+ fprintf(fp1, " * Extern declarations for I/O configuration.\n");
+ fprintf(fp1, " * DO NOT EDIT-- this file is automatically generated.\n");
+ fprintf(fp1, " */\n");
+ fprintf(fp1, "\n");
+ fprintf(fp1, "#ifndef IOCONF_H\n");
+ fprintf(fp1, "#define\tIOCONF_H\n");
/*
* First print the isa initialization structures
*/
@@ -682,7 +694,7 @@ i386_ioconf()
isa_devtab(fp, "null", &dev_id);
}
if (seen_scbus)
- scbus_devtab(fp, &dev_id);
+ scbus_devtab(fp, fp1, &dev_id);
fprintf(fp, "\n");
fprintf(fp, "/*\n");
@@ -700,8 +712,14 @@ i386_ioconf()
fprintf(fp, "\n");
fprintf(fp, "int devtab_count = %d;\n", count);
+ /* XXX David did this differently!!! */
+ /* pseudo_ioconf(fp); */
(void) fclose(fp);
+ fprintf(fp1, "\n");
+ fprintf(fp1, "#endif /* IOCONF_H */\n");
+ (void) fclose(fp1);
moveifchanged(path("ioconf.c.new"), path("ioconf.c"));
+ moveifchanged(path("ioconf.h.new"), path("ioconf.h"));
}
void
@@ -714,7 +732,7 @@ isa_biotab(fp, table)
fprintf(fp, "\n");
fprintf(fp, "struct isa_device isa_biotab_%s[] = {\n", table);
fprintf(fp, "\
-/* id driver iobase irq drq maddr msiz intr unit flags drive alive ri_flags reconfig enabled conflicts next */\n");
+/* id driver iobase irq drq maddr msiz intr unit flags drive alive ri_flags reconfig enabled conflicts next */\n");
for (dp = dtab; dp != 0; dp = dp->d_next) {
mp = dp->d_conn;
if (dp->d_unit == QUES || mp == 0 ||
@@ -722,9 +740,9 @@ isa_biotab(fp, table)
continue;
fprintf(fp, "{ -1, &%3sdriver, %8s,",
mp->d_name, mp->d_port);
- fprintf(fp, "%6s, %2d, C 0x%05X, %5d, 0, %3d, 0x%04X, %5d, 0, 0, 0, %6d, %8d, 0 },\n",
+ fprintf(fp, "%6s, %2d, C 0x%05X, %5d, %8s, %3d, 0x%04X, %5d, 0, 0, 0, %6d, %8d, 0 },\n",
sirq(mp->d_irq), mp->d_drq, mp->d_maddr,
- mp->d_msize, dp->d_unit,
+ mp->d_msize, shandler(mp), dp->d_unit,
dp->d_flags, dp->d_drive, !dp->d_disabled,
dp->d_conflicts);
}
@@ -748,7 +766,7 @@ isa_devtab(fp, table, dev_idp)
fprintf(fp, "\n");
fprintf(fp, "struct isa_device isa_devtab_%s[] = {\n", table);
fprintf(fp, "\
-/* id driver iobase irq drq maddr msiz intr unit flags scsiid alive ri_flags reconfig enabled conflicts next */\n");
+/* id driver iobase irq drq maddr msiz intr unit flags scsiid alive ri_flags reconfig enabled conflicts next */\n");
for (dp = dtab; dp != 0; dp = dp->d_next) {
if (dp->d_unit == QUES || !eq(dp->d_mask, table))
continue;
@@ -762,9 +780,9 @@ isa_devtab(fp, table, dev_idp)
fprintf(fp, " %d,", dp->d_portn);
else
fprintf(fp, " 0x%04x,", dp->d_portn);
- fprintf(fp, "%6s, %2d, C 0x%05X, %5d, 0, %3d, 0x%04X, 0, 0, 0, 0, %6d, %8d, 0 },\n",
+ fprintf(fp, "%6s, %2d, C 0x%05X, %5d, %8s, %3d, 0x%04X, 0, 0, 0, 0, %6d, %8d, 0 },\n",
sirq(dp->d_irq), dp->d_drq, dp->d_maddr,
- dp->d_msize, dp->d_unit,
+ dp->d_msize, shandler(dp), dp->d_unit,
dp->d_flags, !dp->d_disabled, dp->d_conflicts);
}
fprintf(fp, "0\n};\n");
@@ -804,8 +822,9 @@ static void id_put(fp, unit, s)
* lost and should be put back in.
*/
void
-scbus_devtab(fp, dev_idp)
+scbus_devtab(fp, fp1, dev_idp)
FILE *fp;
+ FILE *fp1;
int *dev_idp;
{
register struct device *dp, *mp;
@@ -882,6 +901,24 @@ scbus_devtab(fp, dev_idp)
*/
char *
+shandler(dp)
+ register struct device *dp;
+{
+ static char buf[32 + 1];
+
+ if (dp->d_vec == NULL || dp->d_vec->id == NULL)
+ return "NULL";
+ /*
+ * This is for ISA. We only support one interrupt handler in the
+ * devtabs. Handlers in the config file after the first for each
+ * device are ignored. Special handlers may be registered at
+ * runtime.
+ */
+ sprintf(buf, "%.32s", dp->d_vec->id);
+ return (buf);
+}
+
+char *
sirq(num)
{
@@ -1145,7 +1182,7 @@ write_device_resources(FILE *fp, struct device *dp)
{
int count = 0;
- fprintf(fp, "struct config_resource %s_resources[] = {\n", devstr(dp));
+ fprintf(fp, "struct resource %s_resources[] = {\n", devstr(dp));
if (dp->d_conn) {
fprintf(fp, "\t\"at\",\tRES_STRING,\t(long)\"%s\",\n",
devstr(dp->d_conn));
@@ -1208,6 +1245,7 @@ alpha_ioconf()
{
register struct device *dp, *mp;
FILE *fp;
+ FILE *fp1;
int dev_id = 10;
int count;
@@ -1216,10 +1254,21 @@ alpha_ioconf()
err(1, "%s", path("ioconf.c"));
fprintf(fp, "#include <sys/types.h>\n");
fprintf(fp, "#include <sys/time.h>\n");
+ fprintf(fp, "#include <ioconf.h>\n\n");
fprintf(fp, "#include <sys/queue.h>\n\n");
fprintf(fp, "#include <sys/bus_private.h>\n");
fprintf(fp, "#include <isa/isareg.h>\n\n");
fprintf(fp, "#define C (char *)\n\n");
+ fp1 = fopen(path("ioconf.h.new"), "w");
+ if (fp1 == 0)
+ err(1, "%s", path("ioconf.h.new"));
+ fprintf(fp1, "/*\n");
+ fprintf(fp1, " * Extern declarations for I/O configuration.\n");
+ fprintf(fp1, " * DO NOT EDIT-- this file is automatically generated.\n");
+ fprintf(fp1, " */\n");
+ fprintf(fp1, "\n");
+ fprintf(fp1, "#ifndef IOCONF_H\n");
+ fprintf(fp1, "#define\tIOCONF_H\n");
for (dp = dtab; dp != 0; dp = dp->d_next) {
if (dp->d_type != CONTROLLER && dp->d_type != MASTER
@@ -1242,10 +1291,13 @@ alpha_ioconf()
fprintf(fp, "int devtab_count = %d;\n", count);
if (seen_scbus)
- scbus_devtab(fp, &dev_id);
+ scbus_devtab(fp, fp1, &dev_id);
(void) fclose(fp);
+ fprintf(fp1, "#endif\n");
+ (void) fclose(fp1);
moveifchanged(path("ioconf.c.new"), path("ioconf.c"));
+ moveifchanged(path("ioconf.h.new"), path("ioconf.h"));
}
#endif
diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c
index ff9083125d6a..2389c9b66f9e 100644
--- a/usr.sbin/cron/cron/cron.c
+++ b/usr.sbin/cron/cron/cron.c
@@ -17,7 +17,7 @@
#if !defined(lint) && !defined(LINT)
static const char rcsid[] =
- "$Id: cron.c,v 1.7 1998/07/06 20:28:04 bde Exp $";
+ "$Id: cron.c,v 1.6 1997/09/15 06:39:04 charnier Exp $";
#endif
#define MAIN_PROGRAM
@@ -227,40 +227,28 @@ cron_sync() {
static void
cron_sleep() {
- int seconds_to_wait = 0;
+ register int seconds_to_wait;
- /*
- * Loop until we reach the top of the next minute, sleep when possible.
- */
-
- for (;;) {
+ do {
seconds_to_wait = (int) (TargetTime - time((time_t*)0));
-
- /*
- * If the seconds_to_wait value is insane, jump the cron
- */
-
- if (seconds_to_wait < -600 || seconds_to_wait > 600) {
- cron_sync();
- continue;
- }
-
Debug(DSCH, ("[%d] TargetTime=%ld, sec-to-wait=%d\n",
getpid(), (long)TargetTime, seconds_to_wait))
- /*
- * If we've run out of wait time or there are no jobs left
- * to run, break
+ /* if we intend to sleep, this means that it's finally
+ * time to empty the job queue (execute it).
+ *
+ * if we run any jobs, we'll probably screw up our timing,
+ * so go recompute.
+ *
+ * note that we depend here on the left-to-right nature
+ * of &&, and the short-circuiting.
*/
+ } while (seconds_to_wait > 0 && job_runqueue());
- if (seconds_to_wait <= 0)
- break;
- if (job_runqueue() == 0) {
- Debug(DSCH, ("[%d] sleeping for %d seconds\n",
- getpid(), seconds_to_wait))
-
- sleep(seconds_to_wait);
- }
+ while (seconds_to_wait > 0) {
+ Debug(DSCH, ("[%d] sleeping for %d seconds\n",
+ getpid(), seconds_to_wait))
+ seconds_to_wait = (int) sleep((unsigned int) seconds_to_wait);
}
}
diff --git a/usr.sbin/cron/lib/misc.c b/usr.sbin/cron/lib/misc.c
index 3e0318268880..6c098de1683b 100644
--- a/usr.sbin/cron/lib/misc.c
+++ b/usr.sbin/cron/lib/misc.c
@@ -17,7 +17,7 @@
#if !defined(lint) && !defined(LINT)
static const char rcsid[] =
- "$Id: misc.c,v 1.6 1997/09/15 06:39:25 charnier Exp $";
+ "$Id: misc.c,v 1.5 1997/02/22 16:05:08 peter Exp $";
#endif
/* vix 26jan87 [RCS has the rest of the log]
@@ -619,12 +619,9 @@ arpadate(clock)
{
time_t t = clock ?*clock :time(0L);
struct tm *tm = localtime(&t);
- static char ret[32]; /* zone name might be >3 chars */
+ static char ret[30]; /* zone name might be >3 chars */
- if (tm->tm_year >= 100)
- tm->tm_year += 1900;
-
- (void) snprintf(ret, sizeof(ret), "%s, %2d %s %d %02d:%02d:%02d %s",
+ (void) sprintf(ret, "%s, %2d %s %2d %02d:%02d:%02d %s",
DowNames[tm->tm_wday],
tm->tm_mday,
MonthNames[tm->tm_mon],
diff --git a/usr.sbin/ctm/mkCTM/mkCTM b/usr.sbin/ctm/mkCTM/mkCTM
index a728a786183a..684fb6a856e2 100644
--- a/usr.sbin/ctm/mkCTM/mkCTM
+++ b/usr.sbin/ctm/mkCTM/mkCTM
@@ -44,7 +44,7 @@ set damage 0
set changes 0
source $argv
-exec sh -c "date -u '+%Y%m%d%H%M%S $argv'" >> ${CTMSW}/log
+exec sh -c "date -u '+%y%m%d%H%M%S $argv'" >> ${CTMSW}/log
if {$CTMtmp == ""} {
set CTMtmp $CTMSW/../tmp/${CTMname}_${CTMsuff}
diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c
index 0d983a9a3ec6..011037175ce5 100644
--- a/usr.sbin/edquota/edquota.c
+++ b/usr.sbin/edquota/edquota.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)edquota.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: edquota.c,v 1.7 1997/09/17 06:29:23 charnier Exp $";
+ "$Id$";
#endif /* not lint */
/*
@@ -469,11 +469,9 @@ readprivs(quplist, inname)
warnx("%s:%s: bad format", fsp, cp);
return (0);
}
- dqblk.dqb_curblocks = btodb((off_t)dqblk.dqb_curblocks * 1024);
- dqblk.dqb_bsoftlimit = btodb((off_t)dqblk.dqb_bsoftlimit
- * 1024);
- dqblk.dqb_bhardlimit = btodb((off_t)dqblk.dqb_bhardlimit
- * 1024);
+ dqblk.dqb_curblocks = btodb(dqblk.dqb_curblocks * 1024);
+ dqblk.dqb_bsoftlimit = btodb(dqblk.dqb_bsoftlimit * 1024);
+ dqblk.dqb_bhardlimit = btodb(dqblk.dqb_bhardlimit * 1024);
if ((cp = strtok(line2, "\n")) == NULL) {
warnx("%s: %s: bad format", fsp, line2);
return (0);
diff --git a/usr.sbin/i4b/Makefile b/usr.sbin/i4b/Makefile
deleted file mode 100644
index 3c12d78f8b90..000000000000
--- a/usr.sbin/i4b/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-SUBDIR = isdntrace isdndebug isdnd alawulaw man isdntest \
- isdntel isdntelctl isdnmonitor isdndecode
-
-.include <bsd.subdir.mk>
diff --git a/usr.sbin/i4b/Makefile.inc b/usr.sbin/i4b/Makefile.inc
deleted file mode 100644
index 691d73809e06..000000000000
--- a/usr.sbin/i4b/Makefile.inc
+++ /dev/null
@@ -1,14 +0,0 @@
-# if you don't like curses stuff in the daemon (i.e. don't intend
-# to ever run it in the foreground but are using the monitoring
-# utilities instead) define this to compile it without.
-#I4B_WITHOUT_CURSES = 1
-
-# if you would like monitoring support, define this
-I4B_EXTERNAL_MONITOR = 1
-
-# for the security conscious type: restrict monitoring to the
-# local machine by not compiling any tcp/ip support for monitoring
-# at all
-#I4B_NOTCPIP_MONITOR = 1
-
-.include "${.CURDIR}/../../Makefile.inc"
diff --git a/usr.sbin/i4b/alawulaw/Makefile b/usr.sbin/i4b/alawulaw/Makefile
deleted file mode 100644
index 1daa481e3b08..000000000000
--- a/usr.sbin/i4b/alawulaw/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-PROG = alaw2ulaw
-SRC = alaw2ulaw.c
-CFLAGS += -Wall -g -DDEBUG
-LINKS = ${BINDIR}/alaw2ulaw ${BINDIR}/ulaw2alaw
-MAN1 = alaw2ulaw.1 ulaw2alaw.1
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/i4b/alawulaw/alaw2ulaw.1 b/usr.sbin/i4b/alawulaw/alaw2ulaw.1
deleted file mode 100644
index fea7fa57a7ac..000000000000
--- a/usr.sbin/i4b/alawulaw/alaw2ulaw.1
+++ /dev/null
@@ -1,70 +0,0 @@
-.\"
-.\" Copyright (c) 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: alaw2ulaw.1,v 1.3 1998/12/05 18:02:35 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 17:57:34 1998]
-.\"
-.\" -hm writing manual pages
-.\"
-.\"
-.Dd January 23, 1998
-.Dt alaw2ulaw 1
-.Sh NAME
-.Nm alaw2ulaw
-.Nd convert sound data
-.Sh SYNOPSIS
-.Nm
-.Sh DESCRIPTION
-.Nm alaw2ulaw
-is part of the isdn4bsd package and is used convert sound data between
-uLaw coded data to ALaw coded data and vice versa.
-.Pp
-It reads data from stdin and outputs converted data to stdout.
-.Pp
-In case it is run as
-.Em alaw2ulaw
-it converts ALaw input data to uLaw output.
-.Pp
-In case it is run as
-.Em ulaw2alaw
-it converts uLaw input data to ALaw output.
-.Pp
-
-.Sh EXAMPLES
-The command:
-.Bd -literal -offset indent
-alaw2ulaw <file.alaw >file.ulaw
-.Ed
-.Pp
-converts ALaw input data file file.alaw to uLaw output file file.ulaw.
-
-.Sh STANDARDS
-ITU Recommendations G.711
-
-.Sh AUTHOR
-The
-.Nm
-utility and this man page were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/alawulaw/alaw2ulaw.c b/usr.sbin/i4b/alawulaw/alaw2ulaw.c
deleted file mode 100644
index d13e41de8ed8..000000000000
--- a/usr.sbin/i4b/alawulaw/alaw2ulaw.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 1997 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * convert a-law / u-law sound files
- * ---------------------------------
- *
- * last edit-date: [Sat Dec 5 17:57:56 1998]
- *
- * $Id: alaw2ulaw.c,v 1.2 1998/12/05 18:02:36 hm Exp $
- *
- * -hm telephony is ready
- *
- *---------------------------------------------------------------------------*/
-
-#include <string.h>
-#include <unistd.h>
-
-#define BUF_SIZ 2048
-
-unsigned char alaw_ulaw[];
-unsigned char ulaw_alaw[];
-
-int main(int argc, char *argv[])
-{
- int i, j;
- unsigned char buffer[BUF_SIZ];
- char *p;
- unsigned char *cp;
-
- if((p = rindex(*argv, '/')) != NULL)
- p++;
- else
- p = *argv;
-
- if(!strcmp(p, "ulaw2alaw"))
- {
- cp = ulaw_alaw;
- }
- else if(!strcmp(p, "alaw2ulaw"))
- {
- cp = alaw_ulaw;
- }
- else
- {
- return(1);
- }
-
- while(((j = read(0, buffer, BUF_SIZ)) > 0))
- {
- for(i = 0; i < j; i++)
- buffer[i] = cp[buffer[i]];
- write(1, buffer, j);
- }
- return(0);
-}
-
-unsigned char alaw_ulaw[] = {
- 0x002a, 0x00a9, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0048, 0x00c8,
- 0x0039, 0x00b9, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0055, 0x00d7,
- 0x0022, 0x00a1, 0x005b, 0x00dd, 0x001f, 0x009f, 0x0040, 0x00c0,
- 0x0031, 0x00b1, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004e, 0x00cf,
- 0x002e, 0x00ad, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004c, 0x00cc,
- 0x003d, 0x00bd, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0059, 0x00db,
- 0x0026, 0x00a5, 0x005d, 0x00df, 0x001f, 0x009f, 0x0044, 0x00c4,
- 0x0035, 0x00b5, 0x006b, 0x00ef, 0x001f, 0x009f, 0x0051, 0x00d3,
- 0x0028, 0x00a7, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0046, 0x00c6,
- 0x0037, 0x00b7, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0053, 0x00d5,
- 0x0020, 0x009f, 0x005b, 0x00dd, 0x001f, 0x009f, 0x003f, 0x00bf,
- 0x002f, 0x00af, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004d, 0x00ce,
- 0x002c, 0x00ab, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004a, 0x00ca,
- 0x003b, 0x00bb, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0057, 0x00d9,
- 0x0024, 0x00a3, 0x005d, 0x00df, 0x001f, 0x009f, 0x0042, 0x00c2,
- 0x0033, 0x00b3, 0x006b, 0x00ef, 0x001f, 0x009f, 0x004f, 0x00d1,
- 0x002b, 0x00aa, 0x0063, 0x00e3, 0x001f, 0x009f, 0x0049, 0x00c9,
- 0x003a, 0x00ba, 0x0077, 0x00f7, 0x001f, 0x009f, 0x0057, 0x00d7,
- 0x0023, 0x00a2, 0x005d, 0x00dd, 0x001f, 0x009f, 0x0041, 0x00c1,
- 0x0032, 0x00b2, 0x006b, 0x00eb, 0x001f, 0x009f, 0x004f, 0x00cf,
- 0x002f, 0x00ae, 0x0067, 0x00e7, 0x001f, 0x009f, 0x004d, 0x00cd,
- 0x003e, 0x00be, 0x00ff, 0x00ff, 0x001f, 0x009f, 0x005b, 0x00db,
- 0x0027, 0x00a6, 0x005f, 0x00df, 0x001f, 0x009f, 0x0045, 0x00c5,
- 0x0036, 0x00b6, 0x006f, 0x00ef, 0x001f, 0x009f, 0x0053, 0x00d3,
- 0x0029, 0x00a8, 0x005f, 0x00e3, 0x001f, 0x009f, 0x0047, 0x00c7,
- 0x0038, 0x00b8, 0x006f, 0x00f7, 0x001f, 0x009f, 0x0055, 0x00d5,
- 0x0021, 0x00a0, 0x005b, 0x00dd, 0x001f, 0x009f, 0x003f, 0x00bf,
- 0x0030, 0x00b0, 0x0067, 0x00eb, 0x001f, 0x009f, 0x004e, 0x00ce,
- 0x002d, 0x00ac, 0x0063, 0x00e7, 0x001f, 0x009f, 0x004b, 0x00cb,
- 0x003c, 0x00bc, 0x0077, 0x00ff, 0x001f, 0x009f, 0x0059, 0x00d9,
- 0x0025, 0x00a4, 0x005d, 0x00df, 0x001f, 0x009f, 0x0043, 0x00c3,
- 0x0034, 0x00b4, 0x006b, 0x00ef, 0x001f, 0x009f, 0x0051, 0x00d1
-};
-
-unsigned char ulaw_alaw[] = {
- 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
- 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
- 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
- 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00ac,
- 0x0050, 0x00d0, 0x0010, 0x0090, 0x0070, 0x00f0, 0x0030, 0x00b0,
- 0x0040, 0x00c0, 0x0000, 0x0080, 0x0060, 0x00e0, 0x0020, 0x00a0,
- 0x00d8, 0x0018, 0x0098, 0x0078, 0x00f8, 0x0038, 0x00b8, 0x0048,
- 0x00c8, 0x0008, 0x0088, 0x0068, 0x00e8, 0x0028, 0x00a8, 0x00d6,
- 0x0096, 0x0076, 0x00f6, 0x0036, 0x00b6, 0x0046, 0x00c6, 0x0006,
- 0x0086, 0x0066, 0x00e6, 0x0026, 0x00a6, 0x00de, 0x009e, 0x00fe,
- 0x00fe, 0x00be, 0x00be, 0x00ce, 0x00ce, 0x008e, 0x008e, 0x00ee,
- 0x00ee, 0x00d2, 0x00d2, 0x00f2, 0x00f2, 0x00c2, 0x00c2, 0x00e2,
- 0x00e2, 0x00e2, 0x00da, 0x00da, 0x00da, 0x00da, 0x00fa, 0x00fa,
- 0x00fa, 0x00fa, 0x00ca, 0x00ca, 0x00ca, 0x00ca, 0x00ea, 0x00ea,
- 0x00ea, 0x00ea, 0x00ea, 0x00ea, 0x00eb, 0x00eb, 0x00eb, 0x00eb,
- 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb, 0x00eb,
- 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
- 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
- 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
- 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd, 0x00fd,
- 0x00d1, 0x0011, 0x0091, 0x0071, 0x00f1, 0x0031, 0x00b1, 0x0041,
- 0x00c1, 0x0001, 0x0081, 0x0061, 0x00e1, 0x0021, 0x00a1, 0x0059,
- 0x00d9, 0x0019, 0x0099, 0x0079, 0x00f9, 0x0039, 0x00b9, 0x0049,
- 0x00c9, 0x0009, 0x0089, 0x0069, 0x00e9, 0x0029, 0x00a9, 0x0057,
- 0x0017, 0x0097, 0x0077, 0x00f7, 0x0037, 0x00b7, 0x0047, 0x00c7,
- 0x0007, 0x0087, 0x0067, 0x00e7, 0x0027, 0x00a7, 0x00df, 0x009f,
- 0x009f, 0x00ff, 0x00ff, 0x00bf, 0x00bf, 0x00cf, 0x00cf, 0x008f,
- 0x008f, 0x00ef, 0x00ef, 0x00af, 0x00af, 0x00d3, 0x00d3, 0x00f3,
- 0x00f3, 0x00f3, 0x00c3, 0x00c3, 0x00c3, 0x00c3, 0x00e3, 0x00e3,
- 0x00e3, 0x00e3, 0x00db, 0x00db, 0x00db, 0x00db, 0x00fb, 0x00fb,
- 0x00fb, 0x00fb, 0x00fb, 0x00fb, 0x00cb, 0x00cb, 0x00cb, 0x00cb,
- 0x00cb, 0x00cb, 0x00cb, 0x00cb, 0x00eb, 0x00eb, 0x00eb, 0x00eb
-};
-
-/* EOF */
diff --git a/usr.sbin/i4b/alawulaw/ulaw2alaw.1 b/usr.sbin/i4b/alawulaw/ulaw2alaw.1
deleted file mode 100644
index 4c43c153c670..000000000000
--- a/usr.sbin/i4b/alawulaw/ulaw2alaw.1
+++ /dev/null
@@ -1,70 +0,0 @@
-.\"
-.\" Copyright (c) 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: ulaw2alaw.1,v 1.3 1998/12/05 18:02:37 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 17:58:07 1998]
-.\"
-.\" -hm writing manual pages
-.\"
-.\"
-.Dd January 23, 1998
-.Dt ulaw2alaw 1
-.Sh NAME
-.Nm ulaw2alaw
-.Nd convert sound data
-.Sh SYNOPSIS
-.Nm
-.Sh DESCRIPTION
-.Nm ulaw2alaw
-is part of the isdn4bsd package and is used convert sound data between
-uLaw coded data to ALaw coded data and vice versa.
-.Pp
-It reads data from stdin and outputs converted data to stdout.
-.Pp
-In case it is run as
-.Em alaw2ulaw
-it converts ALaw input data to uLaw output.
-.Pp
-In case it is run as
-.Em ulaw2alaw
-it converts uLaw input data to ALaw output.
-.Pp
-
-.Sh EXAMPLES
-The command:
-.Bd -literal -offset indent
-ulaw2alaw <file.ulaw >file.alaw
-.Ed
-.Pp
-converts uLaw input data file file.ulaw to ALaw output file file.alaw.
-
-.Sh STANDARDS
-ITU Recommendations G.711
-
-.Sh AUTHOR
-The
-.Nm
-utility and this man page were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/isdnd/Makefile b/usr.sbin/i4b/isdnd/Makefile
deleted file mode 100644
index 37d3471357c2..000000000000
--- a/usr.sbin/i4b/isdnd/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# $Id$
-
-PROG = isdnd
-
-SRCS = rc_parse.y rc_scan.l main.c rc_config.c log.c curses.c \
- process.c rates.c msghdl.c fsm.c support.c timer.c \
- exec.c dial.c monitor.c pcause.c controller.c alias.c \
- y.tab.h
-
-COPTS += -I${.CURDIR}/../isdnmonitor -I${.CURDIR}/../isdntel -I${.OBJDIR}
-
-# compile debug support
-COPTS += -DDEBUG
-
-# enable rtprio usage
-COPTS += -DUSE_RTPRIO
-
-MAN8 = isdnd.8
-MAN5 = isdnd.rc.5 isdnd.rates.5 isdnd.acct.5
-
-.if !defined(I4B_WITHOUT_CURSES)
-COPTS += -DUSE_CURSES
-DPADD = ${LIBCURSES} ${LIBTERMCAP}
-LDADD = -lcurses -ltermcap
-.endif
-
-.if defined(I4B_EXTERNAL_MONITOR)
-COPTS += -DI4B_EXTERNAL_MONITOR
-.if defined(I4B_NOTCPIP_MONITOR)
-COPTS += -DI4B_NOTCPIP_MONITOR
-.endif
-.endif
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/i4b/isdnd/alias.c b/usr.sbin/i4b/isdnd/alias.c
deleted file mode 100644
index b802776de7b2..000000000000
--- a/usr.sbin/i4b/isdnd/alias.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * isdnd - common aliasfile handling
- * =================================
- *
- * NOTE: this has to stay in sync with isdntel/alias.c to be able
- * to share a common aliasfile!
- *
- * $Id: alias.c,v 1.5 1998/12/05 18:03:03 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:05:40 1998]
- *
- *----------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-static struct alias *firsta = NULL;
-
-#define MAXBUFSZ 256
-
-static void free_alias(struct alias *ptr);
-
-/*---------------------------------------------------------------------------*
- * read in and init aliases
- *---------------------------------------------------------------------------*/
-void
-init_alias(char *filename)
-{
- FILE *fp;
- char buffer[MAXBUFSZ + 1];
- char number[MAXBUFSZ + 1];
- char name[MAXBUFSZ + 1];
- char *s, *d;
- struct alias *newa = NULL;
- struct alias *lasta = NULL;
-
- firsta = NULL;
-
- if((fp = fopen(filename, "r")) == NULL)
- {
- log(LL_ERR, "init_alias: error opening aliasfile %s: %s!", filename, strerror(errno));
- exit(1);
- }
-
- while((fgets(buffer, MAXBUFSZ, fp)) != NULL)
- {
- if(buffer[0] == '#' || buffer[0] == ' ' ||
- buffer[0] == '\t' || buffer[0] == '\n')
- {
- continue;
- }
-
- s = buffer;
- d = number;
-
- while(*s && (isdigit(*s)))
- *d++ = *s++;
-
- *d = '\0';
-
- while(*s && (isspace(*s)))
- s++;
-
- d = name;
-
- while(*s && (isprint(*s)))
- *d++ = *s++;
-
- *d = '\0';
-
- if((strlen(number) > 1) && (strlen(name) > 1))
- {
- if((newa = (struct alias *) malloc(sizeof(struct alias))) == NULL)
- {
- log(LL_ERR, "init_alias: malloc failed for struct alias!\n");
- exit(1);
- }
-
- if((newa->number = (char *) malloc(strlen(number)+1)) == NULL)
- {
- log(LL_ERR, "init_alias: malloc failed for number alias!\n");
- exit(1);
- }
-
- if((newa->name = (char *) malloc(strlen(name)+1)) == NULL)
- {
- log(LL_ERR, "init_alias: malloc failed for name alias!\n");
- exit(1);
- }
-
- strcpy(newa->name, name);
- strcpy(newa->number, number);
- newa->next = NULL;
-
- if(firsta == NULL)
- {
- firsta = newa;
- }
- else
- {
- lasta->next = newa;
- }
- lasta = newa;
- }
- }
- fclose(fp);
-}
-
-/*---------------------------------------------------------------------------*
- * free all aliases
- *---------------------------------------------------------------------------*/
-void
-free_aliases(void)
-{
- free_alias(firsta);
-}
-
-/*---------------------------------------------------------------------------*
- * free aliases
- *---------------------------------------------------------------------------*/
-static void
-free_alias(struct alias *ptr)
-{
-
- if(ptr == NULL)
- return;
-
- if(ptr->next != NULL)
- free_alias(ptr->next);
-
- if(ptr->number != NULL)
- free(ptr->number);
-
- if(ptr->name != NULL)
- free(ptr->name);
-
- free(ptr);
-}
-
-/*---------------------------------------------------------------------------*
- * try to find alias for number. if no alias found, return number.
- *---------------------------------------------------------------------------*/
-char *
-get_alias(char *number)
-{
- struct alias *ca = NULL;
-
- if(firsta == NULL)
- return(number);
-
- ca = firsta;
-
- for(;;)
- {
- if(strlen(number) == strlen(ca->number))
- {
- if(!(strcmp(number, ca->number)))
- return(ca->name);
- }
- if(ca->next == NULL)
- break;
- ca = ca->next;
- }
- return(number);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/config.h b/usr.sbin/i4b/isdnd/config.h
deleted file mode 100644
index 22c947af84b3..000000000000
--- a/usr.sbin/i4b/isdnd/config.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - compile time configuration header file
- * ---------------------------------------------------
- *
- * $Id: config.h,v 1.6 1998/12/05 18:03:05 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:05:56 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _CONFIG_H_
-#define _CONFIG_H_
-
-/* general values */
-
-#define UMASK 022 /* file creation perm mask */
-#define CFG_ENTRY_MAX 32 /* max no of config entries */
-#define ISDN_CTRL_MAX 4 /* max no of controllers */
-#define MAX_RE 8 /* max regular expression entries */
-
-/* monitor max values */
-
-#define MAX_MHOSTS 8 /* max allowed monitor hosts */
-
-/* timouts */
-
-#define TIMEOUT_CONNECT_ACTIVE 30 /* seconds to wait for MSG_CONN_ACT */
-
-/* utility programs forked */
-
-#define REGPROG_DEF "program" /* default program to use for regexpr */
-#define ANSWERPROG_DEF "answer" /* default telephone answer program */
-
-#endif /* _CONFIG_H_ */
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/controller.c b/usr.sbin/i4b/isdnd/controller.c
deleted file mode 100644
index b3cfcf99b7e3..000000000000
--- a/usr.sbin/i4b/isdnd/controller.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - controller state support routines
- * ----------------------------------------------
- *
- * $Id: controller.c,v 1.10 1998/12/05 18:03:06 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:06:10 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-/*--------------------------------------------------------------------------*
- * init controller state table entry
- *--------------------------------------------------------------------------*/
-int
-init_controller_state(int controller, int ctrl_type, int card_type, int tei)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "init_controller_state: invalid controller number [%d]!", controller);
- return(ERROR);
- }
-
- /* init controller tab */
-
- if(ctrl_type == CTRL_PASSIVE)
- {
- if((card_type > CARD_TYPEP_UNK) &&
- (card_type <= CARD_TYPEP_MAX))
- {
- isdn_ctrl_tab[controller].ctrl_type = ctrl_type;
- isdn_ctrl_tab[controller].card_type = card_type;
- isdn_ctrl_tab[controller].state = CTRL_UP;
- isdn_ctrl_tab[controller].stateb1 = CHAN_IDLE;
- isdn_ctrl_tab[controller].stateb2 = CHAN_IDLE;
- isdn_ctrl_tab[controller].freechans = MAX_CHANCTRL;
- isdn_ctrl_tab[controller].tei = tei;
- log(LL_DMN, "init_controller_state: controller %d is %s",
- controller,
- name_of_controller(isdn_ctrl_tab[controller].ctrl_type,
- isdn_ctrl_tab[controller].card_type));
- }
- else
- {
- log(LL_ERR, "init_controller_state: unknown card type %d", card_type);
- return(ERROR);
- }
-
- }
- else if(ctrl_type == CTRL_DAIC)
- {
- isdn_ctrl_tab[controller].ctrl_type = ctrl_type;
- isdn_ctrl_tab[controller].card_type = card_type;
- isdn_ctrl_tab[controller].state = CTRL_DOWN;
- isdn_ctrl_tab[controller].stateb1 = CHAN_IDLE;
- isdn_ctrl_tab[controller].stateb2 = CHAN_IDLE;
- isdn_ctrl_tab[controller].freechans = MAX_CHANCTRL;
- isdn_ctrl_tab[controller].tei = -1;
- log(LL_DMN, "init_controller_state: controller %d is %s",
- controller,
- name_of_controller(isdn_ctrl_tab[controller].ctrl_type,
- isdn_ctrl_tab[controller].card_type));
- }
- else
- {
- /* XXX active controller init here !!! */
-
- log(LL_ERR, "init_controller_state: unknown controller type %d", ctrl_type);
- return(ERROR);
- }
- return(GOOD);
-}
-
-/*--------------------------------------------------------------------------*
- * set controller state to UP/DOWN
- *--------------------------------------------------------------------------*/
-int
-set_controller_state(int controller, int state)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "set_controller_state: invalid controller number [%d]!", controller);
- return(ERROR);
- }
-
- if(state == CTRL_UP)
- {
- isdn_ctrl_tab[controller].state = CTRL_UP;
- DBGL(DL_CNST, (log(LL_DBG, "set_controller_state: controller [%d] set UP!", controller)));
- }
- else if (state == CTRL_DOWN)
- {
- isdn_ctrl_tab[controller].state = CTRL_DOWN;
- DBGL(DL_CNST, (log(LL_DBG, "set_controller_state: controller [%d] set DOWN!", controller)));
- }
- else
- {
- log(LL_ERR, "set_controller_state: invalid controller state [%d]!", state);
- return(ERROR);
- }
- return(GOOD);
-}
-
-/*--------------------------------------------------------------------------*
- * get controller state
- *--------------------------------------------------------------------------*/
-int
-get_controller_state(int controller)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "set_controller_state: invalid controller number [%d]!", controller);
- return(ERROR);
- }
- return(isdn_ctrl_tab[controller].state);
-}
-
-/*--------------------------------------------------------------------------*
- * decrement number of free channels for controller
- *--------------------------------------------------------------------------*/
-int
-decr_free_channels(int controller)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "decr_free_channels: invalid controller number [%d]!", controller);
- return(ERROR);
- }
- if(isdn_ctrl_tab[controller].freechans > 0)
- {
- (isdn_ctrl_tab[controller].freechans)--;
- DBGL(DL_CNST, (log(LL_DBG, "decr_free_channels: ctrl %d, now %d chan free", controller, isdn_ctrl_tab[controller].freechans)));
- return(GOOD);
- }
- else
- {
- log(LL_ERR, "decr_free_channels: controller [%d] already 0 free chans!", controller);
- return(ERROR);
- }
-}
-
-/*--------------------------------------------------------------------------*
- * increment number of free channels for controller
- *--------------------------------------------------------------------------*/
-int
-incr_free_channels(int controller)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "incr_free_channels: invalid controller number [%d]!", controller);
- return(ERROR);
- }
- if(isdn_ctrl_tab[controller].freechans < MAX_CHANCTRL)
- {
- (isdn_ctrl_tab[controller].freechans)++;
- DBGL(DL_CNST, (log(LL_DBG, "incr_free_channels: ctrl %d, now %d chan free", controller, isdn_ctrl_tab[controller].freechans)));
- return(GOOD);
- }
- else
- {
- log(LL_ERR, "incr_free_channels: controller [%d] already 2 free chans!", controller);
- return(ERROR);
- }
-}
-
-/*--------------------------------------------------------------------------*
- * get number of free channels for controller
- *--------------------------------------------------------------------------*/
-int
-get_free_channels(int controller)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "get_free_channels: invalid controller number [%d]!", controller);
- return(ERROR);
- }
- DBGL(DL_CNST, (log(LL_DBG, "get_free_channels: ctrl %d, %d chan free", controller, isdn_ctrl_tab[controller].freechans)));
- return(isdn_ctrl_tab[controller].freechans);
-}
-
-/*--------------------------------------------------------------------------*
- * set channel state to busy
- *--------------------------------------------------------------------------*/
-int
-set_channel_busy(int controller, int channel)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "set_channel_busy: invalid controller number [%d]!", controller);
- return(ERROR);
- }
-
- switch(channel)
- {
- case CHAN_B1:
- if(isdn_ctrl_tab[controller].stateb1 == CHAN_RUN)
- {
- DBGL(DL_CNST, (log(LL_DBG, "set_channel_busy: controller [%d] channel B1 already busy!", controller)));
- }
- else
- {
- isdn_ctrl_tab[controller].stateb1 = CHAN_RUN;
- DBGL(DL_CNST, (log(LL_DBG, "set_channel_busy: controller [%d] channel B1 set to BUSY!", controller)));
- }
- break;
-
- case CHAN_B2:
- if(isdn_ctrl_tab[controller].stateb2 == CHAN_RUN)
- {
- DBGL(DL_CNST, (log(LL_DBG, "set_channel_busy: controller [%d] channel B2 already busy!", controller)));
- }
- else
- {
- isdn_ctrl_tab[controller].stateb2 = CHAN_RUN;
- DBGL(DL_CNST, (log(LL_DBG, "set_channel_busy: controller [%d] channel B2 set to BUSY!", controller)));
- }
- break;
-
- default:
- log(LL_ERR, "set_channel_busy: controller [%d], invalid channel [%d]!", controller, channel);
- return(ERROR);
- break;
- }
- return(GOOD);
-}
-
-/*--------------------------------------------------------------------------*
- * set channel state to idle
- *--------------------------------------------------------------------------*/
-int
-set_channel_idle(int controller, int channel)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "set_channel_idle: invalid controller number [%d]!", controller);
- return(ERROR);
- }
-
- switch(channel)
- {
- case CHAN_B1:
- if(isdn_ctrl_tab[controller].stateb1 == CHAN_IDLE)
- {
- DBGL(DL_CNST, (log(LL_DBG, "set_channel_idle: controller [%d] channel B1 already idle!", controller)));
- }
- else
- {
- isdn_ctrl_tab[controller].stateb1 = CHAN_IDLE;
- DBGL(DL_CNST, (log(LL_DBG, "set_channel_idle: controller [%d] channel B1 set to IDLE!", controller)));
- }
- break;
-
- case CHAN_B2:
- if(isdn_ctrl_tab[controller].stateb2 == CHAN_IDLE)
- {
- DBGL(DL_CNST, (log(LL_DBG, "set_channel_idle: controller [%d] channel B2 already idle!", controller)));
- }
- else
- {
- isdn_ctrl_tab[controller].stateb2 = CHAN_IDLE;
- DBGL(DL_CNST, (log(LL_DBG, "set_channel_idle: controller [%d] channel B2 set to IDLE!", controller)));
- }
- break;
-
- default:
- log(LL_ERR, "set_channel_idle: controller [%d], invalid channel [%d]!", controller, channel);
- return(ERROR);
- break;
- }
- return(GOOD);
-}
-
-/*--------------------------------------------------------------------------*
- * return channel state
- *--------------------------------------------------------------------------*/
-int
-ret_channel_state(int controller, int channel)
-{
- if((controller < 0) || (controller >= ncontroller))
- {
- log(LL_ERR, "ret_channel_state: invalid controller number [%d]!", controller);
- return(ERROR);
- }
-
- switch(channel)
- {
- case CHAN_B1:
- return(isdn_ctrl_tab[controller].stateb1);
- break;
-
- case CHAN_B2:
- return(isdn_ctrl_tab[controller].stateb2);
- break;
-
- default:
- log(LL_ERR, "ret_channel_state: controller [%d], invalid channel [%d]!", controller, channel);
- return(ERROR);
- break;
- }
- return(ERROR);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/curses.c b/usr.sbin/i4b/isdnd/curses.c
deleted file mode 100644
index b5053828aa52..000000000000
--- a/usr.sbin/i4b/isdnd/curses.c
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - curses fullscreen output
- * -------------------------------------
- *
- * $Id: curses.c,v 1.27 1998/12/05 18:03:08 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:06:24 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#ifdef USE_CURSES
-
-#include "isdnd.h"
-
-#define CHPOS(cfgp) (((cfgp)->isdncontrollerused*2) + (cfgp)->isdnchannelused)
-
-/*---------------------------------------------------------------------------*
- * init curses fullscreen display
- *---------------------------------------------------------------------------*/
-void
-init_screen(void)
-{
- char buffer[512];
- int uheight, lheight;
- int i, j;
- cfg_entry_t *p;
-
- initscr(); /* curses init */
-
- if((COLS < 80) || (LINES < 24))
- {
- log(LL_ERR, "ERROR, minimal screensize must be 80x24, is %dx%d, terminating!",COLS, LINES);
- do_exit(1);
- }
-
- noecho();
- raw();
-
- uheight = ncontroller * 2; /* cards * b-channels */
- lheight = LINES - uheight - 6 + 1; /* rest of display */
-
- if((upper_w = newwin(uheight, COLS, UPPER_B, 0)) == NULL)
- {
- log(LL_ERR, "ERROR, curses init upper window, terminating!");
- exit(1);
- }
-
- if((mid_w = newwin(1, COLS, UPPER_B+uheight+1, 0)) == NULL)
- {
- log(LL_ERR, "ERROR, curses init mid window, terminating!");
- exit(1);
- }
-
- if((lower_w = newwin(lheight, COLS, UPPER_B+uheight+3, 0)) == NULL)
- {
- log(LL_ERR, "ERROR, curses init lower window, LINES = %d, lheight = %d, uheight = %d, terminating!", LINES, lheight, uheight);
- exit(1);
- }
-
- scrollok(lower_w, 1);
-
- sprintf(buffer, "----- isdn controller channel state ------------- isdnd %02d.%02d.%d [pid %d] -", VERSION, REL, STEP, (int)getpid());
-
- while(strlen(buffer) < COLS)
- strcat(buffer, "-");
-
- move(0, 0);
- standout();
- addstr(buffer);
- standend();
-
- move(1, 0);
- /* 01234567890123456789012345678901234567890123456789012345678901234567890123456789 */
- addstr("c tei b remote iface dir outbytes obps inbytes ibps units");
-
- sprintf(buffer, "----- isdn userland interface state ------------------------------------------");
- while(strlen(buffer) < COLS)
- strcat(buffer, "-");
-
- move(uheight+2, 0);
- standout();
- addstr(buffer);
- standend();
-
- sprintf(buffer, "----- isdnd logfile display --------------------------------------------------");
- while(strlen(buffer) < COLS)
- strcat(buffer, "-");
-
- move(uheight+4, 0);
- standout();
- addstr(buffer);
- standend();
-
- move(uheight+5, 0);
- addstr("Date Time Typ Information Description");
-
- refresh();
-
- for(i=0, j=0; i <= ncontroller; i++, j+=2)
- {
- if(isdn_ctrl_tab[i].tei == -1)
- mvwprintw(upper_w, j, H_CNTL, "%d --- 1 ", i);
- else
- mvwprintw(upper_w, j, H_CNTL, "%d %3d 1 ", i, isdn_ctrl_tab[i].tei);
- mvwprintw(upper_w, j+1, H_CNTL, " L12 2 ");
- }
- wrefresh(upper_w);
-
- for(i=0, j=0; i < nentries; i++) /* walk thru all entries */
- {
- p = &cfg_entry_tab[i]; /* get ptr to enry */
-
- mvwprintw(mid_w, 0, j, "%s%d ", bdrivername(p->usrdevicename), p->usrdeviceunit);
-
- p->fs_position = j;
-
- j += ((strlen(bdrivername(p->usrdevicename)) + (p->usrdeviceunit > 9 ? 2 : 1) + 1));
- }
- wrefresh(mid_w);
-
- wmove(lower_w, 0, 0);
- wrefresh(lower_w);
-
- curses_ready = 1;
-}
-
-/*---------------------------------------------------------------------------*
- * curses menu for fullscreen command mode
- *---------------------------------------------------------------------------*/
-void
-do_menu(void)
-{
- static char *menu[WMITEMS] =
- {
- "1 - (D)isplay refresh",
- "2 - (H)angup (choose a channel)",
- "3 - (R)eread config file",
- "4 - (Q)uit the program",
- };
-
- WINDOW *menu_w;
- int c;
- int mpos;
- fd_set set;
- struct timeval timeout;
-
- /* create a new window in the lower screen area */
-
- if((menu_w = newwin(WMENU_HGT, WMENU_LEN, WMENU_POSLN, WMENU_POSCO )) == NULL)
- {
- log(LL_WRN, "ERROR, curses init menu window!");
- return;
- }
-
- /* create a border around the window */
-
- box(menu_w, '|', '-');
-
- /* add a title */
-
- wstandout(menu_w);
- mvwaddstr(menu_w, 0, (WMENU_LEN / 2) - (strlen(WMENU_TITLE) / 2), WMENU_TITLE);
- wstandend(menu_w);
-
- /* fill the window with the menu options */
-
- for(mpos=0; mpos <= (WMITEMS-1); mpos++)
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
-
- /* highlight the first menu option */
-
- mpos = 0;
- wstandout(menu_w);
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
- wstandend(menu_w);
-
- /* input loop */
-
- for(;;)
- {
- wrefresh(menu_w);
-
- FD_ZERO(&set);
- FD_SET(STDIN_FILENO, &set);
- timeout.tv_sec = WMTIMEOUT;
- timeout.tv_usec = 0;
-
- /* if no char is available within timeout, exit menu*/
-
- if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
- goto mexit;
-
- c = wgetch(menu_w);
-
- switch(c)
- {
- case ' ':
- case '\t': /* hilite next option */
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
- mpos++;
- if(mpos >= WMITEMS)
- mpos = 0;
- wstandout(menu_w);
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
- wstandend(menu_w);
- break;
-
- case ('0'+WREFRESH+1): /* display refresh */
- case 'D':
- case 'd':
- wrefresh(curscr);
- goto mexit;
-
- case ('0'+WQUIT+1): /* quit program */
- case 'Q':
- case 'q':
- do_exit(0);
- goto mexit;
-
- case ('0'+WHANGUP+1): /* hangup connection */
- case 'H':
- case 'h':
- display_chans();
- goto mexit;
-
- case ('0'+WREREAD+1): /* reread config file */
- case 'R':
- case 'r':
- rereadconfig(42);
- goto mexit;
-
- case '\n':
- case '\r': /* exec highlighted option */
- switch(mpos)
- {
- case WREFRESH:
- wrefresh(curscr);
- break;
-
- case WQUIT:
- do_exit(0);
- break;
-
- case WHANGUP:
- display_chans();
- break;
-
- case WREREAD:
- rereadconfig(42);
- break;
- }
- goto mexit;
- break;
-
- default:
- goto mexit;
- break;
- }
- }
-
-mexit:
- /* delete the menu window */
-
- delwin(menu_w);
-
- /* re-display the original lower window contents */
-
- touchwin(lower_w);
- wrefresh(lower_w);
-}
-
-/*---------------------------------------------------------------------------*
- * display the charge in units
- *---------------------------------------------------------------------------*/
-void
-display_charge(cfg_entry_t *cep)
-{
- mvwprintw(upper_w, CHPOS(cep), H_UNITS, "%d", cep->charge);
- wclrtoeol(upper_w);
- wrefresh(upper_w);
-}
-
-/*---------------------------------------------------------------------------*
- * display the calculated charge in units
- *---------------------------------------------------------------------------*/
-void
-display_ccharge(cfg_entry_t *cep, int units)
-{
- mvwprintw(upper_w, CHPOS(cep), H_UNITS, "(%d)", units);
- wclrtoeol(upper_w);
- wrefresh(upper_w);
-}
-
-/*---------------------------------------------------------------------------*
- * display accounting information
- *---------------------------------------------------------------------------*/
-void
-display_acct(cfg_entry_t *cep)
-{
- mvwprintw(upper_w, CHPOS(cep), H_OUT, "%-10d", cep->outbytes);
- mvwprintw(upper_w, CHPOS(cep), H_OUTBPS, "%-4d", cep->outbps);
- mvwprintw(upper_w, CHPOS(cep), H_IN, "%-10d", cep->inbytes);
- mvwprintw(upper_w, CHPOS(cep), H_INBPS, "%-4d", cep->inbps);
- wrefresh(upper_w);
-}
-
-/*---------------------------------------------------------------------------*
- * display connect information
- *---------------------------------------------------------------------------*/
-void
-display_connect(cfg_entry_t *cep)
-{
- char buffer[256];
-
- /* remote telephone number */
-
- if(aliasing)
- {
- if(cep->direction == DIR_IN)
- sprintf(buffer, "%s", get_alias(cep->real_phone_incoming));
- else
- sprintf(buffer, "%s", get_alias(cep->remote_phone_dialout));
- }
- else
- {
- if(cep->direction == DIR_IN)
- sprintf(buffer, "%s/%s", cep->name, cep->real_phone_incoming);
- else
- sprintf(buffer, "%s/%s", cep->name, cep->remote_phone_dialout);
- }
-
- buffer[H_IFN - H_TELN - 1] = '\0';
-
- mvwprintw(upper_w, CHPOS(cep), H_TELN, "%s", buffer);
-
- /* interface */
-
- mvwprintw(upper_w, CHPOS(cep), H_IFN, "%s%d ",
- bdrivername(cep->usrdevicename), cep->usrdeviceunit);
-
- mvwprintw(upper_w, CHPOS(cep), H_IO,
- cep->direction == DIR_OUT ? "out" : "in");
-
- mvwprintw(upper_w, CHPOS(cep), H_OUT, "-");
- mvwprintw(upper_w, CHPOS(cep), H_OUTBPS, "-");
- mvwprintw(upper_w, CHPOS(cep), H_IN, "-");
- mvwprintw(upper_w, CHPOS(cep), H_INBPS, "-");
-
- if(do_bell)
- display_bell();
-
- wrefresh(upper_w);
-}
-
-/*---------------------------------------------------------------------------*
- * erase line at disconnect time
- *---------------------------------------------------------------------------*/
-void
-display_disconnect(cfg_entry_t *cep)
-{
- wmove(upper_w, CHPOS(cep),
- H_TELN);
- wclrtoeol(upper_w);
- wrefresh(upper_w);
-
- if(do_bell)
- display_bell();
-
-}
-
-/*---------------------------------------------------------------------------*
- * display interface up/down information
- *---------------------------------------------------------------------------*/
-void
-display_updown(cfg_entry_t *cep, int updown)
-{
- if(updown)
- wstandend(mid_w);
- else
- wstandout(mid_w);
-
- mvwprintw(mid_w, 0, cep->fs_position, "%s%d ",
- bdrivername(cep->usrdevicename), cep->usrdeviceunit);
-
- wstandend(mid_w);
- wrefresh(mid_w);
-}
-
-/*---------------------------------------------------------------------------*
- * display interface up/down information
- *---------------------------------------------------------------------------*/
-void
-display_l12stat(int controller, int layer, int state)
-{
- if(controller > ncontroller)
- return;
- if(!(layer == 1 || layer == 2))
- return;
-
- if(state)
- wstandout(upper_w);
- else
- wstandend(upper_w);
-
- if(layer == 1)
- {
- mvwprintw(upper_w, (controller*2)+1, H_TEI+1, "1");
- if(!state)
- mvwprintw(upper_w, (controller*2)+1, H_TEI+2, "2");
- }
- else if(layer == 2)
- {
- mvwprintw(upper_w, (controller*2)+1, H_TEI+2, "2");
- if(state)
- mvwprintw(upper_w, (controller*2)+1, H_TEI+1, "1");
- }
-
- wstandend(upper_w);
- wrefresh(upper_w);
-}
-
-/*---------------------------------------------------------------------------*
- * display TEI
- *---------------------------------------------------------------------------*/
-void
-display_tei(int controller, int tei)
-{
- if(controller > ncontroller)
- return;
-
- if(tei == -1)
- mvwprintw(upper_w, controller*2, H_TEI, "---");
- else
- mvwprintw(upper_w, controller*2, H_TEI, "%3d", tei);
-
- wrefresh(upper_w);
-}
-
-/*---------------------------------------------------------------------------*
- * display bell :-)
- *---------------------------------------------------------------------------*/
-void
-display_bell(void)
-{
- static char bell[1] = { 0x07 };
- write(STDOUT_FILENO, &bell[0], 1);
-}
-
-/*---------------------------------------------------------------------------*
- * display channel information for shutdown
- *---------------------------------------------------------------------------*/
-void
-display_chans(void)
-{
- char buffer[80];
- int i;
- int cnt = 0;
- WINDOW *chan_w;
- int nlines, ncols, pos_x, pos_y;
- fd_set set;
- struct timeval timeout;
- cfg_entry_t *cep = NULL;
-
- /* need this later to close the connection */
- struct ctlr_chan {
- int cntl;
- int chn;
- } *cc = NULL;
-
- for (i = 0; i < ncontroller; i++)
- {
- if((get_controller_state(i)) != CTRL_UP)
- continue;
- if((ret_channel_state(i, CHAN_B1)) == CHAN_RUN)
- cnt++;
- if((ret_channel_state(i, CHAN_B2)) == CHAN_RUN)
- cnt++;
- }
-
- if(cnt > 0)
- {
- if ((cc = (struct ctlr_chan *)malloc (cnt *
- sizeof (struct ctlr_chan))) == NULL)
- {
- return;
- }
- nlines = cnt + 4;
- ncols = 60;
- }
- else
- {
- nlines = 5;
- ncols = 22;
- }
-
- pos_y = WMENU_POSLN + 4;
- pos_x = WMENU_POSCO + 10;
-
- /* create a new window in the lower screen area */
-
- if((chan_w = newwin(nlines, ncols, pos_y, pos_x )) == NULL)
- {
- log(LL_WRN, "ERROR, curses init channel window!");
- if (cnt > 0)
- free(cc);
- return;
- }
-
- /* create a border around the window */
-
- box(chan_w, '|', '-');
-
- /* add a title */
-
- wstandout(chan_w);
- mvwaddstr(chan_w, 0, (ncols / 2) - (strlen("Channels") / 2), "Channels");
- wstandend(chan_w);
-
- /* no active channels */
- if (cnt == 0)
- {
- mvwaddstr(chan_w, 2, 2, "No active channels");
- wrefresh(chan_w);
- sleep(1);
-
- /* delete the channels window */
-
- delwin(chan_w);
- return;
- }
-
- nlines = 2;
- ncols = 1;
-
- for (i = 0; i < ncontroller; i++)
- {
- if((get_controller_state(i)) != CTRL_UP)
- continue;
-
- if((ret_channel_state(i, CHAN_B1)) == CHAN_RUN)
- {
- sprintf(buffer, "%d - Controller %d channel %s", ncols, i, "B1");
- mvwaddstr(chan_w, nlines, 2, buffer);
- cc[ncols - 1].cntl = i;
- cc[ncols - 1].chn = CHAN_B1;
- nlines++;
- ncols++;
- }
- if((ret_channel_state(i, CHAN_B2)) == CHAN_RUN)
- {
- sprintf(buffer, "%d - Controller %d channel %s", ncols, i, "B2");
- mvwaddstr(chan_w, nlines, 2, buffer);
- cc[ncols - 1].cntl = i;
- cc[ncols - 1].chn = CHAN_B2;
- nlines++;
- ncols++;
- }
- }
-
- for(;;)
- {
- wrefresh(chan_w);
-
- FD_ZERO(&set);
- FD_SET(STDIN_FILENO, &set);
- timeout.tv_sec = WMTIMEOUT;
- timeout.tv_usec = 0;
-
- /* if no char is available within timeout, exit menu*/
-
- if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
- break;
-
- ncols = wgetch(chan_w);
-
- if (!(isdigit(ncols)))
- {
- display_bell();
- continue;
- }
-
- nlines = ncols - '0';
-
- if ((nlines == 0) || (nlines > cnt))
- {
- display_bell();
- continue;
- }
-
- if((cep = get_cep_by_cc(cc[nlines-1].cntl, cc[nlines-1].chn))
- != NULL)
- {
- log(LL_CHD, "%05d %s manual disconnect (fullscreen menu)", cep->cdid, cep->name);
- cep->hangup = 1;
- break;
- }
- }
-
- free(cc);
-
- /* delete the channels window */
-
- delwin(chan_w);
-}
-
-#endif
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/dial.c b/usr.sbin/i4b/isdnd/dial.c
deleted file mode 100644
index 4308f98e2053..000000000000
--- a/usr.sbin/i4b/isdnd/dial.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - dial handling routines
- * -----------------------------------
- *
- * $Id: dial.c,v 1.6 1998/12/05 18:03:09 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:06:36 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-/*---------------------------------------------------------------------------*
- * select the first remote number to dial according to the
- * dial strategy
- *---------------------------------------------------------------------------*/
-void
-select_first_dialno(cfg_entry_t *cep)
-{
- int i, j;
-
- if(cep->remote_numbers_count < 1)
- {
- log(LL_ERR, "select_first_dialno: remote_numbers_count < 1!");
- return;
- }
-
- if(cep->remote_numbers_count == 1)
- {
- strcpy(cep->remote_phone_dialout, cep->remote_numbers[0].number);
- DBGL(DL_DIAL, (log(LL_DBG, "select_first_dialno: only one no, no = %s", cep->remote_phone_dialout)));
- cep->last_remote_number = 0;
- return;
- }
-
- if(cep->remote_numbers_handling == RNH_FIRST)
- {
- strcpy(cep->remote_phone_dialout, cep->remote_numbers[0].number);
- DBGL(DL_DIAL, (log(LL_DBG, "select_first_dialno: use first, no = %s", cep->remote_phone_dialout)));
- cep->last_remote_number = 0;
- return;
- }
-
- i = cep->last_remote_number;
-
- for(j = cep->remote_numbers_count; j > 0; j--)
- {
- if(cep->remote_numbers[i].flag == RNF_SUCC)
- {
- if(cep->remote_numbers_handling == RNH_LAST)
- {
- strcpy(cep->remote_phone_dialout, cep->remote_numbers[i].number);
- DBGL(DL_DIAL, (log(LL_DBG, "select_first_dialno: use last, no = %s", cep->remote_phone_dialout)));
- cep->last_remote_number = i;
- return;
- }
- else
- {
- if(++i >= cep->remote_numbers_count)
- i = 0;
-
- strcpy(cep->remote_phone_dialout, cep->remote_numbers[i].number);
- DBGL(DL_DIAL, (log(LL_DBG, "select_first_dialno: use next, no = %s", cep->remote_phone_dialout)));
- cep->last_remote_number = i;
- return;
- }
- }
-
- if(++i >= cep->remote_numbers_count)
- i = 0;
- }
- strcpy(cep->remote_phone_dialout, cep->remote_numbers[0].number);
- DBGL(DL_DIAL, (log(LL_DBG, "select_first_dialno: no last found (use 0), no = %s", cep->remote_phone_dialout)));
- cep->last_remote_number = 0;
-}
-
-/*---------------------------------------------------------------------------*
- * select next remote number to dial (last was unsuccesfull)
- *---------------------------------------------------------------------------*/
-void
-select_next_dialno(cfg_entry_t *cep)
-{
- if(cep->remote_numbers_count < 1)
- {
- log(LL_ERR, "select_next_dialno: remote_numbers_count < 1!");
- return;
- }
-
- if(cep->remote_numbers_count == 1)
- {
- strcpy(cep->remote_phone_dialout, cep->remote_numbers[0].number);
- DBGL(DL_DIAL, (log(LL_DBG, "select_next_dialno: only one no, no = %s", cep->remote_phone_dialout)));
- cep->last_remote_number = 0;
- return;
- }
-
- /* mark last try as bad */
-
- cep->remote_numbers[cep->last_remote_number].flag = RNF_IDLE;
-
- /* next one to try */
-
- cep->last_remote_number++;
-
- if(cep->last_remote_number >= cep->remote_numbers_count)
- cep->last_remote_number = 0;
-
- strcpy(cep->remote_phone_dialout, cep->remote_numbers[cep->last_remote_number].number);
-
- DBGL(DL_DIAL, (log(LL_DBG, "select_next_dialno: index=%d, no=%s",
- cep->last_remote_number,
- cep->remote_numbers[cep->last_remote_number].number)));
-}
-
-/*---------------------------------------------------------------------------*
- * dial succeded, store this number as the last successful
- *---------------------------------------------------------------------------*/
-void
-select_this_dialno(cfg_entry_t *cep)
-{
- cep->remote_numbers[cep->last_remote_number].flag = RNF_SUCC;
-
- DBGL(DL_DIAL, (log(LL_DBG, "select_this_dialno: index = %d, no = %s",
- cep->last_remote_number,
- cep->remote_numbers[cep->last_remote_number].number)));
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/exec.c b/usr.sbin/i4b/isdnd/exec.c
deleted file mode 100644
index 1ed81a1ac866..000000000000
--- a/usr.sbin/i4b/isdnd/exec.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * exec.h - supplemental program/script execution
- * ----------------------------------------------
- *
- * $Id: exec.c,v 1.10 1998/12/05 18:03:11 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:06:49 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#define MAX_PIDS 32
-
-static struct pid_tab {
- pid_t pid;
- cfg_entry_t *cep;
-} pid_tab[MAX_PIDS];
-
-/*---------------------------------------------------------------------------*
- * SIGCHLD signal handler
- *---------------------------------------------------------------------------*/
-void
-sigchild_handler(int sig)
-{
- int retstat;
- register int i;
- pid_t pid;
-
- if((pid = waitpid(-1, &retstat, WNOHANG)) <= 0)
- {
- log(LL_ERR, "ERROR, waitpid: %s", strerror(errno));
- do_exit(1);
- }
- else
- {
- if(WIFEXITED(retstat))
- {
- DBGL(DL_PROC, (log(LL_DBG, "normal child (pid=%d) termination, exitstat = %d",
- pid, WEXITSTATUS(retstat))));
- }
- else if(WIFSIGNALED(retstat))
- {
- if(WCOREDUMP(retstat))
- log(LL_WRN, "child (pid=%d) termination due to signal %d (coredump)",
- pid, WTERMSIG(retstat));
- else
- log(LL_WRN, "child (pid=%d) termination due to signal %d",
- pid, WTERMSIG(retstat));
- }
- }
-
- /* check if hangup required */
-
- for(i=0; i < MAX_PIDS; i++)
- {
- if(pid_tab[i].pid == pid)
- {
- if(pid_tab[i].cep->cdid != CDID_UNUSED)
- {
- DBGL(DL_PROC, (log(LL_DBG, "sigchild_handler: scheduling hangup for cdid %d, pid %d",
- pid_tab[i].cep->cdid, pid_tab[i].pid)));
- pid_tab[i].cep->hangup = 1;
- }
- pid_tab[i].pid = 0;
- break;
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * execute prog as a subprocess and pass an argumentlist
- *---------------------------------------------------------------------------*/
-pid_t
-exec_prog(char *prog, char **arglist)
-{
- char tmp[MAXPATHLEN];
- char path[MAXPATHLEN+1];
- pid_t pid;
- int a;
-
- sprintf(path, "%s/%s", ETCPATH, prog);
-
- arglist[0] = path;
-
- tmp[0] = '\0';
-
- for(a=1; arglist[a] != NULL; ++a )
- {
- strcat(tmp, " " );
- strcat(tmp, arglist[a]);
- }
-
- DBGL(DL_PROC, (log(LL_DBG, "exec_prog: %s, args:%s", path, tmp)));
-
- switch(pid = fork())
- {
- case -1: /* error */
- log(LL_ERR, "ERROR, exec_prog/fork: %s", strerror(errno));
- do_exit(1);
- case 0: /* child */
- break;
- default: /* parent */
- return(pid);
- }
-
- /* this is the child now */
-
- if(execvp(path,arglist) < 0 )
- _exit(127);
-
- return(-1);
-}
-
-/*---------------------------------------------------------------------------*
- * run interface up/down script
- *---------------------------------------------------------------------------*/
-int
-exec_connect_prog(cfg_entry_t *cep, const char *prog, int link_down)
-{
- char *argv[32], **av = argv;
- char devicename[MAXPATHLEN], addr[100];
- char *device;
- int s;
- struct ifreq ifr;
-
- /* the obvious things */
- device = bdrivername(cep->usrdevicename);
- sprintf(devicename, "%s%d", device, cep->usrdeviceunit);
- *av++ = (char*)prog;
- *av++ = "-d";
- *av++ = devicename;
- *av++ = "-f";
- *av++ = link_down ? "down" : "up";
-
- /* try to figure AF_INET address of interface */
- addr[0] = '\0';
- memset(&ifr, 0, sizeof ifr);
- ifr.ifr_addr.sa_family = AF_INET;
- strncpy(ifr.ifr_name, devicename, sizeof(ifr.ifr_name));
- s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s >= 0) {
- if (ioctl(s, SIOCGIFADDR, (caddr_t)&ifr) >= 0) {
- struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
- strcpy(addr, inet_ntoa(sin->sin_addr));
- *av++ = "-a";
- *av++ = addr;
- }
- close(s);
- }
-
- /* terminate argv */
- *av++ = NULL;
-
- return exec_prog((char*)prog, argv);
-}
-
-/*---------------------------------------------------------------------------*
- * run answeringmachine application
- *---------------------------------------------------------------------------*/
-int
-exec_answer(cfg_entry_t *cep)
-{
- char *argv[32];
- u_char devicename[MAXPATHLEN];
- int pid;
- char *device;
-
- device = bdrivername(cep->usrdevicename);
-
- sprintf(devicename, "/dev/i4b%s%d", device, cep->usrdeviceunit);
-
- argv[0] = cep->answerprog;
- argv[1] = "-D";
- argv[2] = devicename;
- argv[3] = "-d";
- argv[4] = "unknown";
- argv[5] = "-s";
- argv[6] = "unknown";
- argv[7] = NULL;
-
- /* if destination telephone number avail, add it as argument */
-
- if(*cep->local_phone_incoming)
- argv[4] = cep->local_phone_incoming;
-
- /* if source telephone number avail, add it as argument */
-
- if(*cep->real_phone_incoming)
- argv[6] = cep->real_phone_incoming;
-
- if(*cep->display)
- {
- argv[7] = "-t";
- argv[8] = cep->display;
- argv[9] = NULL;
- }
-
- /* exec program */
-
- DBGL(DL_PROC, (log(LL_DBG, "exec_answer: prog=[%s]", cep->answerprog)));
-
- pid = exec_prog(cep->answerprog, argv);
-
- /* enter pid and conf ptr entry addr into table */
-
- if(pid != -1)
- {
- int i;
-
- for(i=0; i < MAX_PIDS; i++)
- {
- if(pid_tab[i].pid == 0)
- {
- pid_tab[i].pid = pid;
- pid_tab[i].cep = cep;
- break;
- }
- }
- return(GOOD);
- }
- return(ERROR);
-}
-
-/*---------------------------------------------------------------------------*
- * check if a connection has an outstanding process, if yes, kill it
- *---------------------------------------------------------------------------*/
-void
-check_and_kill(cfg_entry_t *cep)
-{
- int i;
-
- for(i=0; i < MAX_PIDS; i++)
- {
- if(pid_tab[i].cep == cep)
- {
- pid_t kp;
-
- DBGL(DL_PROC, (log(LL_DBG, "check_and_kill: killing pid %d", pid_tab[i].pid)));
-
- kp = pid_tab[i].pid;
- pid_tab[i].pid = 0;
- kill(kp, SIGHUP);
- break;
- }
- }
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/fsm.c b/usr.sbin/i4b/isdnd/fsm.c
deleted file mode 100644
index 13d57783cd9b..000000000000
--- a/usr.sbin/i4b/isdnd/fsm.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * FSM for isdnd
- * -------------
- *
- * $Id: fsm.c,v 1.15 1998/12/05 18:03:12 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:07:31 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-/* table of state descriptions */
-
-static char *state_text[N_STATES] = {
- "idle",
- "dialing",
- "waitdialretry",
- "dialretry",
-
- "pcb-dialing",
- "pcb-dialfail",
- "pcb-waitcall",
-
- "acb-waitdisc",
- "acb-waitdial",
- "acb-dialing",
- "acb-dialfail",
-
- "accepted",
- "connected",
- "waitdisconnect",
- "down",
- "alert",
-
- "Illegal State"
-};
-
-/* table of event descriptions */
-
-static char *event_text[N_EVENTS] = {
-
- /* incoming messages */
-
- "msg-con-ind",
- "msg-con-act-ind",
- "msg-disc-ind",
- "msg-dialout",
-
- /* local events */
-
- "timeout",
- "disconnect-req",
- "callback-req",
- "alert-req",
-
- /* illegal */
-
- "Illegal Event"
-};
-
-/*---------------------------------------------------------------------------*
- * illegal state default action
- *---------------------------------------------------------------------------*/
-static void
-F_ill(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_ill: Illegal State reached !!!")));
-}
-
-/*---------------------------------------------------------------------------*
- * No change, No action
- *---------------------------------------------------------------------------*/
-static void
-F_NcNa(cfg_entry_t *cep)
-{
-}
-
-/*---------------------------------------------------------------------------*
- * incoming CONNECT, accepting call
- *---------------------------------------------------------------------------*/
-static void
-F_MCI(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_MCI: tx SETUP_RESP_ACCEPT")));
- sendm_connect_resp(cep, cep->cdid, SETUP_RESP_ACCEPT, 0);
- start_timer(cep, TIMEOUT_CONNECT_ACTIVE);
-}
-
-/*---------------------------------------------------------------------------*
- * incoming connect active, call is now active
- *---------------------------------------------------------------------------*/
-static void
-F_MCAI(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_MCAI: Connection active!")));
-
- stop_timer(cep);
-
- if((cep->dialin_reaction == REACT_ANSWER) &&
- (cep->b1protocol == BPROT_NONE))
- {
- exec_answer(cep);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * timeout
- *---------------------------------------------------------------------------*/
-static void
-F_TIMO(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_TIMO: Timout occured!")));
- sendm_disconnect_req(cep, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- cep->cdid = CDID_UNUSED;
-}
-
-/*---------------------------------------------------------------------------*
- * incoming disconnect indication
- *---------------------------------------------------------------------------*/
-static void
-F_IDIS(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_IDIS: disconnect indication")));
- cep->cdid = CDID_UNUSED;
-}
-
-/*---------------------------------------------------------------------------*
- * local disconnect request
- *---------------------------------------------------------------------------*/
-static void
-F_DRQ(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_DRQ: local disconnect request")));
- sendm_disconnect_req(cep, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
-}
-
-/*---------------------------------------------------------------------------*
- * disconnect indication after local disconnect req
- *---------------------------------------------------------------------------*/
-static void
-F_MDI(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_MDI: disconnect indication, local disconnected")));
- cep->cdid = CDID_UNUSED;
-}
-
-/*---------------------------------------------------------------------------*
- * local requested outgoing dial
- *---------------------------------------------------------------------------*/
-static void
-F_DIAL(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_DIAL: local dial out request")));
-
- if(cep->dialrandincr)
- cep->randomtime = (random() & RANDOM_MASK) + cep->recoverytime;
-
- cep->dial_count = 0;
-
- select_first_dialno(cep);
-
- sendm_connect_req(cep);
-}
-
-/*---------------------------------------------------------------------------*
- * outgoing dial successfull
- *---------------------------------------------------------------------------*/
-static void
-F_DOK(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_DOK: dial out ok")));
- select_this_dialno(cep);
-}
-
-/*---------------------------------------------------------------------------*
- * outgoing dial fail (ST_SUSE !!!)
- *---------------------------------------------------------------------------*/
-static void
-F_DFL(cfg_entry_t *cep)
-{
- cep->last_release_time = time(NULL);
-
- if(cep->dialouttype == DIALOUT_NORMAL)
- {
- cep->dial_count++;
-
- if(cep->dial_count < cep->dialretries)
- {
- /* inside normal retry cycle */
-
- DBGL(DL_STATE, (log(LL_DBG, "F_DFL: dial fail, dial retry")));
- select_next_dialno(cep);
- cep->cdid = CDID_RESERVED;
- cep->state = ST_DIALRTMRCHD;
- return;
- }
-
- /* retries exhausted */
-
- if(!cep->usedown)
- {
- DBGL(DL_STATE, (log(LL_DBG, "F_DFL: dial retry fail, dial retries exhausted")));
- dialresponse(cep, DSTAT_TFAIL);
- cep->cdid = CDID_UNUSED;
- cep->dial_count = 0;
- cep->state = ST_IDLE;
- return;
- }
-
- /* interface up/down active */
-
- cep->down_retry_count++;
-
- if(cep->down_retry_count > cep->downtries)
- {
- /* set interface down */
- DBGL(DL_STATE, (log(LL_DBG, "F_DFL: dial retry cycle fail, setting interface down!")));
- dialresponse(cep, DSTAT_PFAIL);
- if_down(cep);
- cep->state = ST_DOWN;
- }
- else
- {
- /* enter new dial retry cycle */
- DBGL(DL_STATE, (log(LL_DBG, "F_DFL: dial retry cycle fail, enter new retry cycle!")));
- select_next_dialno(cep);
- cep->state = ST_DIALRTMRCHD;
- }
-
- cep->dial_count = 0;
- cep->cdid = CDID_RESERVED;
- }
- else /* cdp->dialouttype == DIALOUT_CALLEDBACK */
- {
- DBGL(DL_STATE, (log(LL_DBG, "F_DFL: calledback dial done, wait for incoming call")));
- cep->cdid = CDID_RESERVED;
- cep->state = ST_PCB_WAITCALL;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * local requested outgoing dial
- *---------------------------------------------------------------------------*/
-static void
-F_ACBW(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_ACBW: local callback, wait callback recovery time")));
-
- if(cep->dialrandincr)
- cep->randomtime = (random() & RANDOM_MASK) + cep->recoverytime;
-
- cep->dial_count = 0;
-
- cep->cdid = CDID_RESERVED;
-}
-
-/*---------------------------------------------------------------------------*
- * active callback dialout retry (ST_SUSE !!!)
- *---------------------------------------------------------------------------*/
-static void
-F_ACBR(cfg_entry_t *cep)
-{
- cep->dial_count++;
-
- if(cep->dial_count < cep->dialretries)
- {
- /* inside normal retry cycle */
-
- DBGL(DL_STATE, (log(LL_DBG, "F_ACBR: dial fail, dial retry")));
- select_next_dialno(cep);
- cep->cdid = CDID_RESERVED;
- cep->state = ST_ACB_DIALFAIL;
- return;
- }
-
- /* retries exhausted */
-
- if(!cep->usedown)
- {
- DBGL(DL_STATE, (log(LL_DBG, "F_ACBR: dial retry fail, dial retries exhausted")));
- dialresponse(cep, DSTAT_TFAIL);
- cep->cdid = CDID_UNUSED;
- cep->dial_count = 0;
- cep->state = ST_IDLE;
- return;
- }
-
- /* interface up/down active */
-
- cep->down_retry_count++;
-
- if(cep->down_retry_count > cep->downtries)
- {
- /* set interface down */
- DBGL(DL_STATE, (log(LL_DBG, "F_ACBR: dial retry cycle fail, setting interface down!")));
- dialresponse(cep, DSTAT_PFAIL);
- if_down(cep);
- cep->state = ST_DOWN;
- }
- else
- {
- /* enter new dial retry cycle */
- DBGL(DL_STATE, (log(LL_DBG, "F_ACBR: dial retry cycle fail, enter new retry cycle!")));
- select_next_dialno(cep);
- cep->state = ST_ACB_DIALFAIL;
- }
-
- cep->dial_count = 0;
- cep->cdid = CDID_RESERVED;
-}
-
-/*---------------------------------------------------------------------------*
- * local requested to send ALERT message
- *---------------------------------------------------------------------------*/
-static void
-F_ALRT(cfg_entry_t *cep)
-{
- DBGL(DL_STATE, (log(LL_DBG, "F_ALRT: local send alert request")));
-
- cep->alert_time = cep->alert;
-
- sendm_alert_req(cep);
-}
-
-/*---------------------------------------------------------------------------*
- * isdn daemon state transition table
- *---------------------------------------------------------------------------*/
-struct state_tab {
- void(*func)(cfg_entry_t *cep); /* function to execute */
- int newstate; /* next state */
-} state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE: ST_IDLE ST_DIAL ST_DIALRTMRCHD ST_DIALRETRY ST_PCB_DIAL ST_PCB_DIALFAIL ST_PCB_WAITCALL ST_ACB_WAITDISC ST_ACB_WAITDIAL ST_ACB_DIAL ST_ACB_DIALFAIL ST_ACCEPTED ST_CONNECTED ST_WAITDISCI ST_DOWN ST_ALERT ST_ILLEGAL */
-/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/* messages */
-/* EV_MCI */{{F_MCI, ST_ACCEPTED}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_MCI, ST_ACCEPTED}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_MCI, ST_ACCEPTED}, {F_ill, ST_ILL}},
-/* EV_MCAI */{{F_ill, ST_ILL}, {F_DOK, ST_CONNECTED}, {F_ill, ST_ILL}, {F_DOK, ST_CONNECTED}, {F_DOK, ST_CONNECTED}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_DOK, ST_CONNECTED}, {F_ill, ST_ILL}, {F_MCAI,ST_CONNECTED}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}},
-/* EV_MDI */{{F_ill, ST_ILL}, {F_DFL, ST_SUSE}, {F_ill, ST_ILL}, {F_DFL, ST_SUSE}, {F_DFL, ST_SUSE}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ACBW,ST_ACB_WAITDIAL},{F_ill, ST_ILL}, {F_ACBR, ST_SUSE}, {F_ACBR,ST_SUSE}, {F_IDIS,ST_IDLE}, {F_IDIS,ST_IDLE}, {F_MDI, ST_IDLE}, {F_ill, ST_ILL}, {F_MDI, ST_IDLE}, {F_ill, ST_ILL}},
-/* EV_MDO */{{F_DIAL,ST_DIAL}, {F_NcNa,ST_DIAL}, {F_NcNa,ST_DIALRTMRCHD},{F_NcNa,ST_DIALRETRY}, {F_NcNa,ST_PCB_DIAL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}},
-
-/* local requests */
-/* EV_TIMO */{{F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_TIMO,ST_IDLE}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}},
-/* EV_DRQ */{{F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_DRQ, ST_WAITDISCI}, {F_NcNa,ST_WAITDISCI}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}},
-/* EV_CBRQ */{{F_NcNa,ST_ACB_WAITDIAL},{F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_NcNa,ST_ACB_WAITDIAL},{F_NcNa, ST_ACB_DIAL}, {F_NcNa,ST_ACB_DIALFAIL},{F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}},
-/* EV_ALRT */{{F_ALRT,ST_ALERT}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}},
-
-/* illegal */
-
-/* EV_ILL */{{F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}, {F_ill, ST_ILL}}
-};
-
-/*---------------------------------------------------------------------------*
- * event handler
- *---------------------------------------------------------------------------*/
-void
-next_state(cfg_entry_t *cep, int event)
-{
- int currstate, newstate;
-
- if(event > N_EVENTS)
- {
- log(LL_ERR, "FSM: event > N_EVENTS");
- do_exit(1);
- }
-
- currstate = cep->state;
-
- if(currstate > N_STATES)
- {
- log(LL_ERR, "FSM: currstate > N_STATES");
- do_exit(1);
- }
-
- newstate = state_tab[event][currstate].newstate;
-
- if(newstate > N_STATES)
- {
- log(LL_ERR, "FSM: newstate > N_STATES");
- do_exit(1);
- }
-
- if(newstate != ST_SUSE)
- {
- DBGL(DL_STATE, (log(LL_DBG, "FSM event [%s]: [%s => %s]", event_text[event],
- state_text[currstate],
- state_text[newstate])));
- }
-
- (*state_tab[event][currstate].func)(cep);
-
- if(newstate == ST_ILL)
- {
- log(LL_ERR, "FSM ILLEGAL STATE, event=%s: oldstate=%s => newstate=%s]",
- event_text[event],
- state_text[currstate],
- state_text[newstate]);
- }
-
- if(newstate == ST_SUSE)
- {
- DBGL(DL_STATE, (log(LL_DBG, "FSM (SUSE) event [%s]: [%s => %s]", event_text[event],
- state_text[currstate],
- state_text[cep->state])));
- }
- else
- {
- cep->state = newstate;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return pointer to current state description
- *---------------------------------------------------------------------------*/
-char *
-printstate(cfg_entry_t *cep)
-{
- return((char *) state_text[cep->state]);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/isdnd.8 b/usr.sbin/i4b/isdnd/isdnd.8
deleted file mode 100644
index 9913487e1a64..000000000000
--- a/usr.sbin/i4b/isdnd/isdnd.8
+++ /dev/null
@@ -1,419 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdnd.8,v 1.20 1998/12/18 09:47:09 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 12 21:13:59 1998]
-.\"
-.Dd November 3, 1998
-.Dt isdnd 8
-.Sh NAME
-.Nm isdnd
-.Nd isdn4bsd ISDN connection management daemon
-.Sh SYNOPSIS
-.Nm isdnd
-.Op Fl b
-.Op Fl c Ar configfile
-.Op Fl d Ar debuglevel
-.Op Fl f
-.Op Fl F
-.Op Fl l
-.Op Fl L Ar logfile
-.Op Fl P
-.Op Fl r Ar device
-.Op Fl s Ar facility
-.Op Fl t Ar terminaltype
-.Op Fl u Ar charging unit length
-.Op Fl m
-.Sh DESCRIPTION
-.Nm Isdnd
-is the isdn4bsd package demon which manages all ISDN related connection
-and disconnection of ISDN devices supported by the package.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl b
-Bell: in full-screen mode, ring the bell when connecting
-or disconnecting a call.
-.It Fl c
-Use
-.Ar configfile
-as the name of the runtime configuration filename for
-.Nm isdnd
-instead of the default file
-.Li /etc/isdn/isdnd.rc .
-.It Fl d
-If debugging support is compiled into
-.Nm isdnd
-this option is used to specify the debugging level, or better which kind
-of debugging messages are displayed. The debugging level is the sum of the
-following values:
-.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It Ar 0x001
-general debugging.
-.It Ar 0x002
-rates calculation.
-.It Ar 0x004
-timing calculations.
-.It Ar 0x008
-state transitions.
-.It Ar 0x010
-retry handling.
-.It Ar 0x020
-dialing.
-.It Ar 0x040
-process handling.
-.It Ar 0x080
-isdn4bsd kernel i/o calls.
-.It Ar 0x100
-controller and channel busy/free messages.
-.El
-.Pp
-The value can be specified in any number base supported by the
-.Xr sscanf 3
-library routine.
-.Pp
-In addition, this option accepts also the character 'n' as an argument to
-disable displaying debug messages on the full-screen display.
-.Pp
-.It Fl f
-Specifying this option causes
-.Nm isdnd
-to enter the full-screen mode of operation. When operating in this mode,
-entering the control character
-.Em Control-L
-causes the display to be refreshed and entering
-.Em Carriage-Return
-or
-.Em Enter
-will pop-up a command window. Because the
-.Nm
-daemon will not listen to messages while the command window is active,
-this command window will disappear automatically after 5 seconds without
-any command key press.
-.Pp
-While the command window is active,
-.Em Tab
-or
-.Em Space
-advances to the next menu item. To execute a command, press
-.Em Return
-or
-.Em Enter
-for the highlighted menu item, or enter the number corresponding to the
-item to be executed or enter the capitalized character in the menu item
-description.
-.It Fl l
-If this option is set, logging is not done via the
-.Xr syslogd 8
-facility but instead is appended to a file.
-.It Fl L
-Specifies the name of the logfile which is used when the option
-.Em -l
-is set.
-.It Fl P
-This option prints out the parsed and verified isdnd configuration in the same
-format as the isdnd.rc file. This output can be used as an isdnd.rc file. This
-feature is especially useful when debugging an isdnd.rc file to see, what the
-default settings of options are when they are not set in the isdnd.rc input
-file.
-.Pp
-The
-.Nm
-exits after the printout is done.
-.It Fl F
-This option prevents
-.Nm isdnd
-to detach from the controlling tty and become a daemon.
-.It Fl r
-In conjunction with the
-.Fl t
-option,
-.Ar device
-specifies a terminal device which becomes the controlling tty for
-.Nm isdnd
-and on which the full-screen mode output is displayed.
-.It Fl s
-This option may be used to specify the logging facility in case
-.Xr syslog 3
-logging is configured and another facility than the default LOCAL0
-facility shall be used. The facility is to be specified as an integer in
-the range 0-11 or 16-23 (see the file /usr/include/syslog.h).
-.It Fl t
-In conjunction with the
-.Fl f
-and
-.Fl r
-options,
-.Ar terminaltype
-specifies a terminal type or termcap entry name (such as vt220) for the device
-used for
-.Nm isdnd
-full-screen output. This is useful if an unused (no getty running) tty line is
-used for full-screen output for which no
-.Li TERM
-environment variable exists.
-.It Fl u
-Specifies the length of a charging unit in case the config file entry
-keyword
-.Em unitlenghtsrc
-is set to
-.Em cmdl .
-.It Fl m
-If the isdn daemon is compiled with local or remote monitoring support,
-this option disables all monitoring access. It overrides the config
-file option
-.Em monitor-allowed .
-.El
-.Pp
-.Sh INTERACTION WITH THE KERNEL
-.Nm Isdnd
-communicates with the kernel part of isdn4bsd by receiving status and
-event messages (
-.Xr read 2
-from device /dev/i4b ) and by transmitting commands and responses (
-.Xr ioctl 2
-from device /dev/i4b ).
-.Pp
-The messages and message parameters are documented in the include
-file
-.Em /usr/include/machine/i4b_ioctl.h .
-.Pp
-Supported command and response messages (ioctl's) to the kernel are:
-.Bl -tag -width Ds -compact -offset indent
-.It Ar I4B_CDID_REQ
-Request a unique Call Description IDentifier (cdid) which identifies
-uniquely a single interaction of the local D channel with the exchange.
-.It Ar I4B_CONNECT_REQ
-Actively request a call setup to a remote ISDN subscriber.
-.It Ar I4B_CONNECT_RESP
-Respond to an incoming call, either accept, reject or ignore it.
-.It Ar I4B_DISCONNECT_REQ
-Actively terminate a connection.
-.It Ar I4B_CTRL_INFO_REQ
-Request information about an installed ISDN controller card.
-.It Ar I4B_DIALOUT_RESP
-Give information about call setup to driver who requested dialing out.
-.It Ar I4B_TIMEOUT_UPD
-Update the kernels timeout value(s) in case of dynamically calculated
-shorthold mode timing changes.
-.It Ar I4B_UPDOWN_IND
-Inform the kernel userland drivers about interface soft up/down status
-changes.
-.It Ar I4B_CTRL_DOWNLOAD
-Download firmware to active card(s).
-.It Ar I4B_ACTIVE_DIAGNOSTIC
-Return diagnostic information from active cards.
-.El
-.Pp
-.Pp
-Supported status and event messages from the kernel are:
-.Bl -tag -width Ds -compact -offset indent
-.It Ar MSG_CONNECT_IND
-An incoming call from a remote ISDN user is indicated.
-.It Ar MSG_CONNECT_ACTIVE_IND
-After an incoming call has been accepted locally or an outgoing call has
-been accepted by a remote, the exchange signaled an active connection
-and the corresponding B-channel is switched through.
-.It Ar MSG_DISCONNECT_IND
-A call was terminated.
-.It Ar MSG_DIALOUT_IND
-A userland interface driver requests the daemon to dial out (typically a
-network interface when a packet arrives in its send queue).
-.It Ar MSG_IDLE_TIMEOUT_IND
-A call was terminated by the isdn4bsd kernel driver because a B-channel
-idle timeout occurred.
-.It Ar MSG_ACCT_IND
-Accounting information from a network driver.
-.It Ar MSG_CHARGING_IND
-Charging information from the kernel.
-.El
-.Pp
-.Ss OUTGOING CALLS
-Currently the only possibility to trigger an outgoing call is that an
-isdn4bsd network driver
-.Em (ipr<n>)
-sends a
-.Em MSG_DIALOUT_IND
-to the
-.Nm
-daemon.
-.Pp
-The daemon requests a new CDID from the kernel by using the
-.Em I4B_CDID_REQ
-ioctl message, this CDID is now used in all interactions with the kernel
-to identify this single call until a disconnect occurs.
-.Pp
-After getting the CDID, the daemon looks up several additional information
-in its entry section of the configuration corresponding to that connection
-and issues a
-.Em I4B_CONNECT_REQ
-ioctl message to the kernel. The kernel now dials the remote side and
-if the remote side accepts the call, the kernel sends a
-.Em MSG_CONNECT_ACTIVE_IND
-to the daemon.
-.Pp
-The call is terminated by either the local site timing out or the remote
-side hanging up the connection or the local side actively sending a
-.Em DISCONNECT_REQ
-ioctl message, both events are signaled to the
-.Nm
-by the kernel sending the
-.Em DISCONNECT_IND
-message and the CDID corresponding to the call is no longer valid.
-.Pp
-.Ss INCOMING CALLS
-Incoming calls are signaled to the
-.Nm
-by the kernel transmitting the
-.Em MSG_CONNECT_IND
-message to the daemon.
-.Pp
-With the information contained in this message, the
-.Nm
-searches the entry section of its configuration database and if a match is
-found, it accepts or rejects the call or, of no match is found, it ignores the
-call - all by issuing a
-.Em I4B_CONNECT_RESP
-ioctl message with the appropriate parameters to the kernel.
-.Pp
-In case the daemon decided to accept the message, the kernel signal the then
-active connection by sending a
-.Em MSG_CONNECT_ACTIVE_IND
-message to the daemon.
-.Pp
-The call is terminated by either the local site timing out or the remote
-side hanging up the connection or the local side actively sending a
-.Em DISCONNECT_REQ
-ioctl message, both events are signaled to the
-.Nm
-by the kernel sending the
-.Em DISCONNECT_IND
-message and the CDID corresponding to the call is no longer valid.
-.Pp
-
-.Sh SIGNALS
-
-Sending a HUP signal to
-.Nm
-causes all open connections to be terminated and the configuration file is
-reread. In case aliasfile handling was enabled, the aliasfile is also
-reread.
-
-Sending a USR1 signal to
-.Nm
-causes the accounting file and the logfile (if logging to a file is used
-instead of logging via the
-.Xr syslog 3
-facility) to be closed and reopened to make logfile rotation possible.
-
-.Sh ENVIRONMENT
-The following environment variables affect the execution of
-.Nm isdnd :
-.Bl -tag -width Ds
-.It Ev TERM
-The terminal type when running in full-screen display mode.
-See
-.Xr environ 7
-for more information.
-.El
-
-.Sh FILES
-.Bl -tag -width /etc/isdn/isdnd.rates -compact
-.It Pa /dev/i4b
-The device-file used to communicate with the kernel ISDN driver subsystem.
-
-.It Pa /var/log/messages
-A record of the actions in case of syslogd logging support.
-
-.It Pa /var/log/isdnd.acct
-The default accounting information filename (if accounting is configured).
-
-.It Pa /var/log/isdnd.log
-The default logging filename (if logging to a file is configured).
-
-.It Pa /var/run/isdnd.pid
-The process id of the isdn daemon (also known as "lockfile" to isdnd, preventing multiple invocations of it).
-
-.It Pa /usr/local/lib/isdn
-.It Pa /etc/isdn
-The directory where isdnd expects some supplementary data files and programs
-for telephone answering support.
-
-.It Pa /etc/isdn/isdnd.rc
-The default runtime configuration file.
-
-.It Pa /etc/isdn/isdnd.rates
-The default unit charging rates specification file.
-
-.It Pa /etc/isdn/isdntel.alias
-The default table (if aliasing is enabled) to convert phone number to caller's name.
-.El
-
-.Sh EXAMPLES
-For a first try, the following command should be used to start
-.Nm
-in foreground mode for better debugging the configuration setup:
-.Bd -literal -offset indent
-isdnd -d0xf9 -F
-.Ed
-.Pp
-This will start isdnd with reasonable debugging settings and produce
-output on the current terminal.
-.Nm Isdnd
-can then be terminated by entering Control-C.
-.Pp
-Another example, the command:
-.Bd -literal -offset indent
-isdnd -d0xf9 -f -r /dev/ttyv3 -t vt100
-.Ed
-.Pp
-will start
-.Nm isdnd
-with reasonable debugging messages enabled, full-screen mode of operation,
-full-screen display redirected to /dev/ttyv03 and using a termcap entry
-for vt100 on this display.
-
-.Sh DIAGNOSTICS
-Exit status is 0 on success, 1 on error.
-.Pp
-
-.Sh SEE ALSO
-.Xr syslogd 8 ,
-.Xr isdntrace 8 ,
-.Xr isdntel 8 ,
-.Xr isdnd.rc 5 ,
-.Xr isdnd.rates 5 ,
-.Xr i4bisppp 4 ,
-.Xr i4bipr 4
-
-.Sh BUGS
-Still one or more left.
-
-.Sh AUTHOR
-The
-.Nm
-daemon and this manual page were written by Hellmuth Michaelis. He can
-be contacted at hm@kts.org or hm@hcs.de.
diff --git a/usr.sbin/i4b/isdnd/isdnd.acct.5 b/usr.sbin/i4b/isdnd/isdnd.acct.5
deleted file mode 100644
index 9329e80c8730..000000000000
--- a/usr.sbin/i4b/isdnd/isdnd.acct.5
+++ /dev/null
@@ -1,108 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdnd.acct.5,v 1.6 1998/12/05 18:03:18 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:09:33 1998]
-.\"
-.Dd September 11, 1998
-.Dt isdnd.acct 5
-.Sh NAME
-.Nm isdnd.acct
-.Nd isdn4bsd ISDN management daemon accounting file format
-.Sh DESCRIPTION
-The file
-.Pa isdnd.acct
-contains accounting information which is written if the variable
-.Em useacctfile
-in the
-.Xr isdnd 8
-configuration file
-.Xr isdnd.rc 5
-is set to
-.Em on
-and charging information transmission has been subscribed for the
-ISDN connection (AOCD or AOCE).
-.Pp
-If the variable
-.Em acctall
-is set to
-.Em on ,
-accounting information is written even if the local site was not charged
-or no charging information is available or is not subscribed.
-.Pp
-The general format of an accounting line is a follows:
-.Pp
-.Dl FROM - UNTIL NAME UNITS (SECONDS) (INBYTES/OUTBYTES)
-.Pp
-.Em FROM
-is the time the connection was established in the format
-.Dl Day:Month:Year Hour:Minutes:seconds
-.Pp
-.Em UNTIL
-is the time the connection was closed. The format is the same as
-described for
-.Em FROM
-above.
-.Pp
-.Em NAME
-is the symbolic name got from the
-.Em name
-entry of the
-.Xr isdnd.rc 5
-config file for this connection.
-.Pp
-.Em UNITS
-is the amount of charging units billed for the connection.
-.Pp
-.Em SECONDS
-is the number of seconds the connection lasted.
-.Pp
-.Em INBYTES
-and
-.Em OUTBYTES
-is the (optional) number of bytes that were transferred.
-
-.Sh FILES
-.Bl -tag -width /var/log/isdnd.acct -compact
-.It Pa /var/log/isdnd.acct
-The default accounting information file for the
-.Nm isdnd
-ISDN daemon.
-
-.Sh EXAMPLES
-This is a typical accounting line:
-.Pp
-.Dl 12.06.97 10:41:37 - 12.06.97 10:45:18 GROGGY 2 (65) (4711/1147)
-
-.Sh SEE ALSO
-.Xr isdnd 8 ,
-.Xr isdnd.rc 5
-
-.Sh AUTHOR
-The
-.Xr isdnd 8
-daemon and this manual page were written by Hellmuth Michaelis.
-He can be contacted at hm@kts.org or hm@hcs.de.
-
diff --git a/usr.sbin/i4b/isdnd/isdnd.h b/usr.sbin/i4b/isdnd/isdnd.h
deleted file mode 100644
index 009a2dde10f5..000000000000
--- a/usr.sbin/i4b/isdnd/isdnd.h
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - main header file
- * -----------------------------
- *
- * $Id: isdnd.h,v 1.56 1998/12/16 13:39:46 hm Exp $
- *
- * last edit-date: [Mon Dec 14 10:06:39 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _ISDND_H_
-#define _ISDND_H_
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <strings.h>
-#include <ctype.h>
-#include <syslog.h>
-#include <regex.h>
-
-#ifdef USE_CURSES
-#include <curses.h>
-#endif
-
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#ifdef USE_RTPRIO
-#include <sys/rtprio.h>
-#endif
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include "config.h" /* compile time configuration */
-#include "pathnames.h" /* location of files */
-#include "alias.h" /* alias file processing */
-
-/*---------------------------------------------------------------------------*
- * some general definitions
- *---------------------------------------------------------------------------*/
-#define GOOD 0 /* general "good" or "ok" return*/
-#define ERROR (-1) /* general error return */
-#define WARNING (-2) /* warning return */
-#define INVALID (-1) /* an invalid integer */
-
-/*---------------------------------------------------------------------------*
- * misc
- *---------------------------------------------------------------------------*/
-#define RTPRIO_NOTUSED (-1) /* rtprio is not used for isdnd */
-
-/*---------------------------------------------------------------------------*
- * debug flag bits
- *---------------------------------------------------------------------------*/
-#define DL_MSG 0x0001 /* general debug messages */
-#define DL_RATES 0x0002 /* messages related to rates */
-#define DL_TIME 0x0004 /* messages related to timing */
-#define DL_STATE 0x0008 /* messages related to states changes */
-#define DL_RCVRY 0x0010 /* messages related to dial recovery */
-#define DL_DIAL 0x0020 /* messages related to dial recovery */
-#define DL_PROC 0x0040 /* messages related to process handling */
-#define DL_DRVR 0x0080 /* messages related to kernel i4b msg i/o*/
-#define DL_CNST 0x0100 /* messages related to controller state */
-
-#ifdef DEBUG
-#define DBGL(cond, dolog) if(cond & debug_flags) dolog
-#else
-#define DBGL(cond, dolog)
-#endif
-
-/*---------------------------------------------------------------------------*
- * curses fullscreen display definitions
- *---------------------------------------------------------------------------*/
-
-/* window dimensions */
-#define UPPER_B 2 /* upper window start */
-
-/* horizontal positions for upper window */
-#define H_CNTL 0 /* controller */
-#define H_TEI 2 /* TEI */
-#define H_CHAN (H_TEI+4) /* channel */
-#define H_TELN (H_CHAN+2) /* telephone number */
-#define H_IFN (H_TELN+23) /* interfacename */
-#define H_IO (H_IFN+7) /* incoming or outgoing */
-#define H_OUT (H_IO+4) /* # of bytes out */
-#define H_OUTBPS (H_OUT+11) /* bytes per second out */
-#define H_IN (H_OUTBPS+5) /* # of bytes in */
-#define H_INBPS (H_IN+11) /* bytes per second in */
-#define H_UNITS (H_INBPS+6) /* # of charging units */
-
-/* fullscreen mode menu window */
-#define WMENU_LEN 35 /* width of menu window */
-#define WMENU_TITLE "Command" /* title string */
-#define WMENU_POSLN 10 /* menu position, line */
-#define WMENU_POSCO 5 /* menu position, col */
-#define WMITEMS 4 /* no of menu items */
-#define WMENU_HGT (WMITEMS + 4) /* menu window height */
-
-#define WREFRESH 0
-#define WHANGUP 1
-#define WREREAD 2
-#define WQUIT 3
-
-#define WMTIMEOUT 5 /* timeout in seconds */
-
-/*---------------------------------------------------------------------------*
- * charging rates
- *---------------------------------------------------------------------------*/
-#define NDAYS 7 /* number of days in a week */
-#define NRATES 4 /* number of rate structures supported */
-
-/* struct for rates - each day has one or more */
-struct rates
-{
- int start_hr; /* hour at which this rate starts, e.g. 12 */
- int start_min; /* minute of start ... */
- int end_hr; /* hour at which this rate ends, e.g. 19 */
- int end_min; /* minute of end ... */
- int rate; /* how long can I telephone at this price, seconds */
- struct rates *next;
-};
-
-/*---------------------------------------------------------------------------*
- * the internal identifiers for isdnd log levels. CAUTION: this has to stay
- * in sync with the loglevel to text and sysloglevel table in log.c !!
- *---------------------------------------------------------------------------*/
-enum logids
-{
- LL_ERR, /* error conditions - everything which caused an error */
- LL_WRN, /* warning conditions - nonfatal abnormal conditions */
- LL_DMN, /* normal but significant condition - status of daemon */
- LL_CHD, /* informational - everything regarding call handling */
- LL_DBG /* debug messages - everything which helps debugging */
-};
-
-/*---------------------------------------------------------------------------*
- * state machine events
- *---------------------------------------------------------------------------*/
-enum events
-{
- /* incoming messages */
-
- EV_MCI, /* MSG_CONNECT_IND */
- EV_MCAI, /* MSG_CONNECT_ACTIVE_IND */
- EV_MDI, /* MSG_DISCONNECT_IND */
- EV_MDO, /* MSG_DIALOUT */
-
- /* local requests */
-
- EV_TIMO, /* timer expired */
- EV_DRQ, /* disconnect request */
- EV_CBRQ, /* callback request */
- EV_ALRT, /* alerting request */
-
- /* illegal */
-
- EV_ILL /* illegal event */
-};
-
-#define N_EVENTS (EV_ILL+1) /* no of possible events */
-
-/*---------------------------------------------------------------------------*
- * this struct describes the numbers to try to dial out
- *---------------------------------------------------------------------------*/
-typedef struct {
- char number[TELNO_MAX]; /* remote number to dial */
- int flag; /* usage flag */
-#define RNF_IDLE 0
-#define RNF_SUCC 1 /* last dial was ok */
-} remote_number_t;
-
-/*---------------------------------------------------------------------------*
- * this struct describes numbers allowed to dial in
- *---------------------------------------------------------------------------*/
-typedef struct {
- char number[TELNO_MAX]; /* calling party number */
-} incoming_number_t;
-
-/*---------------------------------------------------------------------------*
- * this structure describes a prematurely aborted called-back dialout
- *---------------------------------------------------------------------------*/
-typedef struct {
- int cdid; /* call handle */
- int controller; /* the controller used to dial out */
- int channel; /* the channel assigned to the outgoing call */
- /* XXX - timeout handling and error recovery? */
-} phantom_t;
-
-/*---------------------------------------------------------------------------*
- * this struct describes one complete configuration entry
- *---------------------------------------------------------------------------*/
-typedef struct cfg_entry {
-
- /* ====== filled in at startup configuration, then static ===========*/
-
- char name[32]; /* id for this entry */
-
- int isdncontroller; /* controller to use 0 ... n */
- int isdnchannel; /* channel to use */
-
- int isdntxdelin; /* tx delay, incoming connections */
- int isdntxdelout; /* tx delay, outgoing connections */
-
- int usrdevicename; /* userland device to use */
- int usrdeviceunit; /* userland unit to use */
-
- int remote_numbers_count; /* number of remote numbers */
-#define MAXRNUMBERS 8 /* max remote numbers */
-
- remote_number_t remote_numbers[MAXRNUMBERS]; /* remote numbers to dial */
-
- int remote_numbers_handling; /* how to handle the remote dialing */
-#define RNH_NEXT 0 /* use next number after last successfull */
-#define RNH_LAST 1 /* use last successfull for next call */
-#define RNH_FIRST 2 /* always use first number for next call */
-
- char local_phone_dialout[TELNO_MAX]; /* our number to tell remote*/
- char local_phone_incoming[TELNO_MAX]; /* answer calls for this local number */
-
-#define MAX_INCOMING 8
- int incoming_numbers_count; /* number of incoming allowed numbers */
- incoming_number_t remote_phone_incoming[MAX_INCOMING]; /* answer calls from this remote machine */
-
- int dialin_reaction; /* what to do with incoming calls */
-#define REACT_ACCEPT 0
-#define REACT_REJECT 1
-#define REACT_IGNORE 2
-#define REACT_ANSWER 3
-#define REACT_CALLBACK 4
-
- int b1protocol; /* hdlc / raw */
-
- int idle_time_in; /* max idle time incoming calls */
- int idle_time_out; /* max idle time outgoing calls */
-
- int unitlength; /* length of a charging unit */
-#define UNITLENGTH_DEFAULT 60 /* last resort unit length */
-
- int earlyhangup; /* time in seconds to hangup */
- /* before the next expected */
- /* charging unit */
-#define EARLYHANGUP_DEFAULT 5
-
- int ratetype; /* type of rate */
-#define NO_RATE (NRATES+1)
-#define INVALID_RATE (-1)
-
- int unitlengthsrc; /* where we get the unit length from */
-#define ULSRC_NONE 0 /* nowhere specified */
-#define ULSRC_CMDL 1 /* specified on commandline */
-#define ULSRC_CMDLMIN 5 /* minimum value from cmdl */
-#define ULSRC_CMDLMAX 3600 /* minimum value from cmdl */
-#define ULSRC_CONF 2 /* get it from config file */
-#define ULSRC_RATE 3 /* get it dynamic from ratesfile*/
-#define ULSRC_DYN 4 /* dynamic calculated from AOCD */
-
- char *answerprog; /* program to use for answering */
- char *connectprog; /* program run after negotiation finished */
- char *disconnectprog; /* program run after shutdown is complete */
-
- int callbackwait; /* time to wait before calling back */
-#define CALLBACKWAIT_MIN 1
-
- int calledbackwait; /* time to wait for remote callback */
-#define CALLEDBACKWAIT_MIN 2
-
- int dialretries; /* no. of dial tries */
-#define DIALRETRIES_DEF 1
-
- int recoverytime; /* time between 2 dial tries */
-#define RECOVERYTIME_MIN 1
-
- int dialrandincr; /* use random dial time incr */
-
- int usedown; /* set interface down yes/no */
- int downtries; /* retries before i/f is set down */
-#define DOWN_TRIES_MIN 2
-#define DOWN_TRIES_MAX 20
- int downtime; /* time i/f is down */
-#define DOWN_TIME_MIN 10 /* 10 seconds */
-#define DOWN_TIME_MAX 3600 /* 1 hour */
-
- int dialouttype; /* type of outgoing connection */
-#define DIALOUT_NORMAL 0 /* normal dialout behaviour */
-#define DIALOUT_CALLEDBACK 1 /* remote is expected to callback */
-
- int alert; /* alert time in sec if nonzero */
-#define MINALERT 5 /* 5 secs min */
-#define MAXALERT (3*60) /* 3 minutes max */
-
- int inout; /* in/out, in-only or out-only */
-#define DIR_INOUT 0
-#define DIR_INONLY 1
-#define DIR_OUTONLY 2
-
-/*===========================================================================*/
-/*============ filled in after start, then dynamic ==========================*/
-/*===========================================================================*/
-
- int cdid; /* cdid for call */
-#define CDID_RESERVED (-1)
-
- int isdncontrollerused; /* the one we are using */
- int isdnchannelused; /* the one we are using */
-
- int fs_position; /* fullscreen position */
-
- int state; /* state of connection */
-#define ST_IDLE 0 /* connection is idle / disconnected */
-
- /* normal dial out to remote */
-#define ST_DIAL 1 /* dialing */
-#define ST_DIALRTMRCHD 2 /* wait for dial retry time reached */
-#define ST_DIALRETRY 3 /* last/first dialing failed, retry */
-
- /* PCB: passive callback, i'm being called back */
-#define ST_PCB_DIAL 4 /* dialing, trigger a callback */
-#define ST_PCB_DIALFAIL 5 /* dialing failed triggering a callbk */
-#define ST_PCB_WAITCALL 6 /* waiting for callback from remote */
-
- /* ACB: active callback, i'm calling back */
-#define ST_ACB_WAITDISC 7 /* got call, wait for disconnect */
-#define ST_ACB_WAITDIAL 8 /* wait until allowed to callback */
-#define ST_ACB_DIAL 9 /* callback to remote */
-#define ST_ACB_DIALFAIL 10 /* callback to remote failed */
-
- /* normal non-dialling states */
-#define ST_ACCEPTED 11 /* remote accepted */
-#define ST_CONNECTED 12 /* connected with remote */
-#define ST_WAITDISCI 13 /* tx disc req, wait for disc ind */
-#define ST_DOWN 14 /* interface is down */
-#define ST_ALERT 15 /* interface is waiting for alert time*/
-
- /* illegal and pseudo states */
-#define ST_ILL 16 /* illegal state */
-#define ST_SUSE 17 /* subroutine sets new state */
-
-#define N_STATES (ST_ILL+1) /* max number of states */
-
- int disc_cause; /* cause from disconnect */
-
- int local_disconnect; /* flag, who disconnected */
-#define DISCON_LOC 0
-#define DISCON_REM 1
-
- int timerval; /* value for timer, 0 if inactive */
- int timerremain; /* remaining time */
-
- int hangup; /* flag, hangup connection asap */
-
- char real_phone_incoming[TELNO_MAX]; /* real remote telno in case of wildcard */
-
- int last_remote_number; /* index of last used dialout number*/
-
- char remote_phone_dialout[TELNO_MAX]; /* used remote number to dial */
-
- int direction; /* incoming or outgoing */
-#define DIR_IN 0
-#define DIR_OUT 1
-
- int charge; /* charge in units */
- int last_charge; /* last charge in units */
-
- int inbytes; /* # of bytes from remote */
- int iinbytes; /* # of bytes from remote on the line */
- int inbps; /* bytes/sec from remote */
- int outbytes; /* # of bytes to remote */
- int ioutbytes; /* # of bytes to remote on the line */
- int outbps; /* bytes/sec to remote */
-
- time_t connect_time; /* time connection was established */
-
- time_t aoc_last; /* last AOCD timestamp */
- time_t aoc_now; /* current AOCD timestamp */
- time_t aoc_diff; /* current unit length */
- time_t aoc_lastdiff; /* last charge unit length */
- int aoc_valid; /* flag: time diff is valid */
-#define AOC_INVALID 0 /* aoc_diff is NOT valid */
-#define AOC_VALID 1 /* aoc_diff is valid */
-
- time_t last_dial_time; /* time of last dialing */
- time_t last_release_time; /* time of last hangup */
-
- int dial_count; /* number of dialout tries */
- int randomtime; /* random() part of recoverytime*/
-#define RANDOM_MASK 0x04 /* bits used from randomtime */
-
- int down_retry_count; /* retry cycle count for usedown*/
- time_t went_down_time; /* time i/f went down */
- phantom_t saved_call; /* outgoing call state if called
- back too early */
-
- int alert_time; /* count down of alert time */
- char display[DISPLAY_MAX];
-} cfg_entry_t;
-
-/*---------------------------------------------------------------------------*
- * this struct describes state of controller with 2 b channels
- *---------------------------------------------------------------------------*/
-typedef struct isdn_ctrl_state {
- int ctrl_type; /* type: active/passive */
- int card_type; /* manufacturer (CARD_XXXX) */
- int state; /* controller state */
-#define CTRL_DOWN 0 /* controller inoparable */
-#define CTRL_UP 1 /* controller may be used */
- int stateb1; /* B-channel 1 */
- int stateb2; /* B-channel 2 */
-#define CHAN_IDLE 0 /* channel is free for usage */
-#define CHAN_RUN 1 /* channel is occupied */
- int freechans; /* number of unused channels */
-#define MAX_CHANCTRL 2 /* free channels per controller */
- int tei; /* tei or -1 if invalid */
-} isdn_ctrl_state_t;
-
-/*---------------------------------------------------------------------------*
- * this struct describes a logging regular expression
- *---------------------------------------------------------------------------*/
-struct rarr {
- int re_flg; /* valid entry flag */
- char *re_expr; /* plain text expression */
- regex_t re; /* compiled expression */
- char *re_prog; /* the program to be executed */
-};
-
-#ifdef I4B_EXTERNAL_MONITOR
-/* for each rights entry we keep one of this structures around: */
-struct monitor_rights {
- char name[FILENAME_MAX]; /* net/host spec or filename */
- int rights; /* bitmask of allowed acces rights */
- u_int32_t net; /* net/host address (host byte order!) */
- u_int32_t mask; /* bitmask 1 = network, 0 = host (host byte order!) */
- int local; /* zero if remote access via tcp/ip */
-};
-#endif
-
-/*---------------------------------------------------------------------------*
- * global variables, storage allocation
- *---------------------------------------------------------------------------*/
-#ifdef MAIN
-
-int isdnfd; /* file handle, /dev/i4b */
-
-char *configfile = CONFIG_FILE_DEF; /* configuration filename */
-int config_error_flag = 0; /* error counter */
-
-#ifdef DEBUG
-int do_debug = 0; /* debug mode flag */
-int debug_flags = 0; /* debug options */
-int debug_noscreen = 0; /* not on fullscreen */
-#endif
-
-int do_bell = 0; /* bell on connect/disconnect */
-
-int do_fork = 1; /* run as daemon/foreground */
-
-int do_ttytype = 0; /* got new terminal type */
-char *ttype = ""; /* termcap entry name string */
-
-int do_rdev = 0; /* redirect output */
-char *rdev = ""; /* new device string */
-
-int do_print = 0; /* config file printout */
-
-int got_unitlen = 0; /* flag, got length of a unit */
-time_t unit_length; /* length of a unit */
-
-cfg_entry_t cfg_entry_tab[CFG_ENTRY_MAX]; /* configuration table */
-isdn_ctrl_state_t isdn_ctrl_tab[ISDN_CTRL_MAX]; /* controller states table */
-
-int ncontroller = 0; /* # of controllers available */
-int nentries = 0; /* # of entries in config tab */
-
-int uselogfile = 0; /* flag, use a logfile */
-char logfile[MAXPATHLEN] = LOG_FILE_DEF; /* log filename */
-FILE *logfp = NULL; /* log file pointer */
-int logfacility = LOG_LOCAL0; /* the syslog facility used */
-int nregex = 0; /* number of reg expr */
-struct rarr rarr[MAX_RE]; /* regexpr & progs table */
-
-char ratesfile[MAXPATHLEN] = RATES_FILE_DEF; /* rates filename */
-char *rate_error = NULL; /* errorcase: error string */
-int got_rate = 0; /* flag, ratesfile found */
-struct rates *rates[NRATES][NDAYS]; /* the rates structure */
-
-int useacctfile = 0; /* flag, write accounting */
-char acctfile[MAXPATHLEN] = ACCT_FILE_DEF; /* accounting filename */
-FILE *acctfp = NULL; /* accounting file pointer */
-int acct_all = 1; /* account all connections */
-
-int aliasing = 0; /* enable alias processing */
-char aliasfile[MAXPATHLEN] = ALIASFILE; /* alias file location */
-
-int do_fullscreen = 0; /* fullscreen log */
-int curses_ready = 0; /* curses initialized */
-
-#ifdef USE_CURSES
-WINDOW *upper_w; /* curses upper window pointer */
-WINDOW *mid_w; /* curses mid window pointer */
-WINDOW *lower_w; /* curses lower window pointer */
-#endif
-
-int rt_prio = RTPRIO_NOTUSED; /* realtime priority */
-
-/* monitor via network */
-
-int do_monitor = 0;
-int inhibit_monitor = 0;
-#ifdef I4B_EXTERNAL_MONITOR
-int monitorport = DEF_MONPORT;
-#else
-int monitorport = -1;
-#endif
-int accepted = 0;
-
-int isdntime = 0; /* flag, log time from exchange */
-
-#else /* !MAIN */
-
-int isdnfd;
-
-char *configfile;
-int config_error_flag;
-
-#ifdef DEBUG
-int do_debug;
-int debug_flags;
-int debug_noscreen;
-#endif
-
-int do_bell;
-
-int do_fork;
-
-int do_ttytype;
-char *ttype;
-
-int do_rdev;
-char *rdev;
-
-int do_print;
-
-int got_unitlen;
-time_t unit_length;
-
-cfg_entry_t cfg_entry_tab[CFG_ENTRY_MAX]; /* configuration table */
-isdn_ctrl_state_t isdn_ctrl_tab[ISDN_CTRL_MAX]; /* controller states table */
-
-int ncontroller;
-int nentries;
-
-int uselogfile;
-char logfile[MAXPATHLEN];
-int logfacility;
-int nregex;
-struct rarr rarr[MAX_RE];
-
-char ratesfile[MAXPATHLEN];
-char *rate_error;
-int got_rate;
-struct rates *rates[NRATES][NDAYS];
-
-int useacctfile;
-char acctfile[MAXPATHLEN];
-FILE *acctfp;
-int acct_all;
-
-int aliasing;
-char aliasfile[MAXPATHLEN];
-
-int do_fullscreen;
-int curses_ready;
-
-#ifdef USE_CURSES
-WINDOW *upper_w;
-WINDOW *mid_w;
-WINDOW *lower_w;
-#endif
-
-int rt_prio;
-
-int do_monitor;
-int inhibit_monitor;
-int monitorport;
-int accepted;
-
-int isdntime;
-
-#endif /* MAIN */
-
-char * bdrivername ( int drivertype );
-void cfg_setval ( int keyword );
-void check_and_kill ( cfg_entry_t *cep );
-void check_pid ( void );
-void close_allactive ( void );
-void configure ( char *filename, int reread );
-void daemonize ( void );
-void dialresponse(cfg_entry_t *cep, int dstat);
-void display_acct ( cfg_entry_t *cep );
-void display_bell ( void );
-void display_ccharge ( cfg_entry_t *cep, int units );
-void display_chans ( void );
-void display_charge ( cfg_entry_t *cep );
-void display_connect ( cfg_entry_t *cep );
-void display_disconnect ( cfg_entry_t *cep );
-void display_l12stat(int controller, int layer, int state);
-void display_tei(int controller, int tei);
-void display_updown ( cfg_entry_t *cep, int updown );
-void hangup_channel ( int channel );
-void do_exit ( int exitval );
-void do_menu ( void );
-int exec_answer ( cfg_entry_t *cep );
-int exec_connect_prog ( cfg_entry_t *cep, const char *prog, int link_down );
-pid_t exec_prog ( char *prog, char **arglist );
-cfg_entry_t * find_by_device_for_dialout ( int drivertype, int driverunit );
-cfg_entry_t * find_matching_entry_incoming ( msg_connect_ind_t *mp );
-cfg_entry_t * find_active_entry_by_driver ( int drivertype, int driverunit );
-void finish_log ( void );
-char * getlogdatetime ( void );
-int get_cdid ( void );
-cfg_entry_t * get_cep_by_cc ( int ctrlr, int chan );
-cfg_entry_t * get_cep_by_driver ( int drivertype, int driverunit );
-cfg_entry_t * get_cep_by_cdid ( int cdid );
-int get_current_rate ( cfg_entry_t *cep, int logit );
-void handle_charge ( cfg_entry_t *cep );
-void handle_recovery ( void );
-void if_up(cfg_entry_t *cep);
-void if_down(cfg_entry_t *cep);
-void init_controller ( void );
-void init_log ( void );
-void init_screen ( void );
-void log ( int what, const char *fmt, ... );
-int main ( int argc, char **argv );
-void msg_accounting ( msg_accounting_ind_t *mp );
-void msg_alert_ind ( msg_alert_ind_t *mp );
-void msg_charging_ind ( msg_charging_ind_t *mp );
-void msg_connect_active_ind ( msg_connect_active_ind_t *mp );
-void msg_connect_ind ( msg_connect_ind_t *mp );
-void msg_pdeact_ind(msg_pdeact_ind_t *md);
-void msg_negcomplete_ind(msg_negcomplete_ind_t *ind);
-void msg_ifstatechg_ind(msg_ifstatechg_ind_t *ind);
-void msg_drvrdisc_req(msg_drvrdisc_req_t *mp);
-void msg_dialout ( msg_dialout_ind_t *mp );
-void msg_disconnect_ind ( msg_disconnect_ind_t *mp );
-void msg_idle_timeout_ind ( msg_idle_timeout_ind_t *mp );
-void msg_l12stat_ind(msg_l12stat_ind_t *ml);
-void msg_teiasg_ind(msg_teiasg_ind_t *mt);
-void msg_proceeding_ind ( msg_proceeding_ind_t *mp );
-const char * name_of_controller(int ctrl_type, int card_type);
-void next_state ( cfg_entry_t *cep, int event );
-char * print_i4b_cause( cause_t code );
-char * printstate ( cfg_entry_t *cep );
-int readrates ( char *filename );
-int ret_channel_state(int controller, int channel);
-void reopenfiles ( int dummy );
-void rereadconfig ( int dummy );
-void select_first_dialno ( cfg_entry_t *cep );
-void select_next_dialno ( cfg_entry_t *cep );
-void select_this_dialno ( cfg_entry_t *cep );
-int sendm_alert_req ( cfg_entry_t *cep );
-int sendm_connect_req ( cfg_entry_t *cep );
-int sendm_connect_resp ( cfg_entry_t *cep, int cdid, int response, int cause );
-int sendm_disconnect_req ( cfg_entry_t *cep, int cause );
-int set_channel_busy(int controller, int channel);
-int set_channel_idle(int controller, int channel);
-int setup_dialout(cfg_entry_t *cep);
-void sigchild_handler ( int sig );
-void start_timer ( cfg_entry_t *cep, int seconds );
-void stop_timer ( cfg_entry_t *cep );
-void unitlen_chkupd( cfg_entry_t *cep );
-void write_pid ( void );
-void yyerror ( const char *msg );
-
-/* montior server module */
-void monitor_init();
-void monitor_exit();
-void monitor_clear_rights();
-void monitor_fixup_rights();
-int monitor_start_rights(const char *clientspec);
-void monitor_add_rights(int rights);
-
-/* possible return codes from monitor_start_rights: */
-#define I4BMAR_OK 0 /* rights added successfully */
-#define I4BMAR_LENGTH 1 /* local socket name to long */
-#define I4BMAR_DUP 2 /* entry already exists */
-#define I4BMAR_CIDR 3 /* cidr netmask is invalid */
-#define I4BMAR_NOIP 4 /* host/net could not be resolved */
-
-int monitor_create_local_socket();
-
-#ifndef I4B_NOTCPIP_MONITOR
-int monitor_create_remote_socket(int portno);
-#endif
-
-void monitor_prepselect(fd_set *selset, int *max_fd);
-void monitor_handle_input(fd_set *selset);
-void monitor_handle_connect(int sockfd, int is_local);
-void monitor_evnt_charge(cfg_entry_t *cep, int units, int estimated);
-void monitor_evnt_connect(cfg_entry_t *cep);
-void monitor_evnt_disconnect(cfg_entry_t *cep);
-void monitor_evnt_updown(cfg_entry_t *cep, int up);
-void monitor_evnt_log(int prio, const char * what, const char * msg);
-
-/* controller.c */
-
-int init_controller_state(int controller, int ctrl_type, int card_type, int tei);
-int set_controller_state(int controller, int state);
-int get_controller_state(int controller);
-int decr_free_channels(int controller);
-int incr_free_channels(int controller);
-int get_free_channels(int controller);
-int set_channel_busy(int controller, int channel);
-int set_channel_idle(int controller, int channel);
-int ret_channel_state(int controller, int channel);
-
-/* alias.c */
-
-void init_alias(char *filename);
-void free_aliases(void);
-char *get_alias(char *number);
-
-#endif /* _ISDND_H_ */
diff --git a/usr.sbin/i4b/isdnd/isdnd.rates.5 b/usr.sbin/i4b/isdnd/isdnd.rates.5
deleted file mode 100644
index 450cd5eac3f8..000000000000
--- a/usr.sbin/i4b/isdnd/isdnd.rates.5
+++ /dev/null
@@ -1,115 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdnd.rates.5,v 1.6 1998/12/05 18:03:21 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:09:57 1998]
-.\"
-.Dd September 11, 1998
-.Dt isdnd.rates 5
-.Sh NAME
-.Nm isdnd.rates
-.Nd isdn4bsd ISDN management daemon rates description file
-.Sh DESCRIPTION
-The file
-.Pa isdnd.rates
-contains descriptions how long charging units last at a given time of day,
-day of week and the distance to the destination. If this file is available,
-this information may be used by the
-.Xr isdnd 8
-ISDN connection management daemon to calculate the short hold time for a
-connection.
-.Pp
-The format of a rate entry line is a follows:
-.Pp
-The first field, the
-.Pq Fa rate-code
-defines a collection of rates (for each day of the week) which can be
-referenced in the
-.Xr isdnd 8
-configuration file
-.Xr isdnd.rc 5 .
-This field must start with the identifier
-.Dq ra
-followed by a digit in the range of zero to four.
-.Pp
-
-The second field, the
-.Pq Fa day-number
-selects the day of week for which this entry defines the rates, where 0 stands
-for Sunday, 1 for Monday and so on until the digit 6 which stands for Saturday.
-.Pp
-
-The rest of the line consists of one or more space separated fields which have
-the following syntax:
-.Bd -filled -offset indent
-start_hour.start_minutes-end_hour.end_minutes:charge_unit_length
-.Ed
-.Pp
-Start_hour and start_minutes define the begin of a time section and end_hour
-and end_minutes define the end. Charge_unit_length define the length of a
-charging unit in the previously defined time section. No spaces or tabs are
-allowed inside this field. The hour and minutes specifications MUST have
-exactly 2 digits, in case just one digit is needed, a leading 0 must be used.
-.Pp
-For example,
-.Bd -filled -offset indent
-14.00-18.00:90
-.Ed
-.Pp
-defines, that between 2:00 PM and 6:00 PM the length of one charging unit
-lasts 90 seconds.
-.Pp
-
-.Sh FILES
-.Bl -tag -width /etc/isdn/isdnd.rates -compact
-.It Pa /etc/isdn/isdnd.rates
-The default rates specification file for the
-.Nm isdnd
-ISDN daemon.
-
-.Sh EXAMPLES
-The line:
-.Bd -literal
-ra0 0 00.00-05.00:240 05.00-21.00:150 21.00-24.00:240
-.Ed
-.Pp
-defines the unit lengths for a Sunday.
-
-.Sh SEE ALSO
-.Xr isdnd 8 ,
-.Xr isdnd.rc 5
-
-.Sh AUTHOR
-The rates subsystem for the
-.Xr isdnd 8
-daemon to which
-.Nm
-belongs was designed and written by Gary Jennejohn.
-.Pp
-The
-.Xr isdnd 8
-daemon and this manual page were written by Hellmuth Michaelis.
-He can be reached at hm@kts.org or hm@hcs.de.
-
diff --git a/usr.sbin/i4b/isdnd/isdnd.rc.5 b/usr.sbin/i4b/isdnd/isdnd.rc.5
deleted file mode 100644
index 03d1a3a528f3..000000000000
--- a/usr.sbin/i4b/isdnd/isdnd.rc.5
+++ /dev/null
@@ -1,642 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdnd.rc.5,v 1.27 1998/12/05 18:03:23 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:10:08 1998]
-.\"
-.Dd October 27, 1998
-.Dt isdnd.rc 5
-.Sh NAME
-.Nm isdnd.rc
-.Nd isdn4bsd ISDN connection management daemon config file format
-.Sh DESCRIPTION
-The file
-.Pa /etc/isdn/isdnd.rc
-contains (if not otherwise specified on the command line) the runtime
-configuration for the
-.Xr isdnd 8
-ISDN connection management daemon which is part of the isdn4bsd package.
-.Pp
-The configuration file consists of keywords which start in column 1 followed by
-one or more spaces or tabs, an equal sign, one or more spaces or tabs
-and a keyword dependent parameter value.
-.Pp
-A line beginning with '#' is treated as a comment line.
-.Pp
-For keywords requiring the specification of a boolean value, the truth
-value can be either
-.Em yes
-or
-.Em on
-while the false value can be either
-.Em no
-or
-.Em off .
-.Pp
-The configuration file consists of one
-.Em system
-section and one or more
-.Em entry
-sections.
-In the
-.Em system
-section parameters regarding the daemon operation or parameters
-not associated with a single remote connection can be set.
-In the
-.Em entry
-section(s) parameters directly associated with a single remote
-connection can be set.
-.Pp
-The following keywords are recognized by
-.Nm isdnd :
-.Pp
-.Bl -tag -width system -compact
-
-.It Li system
-This keyword starts the system configuration section. It must not
-have a parameter and may be used only once. The keyword is mandatory.
-The following keywords are valid in the system configuration section:
-.Bl -tag -width useacctfile -compact
-
-.It Li acctall
-If this parameter is set to
-.Em on ,
-accounting information is written even if the local site was not charged
-or no charging information is available or is not subscribed. (optional)
-
-.It Li acctfile
-Specifies the name of the accounting file which is used when the keyword
-.Em useacctfile
-(see below) is set to
-.Em on .
-If this keyword is omitted the system default is used. (optional)
-
-.It Li aliasing
-If this parameter is set to
-.Em on ,
-alias processing of telephone-number to name is enabled (see also the
-.Em aliasfile
-keyword below). The default is off. (optional)
-
-.It Li aliasfile
-Specifies the name of the telephone number-to-name alias database file shared
-with the
-.Xr isdntel 1
-utility when alias processing is enabled via the
-.Em aliasing
-keyword. (optional)
-
-.It Li isdntime
-If this parameter is set to
-.Em on ,
-date/time information from the exchange (if provided) is written to the
-logfile. The default is off. (optional)
-
-.It Li monitor-allowed
-If this parameter is set to
-.Em on
-or
-.Em yes ,
-monitoring via a local or remote machine is enabled.
-This parameter is optional and is set to
-.Em off
-by default.
-
-.It Li monitor-port
-sets the TCP port number for remote monitoring.
-This integer parameter is optional and is set to port 451 by default.
-
-.It Li monitor
-This keyword specifies a local socket name or a host or network for remote
-monitoring. The
-.Em monitor
-specification may either be:
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar the name of a local (UNIX-domain) socket
-this MUST start with a "/", example: /var/run/isdn-monitor
-.It Ar a dotted-quad host specification
-example: 192.168.1.2
-.It Ar a dotted-quad network address with netmask
-example: 192.168.1.0/24
-.It Ar a resolvable host name
-example: localhost
-.It Ar a resolvable network name with netmask
-example: up-vision-net/24
-.El
-
-.It Li monitor-access
-This keyword specifies the access rights for a previously used
-.Em monitor
-keyword. The supported access rights are:
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar fullcmd
-.It Ar restrictedcmd
-.It Ar channelstate
-.It Ar logevents
-.It Ar callin
-.It Ar callout
-.El
-
-.It Li ratesfile
-Specifies the name of the ratesfile. If this keyword is omitted the system
-default is used. (optional)
-
-.It Li regexpr
-This keyword is used to specify regular expressions. It can be specified
-more than once up to a compile time dependent value (currently set to 5 by
-the MAX_RE definition in the source).
-.Pp
-All specified regular expressions are compared to the log strings at runtime
-and if a match is found, a program is run with the log text as a parameter
-(see also the keyword
-.Em regprog
-below).
-.Pp
-For an explanation how regular expressions are specified, please have a
-look at
-.Xr re_format 7
-and
-.Xr regex 3 .
-The
-.Em extended
-regular expression syntax is supported here.
-.Pp
-Hint: it might be necessary to properly quote the expression to avoid
-improper interpretation by the configuration file parser.
-(optional)
-
-.It Li regprog
-This keyword is used to specify the name of a program which is run in
-case a corresponding regular expression is matched by a logging string.
-.Nm Isdnd
-expects to find the program below the path
-.Pa /etc/isdn
-which is prepended to the string specified as a parameter to this keyword.
-(optional)
-
-.It Li rtprio
-Specifies the realtime priority
-.Nm isdnd
-runs at as an integer value in the range 0...31 with 0 being the highest
-priority. This keyword is optional; if not specified the process priority of
-.Nm isdnd
-is not touched in any way.
-( See also
-.Xr rtprio 1
-).
-This keyword is only available if
-.Nm
-was compiled with -DUSE_RTPRIO.
-
-.It Li useacctfile
-If this parameter is set to
-.Em on
-charging (if available) and accounting information is written to the
-accounting file. (optional)
-
-.El
-
-.It Li entry
-This keyword starts one configuration entry. It must not have a parameter.
-This keyword must be used at least once.
-The following keywords are valid in an entry section:
-.Bl -tag -width unitlengthsrc -compact
-
-.It Li answerprog
-This keyword is used to specify the name of a program which is run in
-case an incoming telephone connection specified
-.Em answer
-in its configuration entry. The default name is
-.Em answer .
-.Nm Isdnd
-expects to find this program beneath the path
-.Pa /etc/isdn
-which is prepended to the string specified as a parameter to this keyword.
-(optional)
-
-.It Li alert
-is used to specify a time in seconds to wait before accepting a call. This
-keyword is only usable for incoming telephone calls (dialin-reaction = answer).
-It is used to have a chance to accept an incoming call on the phone before
-the answering machine starts to run. The minimum value for the alert parameter
-is 5 seconds and the maximum parameter allowed is 180 seconds.
-(optional)
-
-.It Li b1protocol
-The B channel layer 1 protocol used for this connection. The keyword is mandatory.
-The currently configurable values are:
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar hdlc
-HDLC framing.
-.It Ar raw
-No framing at all (used for telephony).
-.El
-
-.It Li callbackwait
-The time in seconds to wait between hanging up the call from a remote site
-and calling back the remote site. (optional)
-
-.It Li calledbackwait
-The time in seconds to wait for a remote site calling back the local site
-after a call from the local site to the remote site has been made. (optional)
-
-.It Li dialin-reaction
-Used to specify what to do when an incoming connection request is received.
-The keyword is mandatory.
-The currently supported parameters are:
-.Pp
-.Bl -tag -width calledback -compact -offset
-.It Ar accept
-Accept an incoming call.
-.It Ar reject
-Reject an incoming call.
-.It Ar ignore
-Ignore an incoming call.
-.It Ar answer
-Start telephone answering for an incoming voice call.
-.It Ar callback
-When a remote site calls, hangup and call back the remote site.
-.El
-
-.It Li dialout-type
-This keyword ist used to configure what type of dialout mode is used.
-The keyword is mandatory.
-The currently supported parameters are:
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar normal
-Normal behavior, call the remote site which is supposed to accept the call.
-.It Ar calledback
-Callback behavior, call the remote side which rejects the call and calls
-us back.
-.El
-
-.It Li dialrandincr
-When dialing or re-dialing and this parameter is set to
-.Em on ,
-the dial retry time is added with a random value (currently 0...3 seconds)
-to minimize the chance of two sites dialing synchronously so each gets a busy
-each time it dials because the other side is also dialing.
-
-.It Li dialretries
-The number of dialing retries before giving up. (optional)
-
-.It Li direction
-This keyword is used to configure if incoming and outgoing, incoming-only or
-outgoing only connections are possible.
-The keyword is optional, the default is
-.Em inout .
-.Pp
-The currently supported parameters are:
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar inout
-Normal behavior, connection establishment is possible from remote and local.
-.It Ar in
-Only incoming connections are possible.
-.It Ar out
-Only outgoing connections are possible.
-.El
-
-.It Li downtries
-is used to configure the number of unsuccessful tries (= retry cycles!) before
-the interface is disabled (for
-.Em downtime
-seconds).
-(see also the keyword
-.Em usedown
-further up). This keyword is optional.
-
-.It Li downtime
-is used to configure the time in seconds an interface is disabled
-after the configured number of
-.Em downtries .
-(see also the keyword
-.Em usedown
-further up).
-This keyword is optional and is set to 60 seconds by default.
-
-.It Li earlyhangup
-A (safety) time in seconds which specifies the time to hangup before an
-expected next charging unit will occur. (optional)
-
-.It Li idletime-outgoing
-The time in seconds an outgoing connection must be idle before hanging up.
-(optional)
-
-.It Li idletime-incoming
-The time in seconds an incoming connection must be idle before hanging up.
-(optional)
-
-.It Li isdncontroller
-The ISDN controller number to be used for connections for this entry.
-(mandatory)
-
-.It Li isdnchannel
-The ISDN controller channel number to be used for connections for this entry.
-In case a channel is explicitly selected here, the SETUP message will request
-this channel but mark the request as
-.Em preferred
-(the indicated channel is preferred) instead of exclusive (only the indicated
-channel is acceptable). Thus the exchange is still free to select another
-than the requested channel!
-(mandatory)
-
-.It Li isdntxdel-incoming
-A delay value suitable for the
-.Em timeout()
-kernel subroutine to delay the transmittion of the first packet after a
-successfull connection is made by this value for
-.Em incoming
-ISDN connections. The specification unit is 1/100 second. A zero (0) disables
-this feature and is the default value. This feature is implemented (and makes
-sense only) for the
-.Xr i4bipr 4
-IP over raw HDLC ISDN driver. (optional)
-
-.It Li isdntxdel-outgoing
-A delay value suitable for the
-.Em timeout()
-kernel subroutine to delay the transmittion of the first packet after a
-successfull connection is made by this value for
-.Em outgoing
-ISDN connections. The specification unit is 1/100 second. A zero (0) disables
-this feature and is the default value. This feature is implemented (and makes
-sense only) for the
-.Xr i4bipr 4
-IP over raw HDLC ISDN driver. (optional)
-
-.It Li local-phone-dialout
-The local telephone number used when the local site dials out. When dialing
-out to a remote site, the number specified here is put into the
-.Em "Calling Party Number Information Element" .
-.Pp
-This keyword is mandatory for the
-.em
-ipr
-userland interfaces.
-
-.It Li local-phone-incoming
-The local telephone number used for verifying the destination of incoming
-calls. When a remote site dials in, this number is used to verify that it
-is the local site which the remote site wants to connect to. It is compared
-with the
-.Em "Called Party Number Information Element"
-got from the telephone exchange.
-.Pp
-This keyword is mandatory for the ipr interfaces.
-
-.It Li name
-Defines a symbolic name for this configuration entry. It's purpose is to
-use this name in the full-screen display for easy identification of a link
-to a remote site and for accounting purposes. (mandatory)
-
-.It Li ratetype
-The rate entry used from the rates file. (optional)
-.br
-For example, ratetype=0 selects lines beginning "ra0" in /etc/isdn/isdnd.rates;
-(typically ra0 lines are a set of tables for local call rates on different
-days of the week & times per day).
-
-.It Li recoverytime
-The time in seconds to wait between dial retries. (optional)
-
-.It Li remdial-handling
-is used to specify the dialout behavior in case more than one outgoing
-number is specified.
-The currently supported parameters are:
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar first
-For every new (non-retry) call setup, start with the first number.
-.It Ar last
-For every new (non-retry) call setup, start with the last number with
-which a successful connection was made.
-.It Ar next
-For every new (non-retry) call setup, start with the next number which
-follows the last one used.
-.El
-
-.It Li remote-phone-dialout
-The remote telephone number used when the local site dials out. When dialing
-out to a remote site, the number specified here is put into the
-.Em "Called Party Number Information Element" .
-.Pp
-This keyword is mandatory for the
-.em
-ipr
-interfaces. It may be specified more than once to try to dial to several
-numbers until one succeeds.
-
-.It Li remote-phone-incoming
-The remote telephone number used to verify an incoming call. When a remote site
-dials in, this number is used to verify that it is the correct remote site
-which is herewith authorized to connect into the local system. This parameter
-is compared against the
-.Em "Calling Party Number Information Element"
-got from the telephone exchange.
-.Pp
-This keyword is mandatory for the ipr interfaces.
-.Pp
-This keyword may have a wildcard parameter '*' to permit anyone dialing in.
-
-.It Li unitlength
-The length of a charging unit in seconds. This is used in conjunction with
-the idletime to decide when to hangup a connection. (optional)
-
-.It Li unitlengthsrc
-This keyword is used to specify from which source
-.Xr isdnd 8
-takes the unitlength for shorthold mode. The currently configurable values are:
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar none
-Then unitlength is not specified anywhere.
-.It Ar cmdl
-Use the unitlength specified on the commandline.
-.It Ar conf
-Use the unitlength specified in the configuration file with the keyword
-.Em unitlength .
-.It Ar rate
-Use the unitlength from the ratesfile specified in the configuration
-file with the keyword
-.Em ratetype .
-.It Ar aocd
-Use a dynamically calculated unitlength in case AOCD is subscribed on
-the ISDN line. (AOCD is an acronym for ``Advice Of Charge During the call''
-which is a service provided by the telecommunications (ie phone) provider,
-to indicate billable units).
-.El
-
-.It Li usrdevicename
-Specifies the userland interface which is used for interfacing ISDN B channel
-data to the userland. The keyword is mandatory.
-This keyword accepts the following parameters:
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar ipr
-This parameter configures a raw HDLC IP over ISDN interface.
-.It Ar isp
-This parameter configures a synchronous PPP over ISDN interface.
-.It Ar rbch
-This specifies a Raw B CHannel access interface.
-.It Ar tel
-ISDN telephony.
-.El
-
-.It Li usrdeviceunit
-Specifies the unit number for the with the
-.em
-usrdevicename
-specified device.
-
-.It Li usedown
-is used to enable the use of the keywords
-.Em downtries
-and
-.Em downtime
-in the entries section(s). It is used in the
-.Nm isdnd
-daemon to dynamically enable and disable the IP interfaces to avoid excessive
-dialing activities in case of transient failures (such as busy lines).
-This parameter is optional and is set to
-.Em off
-by default.
-
-.It Li connectprog
-specifies a program run everytime after a connection is established and
-address negotiation is complete (i.e.: the connection is useable).
-.Nm Isdnd
-expects to find the program below the path
-.Pa /etc/isdn
-which is prepended to the string specified as a parameter to this keyword.
-(optional)
-
-.It Li disconnectprog
-specifies a program run everytime after a connection was shut down.
-.Nm Isdnd
-expects to find the program below the path
-.Pa /etc/isdn
-which is prepended to the string specified as a parameter to this keyword.
-(optional)
-
-.El
-.El
-
-.Sh IDLETIME CALCULATION AND SHORTHOLD MODE
-.Bl -tag -width incoming calls -compact
-.It Li incoming calls
-It is assumed that the calling side knows most about charging structures and
-such and as a consequence only the keyword
-.Em idletime-incoming
-has a function for incoming calls.
-.Pp
-For incoming calls the line is constantly monitored, and in case there was
-not traffic taking place for the time in seconds specified by
-.Em idletime-incoming
-the call is closed.
-.Pp
-Typically,
-.Em idletime-incoming
-is used as a last resort and is therefore set much higher than a charging
-unit time: typical values are one to five minutes.
-
-.It Li outgoing calls
-Outgoing call disconnect time can be setup in one of two ways:
-
-.Bl -tag -width shorthold mode -compact
-.It Li simple mode
-For simple mode, the selected
-.Em unitlength
-must be 0 (zero) and
-.Em idletime-outgoing
-greater zero.
-.Pp
-The outgoing traffic is constantly monitored, and in case there was
-not traffic taking place for the time in seconds specified by
-.Em idletime-outgoing
-the call is closed.
-.Pp
-Typical values in simple mode are 10 to 30 seconds.
-
-.It Li shorthold mode
-For shorthold mode, the selected
-.Em unitlength
-and
-.Em idletime-outgoing
-must be greater than 0 (zero);
-.Em earlyhangup must be >= 0 (zero).
-
-.Bd -literal
-
-|<unchecked-window>|<checkwindow>|<safetywindow>|
-| | | |
-+------------------+-------------+--------------+
-| | | |
-| |<-idle-time->|<earlyhangup->|
-|<--------------unitlength--------------------->|
-
-.Ed
-
-During the unchecked window which is (unitlength - (idle-time+earlyhangup))
-in length, no idle check is done. After the unchecked window has ended,
-the line is checked for idle-time length if no traffic takes place. In case
-there was traffic detected in the check-window, the same procedure is restarted
-at the beginning of the next unit. In case no traffic was detected during
-the check-window, the line is closed at the end of the check window.
-.Pp
-Notice:
-.Em unitlength
-must (!) be greater than the sum of
-.Em idletime-outgoing
-and
-.Em earlyhangup !
-
-.El
-.El
-
-.Pp
-
-.Sh FILES
-.Bl -tag -width /etc/isdn/isdnd.rc -compact
-.It Pa /etc/isdn/isdnd.rc
-The default configuration file for the
-.Nm isdnd
-ISDN daemon.
-
-.Sh SEE ALSO
-.Xr isdnd 8
-.Xr isdnmonitor 8
-.Xr regex 3
-.Xr re_format 7
-
-.Sh AUTHOR
-The
-.Xr isdnd 8
-daemon and this manual page were written by Hellmuth Michaelis.
-He can be reached at hm@kts.org.
diff --git a/usr.sbin/i4b/isdnd/log.c b/usr.sbin/i4b/isdnd/log.c
deleted file mode 100644
index 4c1ffb63b59d..000000000000
--- a/usr.sbin/i4b/isdnd/log.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - logging routines
- * -----------------------------
- *
- * $Id: log.c,v 1.14 1998/12/05 18:03:24 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:10:22 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <time.h>
-#include <errno.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <regex.h>
-
-#include <machine/i4b_ioctl.h>
-
-#include "isdnd.h"
-
-#define LOGBUFLEN 256
-
-extern int do_monitor;
-extern int accepted;
-extern FILE *logfp;
-
-static void check_reg(char *logstring);
-
-struct logtab {
- char *text;
- int pri;
-};
-
-/*---------------------------------------------------------------------------*
- * table for converting internal log levels into syslog levels
- *---------------------------------------------------------------------------*/
-static struct logtab logtab[] = {
- {"ERR", LOG_ERR}, /* error conditions */
- {"WRN", LOG_WARNING}, /* warning conditions, nonfatal */
- {"DMN", LOG_NOTICE}, /* normal but significant condition, daemon*/
- {"CHD", LOG_INFO}, /* informational, call handling */
- {"DBG", LOG_DEBUG} /* debug messages */
-};
-
-/*---------------------------------------------------------------------------*
- * initialize logging
- *---------------------------------------------------------------------------*/
-void
-init_log(void)
-{
- int i;
-
- if(uselogfile)
- {
- if((logfp = fopen(logfile, "a")) == NULL)
- {
- fprintf(stderr, "ERROR, cannot open logfile %s: %s\n",
- logfile, strerror(errno));
- exit(1);
- }
-
- /* set unbuffered operation */
-
- setvbuf(logfp, (char *)NULL, _IONBF, 0);
- }
- else
- {
-#if DEBUG
- if(do_debug && do_fork == 0 && do_fullscreen == 0)
- (void)openlog("isdnd",
- LOG_PID|LOG_CONS|LOG_NDELAY|LOG_PERROR,
- logfacility);
- else
-#endif
- (void)openlog("isdnd", LOG_PID|LOG_CONS|LOG_NDELAY,
- logfacility);
- }
-
- /* initialize the regexp array */
-
- for(i = 0; i < MAX_RE; i++)
- {
- char *p;
- char buf[64];
-
- sprintf(buf, "%s%d", REGPROG_DEF, i);
-
- rarr[i].re_flg = 0;
-
- if((p = malloc(strlen(buf) + 1)) == NULL)
- {
- log(LL_DBG, "init_log: malloc failed: %s", strerror(errno));
- do_exit(1);
- }
-
- strcpy(p, buf);
-
- rarr[i].re_prog = p;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * finish logging
- *---------------------------------------------------------------------------*/
-void
-finish_log(void)
-{
- if(uselogfile)
- {
- fflush(logfp);
- fclose(logfp);
- }
- else
- {
- (void)closelog();
- }
-}
-
-/*---------------------------------------------------------------------------*
- * place entry into logfile
- *---------------------------------------------------------------------------*/
-void
-log(int what, const char *fmt, ...)
-{
- char buffer[LOGBUFLEN];
- register char *dp;
- va_list ap;
-
- va_start(ap, fmt);
- vsnprintf(buffer, LOGBUFLEN-1, fmt, ap);
- va_end(ap);
-
- dp = getlogdatetime(); /* get time string ptr */
-
-#ifdef USE_CURSES
-
- /* put log on screen ? */
-
- if((do_fullscreen && curses_ready) &&
- ((!debug_noscreen) || (debug_noscreen && (what != LL_DBG))))
- {
- wprintw(lower_w, "%s %s %-.*s\n", dp, logtab[what].text,
- COLS-((strlen(dp))+(strlen(logtab[what].text))+2), buffer);
- wrefresh(lower_w);
- }
-#endif
-
-#ifdef I4B_EXTERNAL_MONITOR
- monitor_evnt_log(logtab[what].pri, logtab[what].text, buffer);
-#endif
-
- if(uselogfile)
- {
- fprintf(logfp, "%s %s %s\n", dp, logtab[what].text, buffer);
- }
- else
- {
- register char *s = buffer;
-
- /* strip leading spaces from syslog output */
-
- while(*s && (*s == ' '))
- s++;
-
- syslog(logtab[what].pri, "%s %s", logtab[what].text, s);
- }
-
-
-#if DEBUG
- if(what != LL_DBG) /* don't check debug logs, endless loop !!! */
-#endif
- check_reg(buffer);
-}
-
-/*---------------------------------------------------------------------------*
- * return ptr to static area containing date/time
- *---------------------------------------------------------------------------*/
-char *
-getlogdatetime()
-{
- static char logdatetime[41];
- time_t tim;
- register struct tm *tp;
-
- tim = time(NULL);
- tp = localtime(&tim);
- strftime(logdatetime,40,I4B_TIME_FORMAT,tp);
- return(logdatetime);
-}
-
-/*---------------------------------------------------------------------------*
- * check for a match in the regexp array
- *---------------------------------------------------------------------------*/
-static void
-check_reg(char *logstring)
-{
- register int i;
-
- for(i = 0; i < MAX_RE; i++)
- {
- if(rarr[i].re_flg && (!regexec(&(rarr[i].re), logstring, (size_t) 0, NULL, 0)))
- {
- char* argv[3];
- argv[0] = rarr[i].re_prog;
- argv[1] = logstring;
- argv[2] = NULL;
-
- exec_prog(rarr[i].re_prog, argv);
- break;
- }
- }
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/main.c b/usr.sbin/i4b/isdnd/main.c
deleted file mode 100644
index 9d16717d485d..000000000000
--- a/usr.sbin/i4b/isdnd/main.c
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - main program entry
- * -------------------------------
- *
- * $Id: main.c,v 1.29 1998/12/05 18:03:26 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:10:38 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#ifdef I4B_EXTERNAL_MONITOR
-#include "monitor.h"
-#endif
-
-#define MAIN
-#include "isdnd.h"
-#undef MAIN
-
-#ifdef I4B_EXTERNAL_MONITOR
-
-#ifdef I4B_NOTCPIP_MONITOR
-/* monitor via local socket */
-static void mloop(int sockfd);
-#else /* I4B_NOTCPIP_MONITOR */
-/* monitor via local and tcp/ip socket */
-static void mloop(int localsock, int remotesock);
-#endif /* I4B_NOTCPIP_MONITOR */
-
-#else /* I4B_EXTERNAL_MONITOR */
-/* no monitoring at all */
-static void mloop();
-#endif /* I4B_EXTERNAL_MONITOR */
-
-#ifdef USE_CURSES
-static void kbdrdhdl(void);
-#endif
-
-static void isdnrdhdl(void);
-static void usage(void);
-
-#define MSG_BUF_SIZ 1024 /* message buffer size */
-
-/*---------------------------------------------------------------------------*
- * usage display and exit
- *---------------------------------------------------------------------------*/
-static void
-usage(void)
-{
- fprintf(stderr, "\n");
- fprintf(stderr, "isdnd - i4b ISDN manager daemon, version %02d.%02d.%d, %s %s\n", VERSION, REL, STEP, __DATE__, __TIME__);
-#ifdef DEBUG
- fprintf(stderr, " usage: isdnd [-b] [-c file] [-d level] [-F]\n");
-#else
- fprintf(stderr, " usage: isdnd [-b] [-c file] [-F]\n");
-#endif
- fprintf(stderr, " [-f [-r dev] [-t termtype]] [-u time]\n");
- fprintf(stderr, " [-l] [-L file] [-s facility] [-m]\n");
- fprintf(stderr, " -b audible bell in fullscreen mode at connect/disconnect\n");
- fprintf(stderr, " -c <filename> configuration file name (def: %s)\n", CONFIG_FILE_DEF);
-#ifdef DEBUG
- fprintf(stderr, " -d <level> set debug flag bits:\n");
- fprintf(stderr, " general = 0x%04x, rates = 0x%04x, timing = 0x%04x\n", DL_MSG, DL_RATES, DL_TIME);
- fprintf(stderr, " state = 0x%04x, retry = 0x%04x, dial = 0x%04x\n", DL_STATE, DL_RCVRY, DL_DIAL);
- fprintf(stderr, " process = 0x%04x, kernio = 0x%04x ctrlstat = 0x%04x\n", DL_PROC, DL_DRVR, DL_CNST);
- fprintf(stderr, " -dn no debug output on fullscreen display\n");
-#endif
- fprintf(stderr, " -f fullscreen status display\n");
- fprintf(stderr, " -F do not become a daemon process\n");
- fprintf(stderr, " -l use a logfile instead of syslog\n");
- fprintf(stderr, " -L <file> use file instead of %s for logging\n", LOG_FILE_DEF);
- fprintf(stderr, " -P pretty print real config to stdout and exit\n");
- fprintf(stderr, " -r <device> redirect output to other device (for -f)\n");
- fprintf(stderr, " -s <facility> use facility instead of %d for syslog logging\n", LOG_LOCAL0 >> 3);
- fprintf(stderr, " -t <termtype> terminal type of redirected screen (for -f)\n");
- fprintf(stderr, " -u <time> length of a charging unit in seconds\n");
- fprintf(stderr, " -m inhibit network/local monitoring\n");
- fprintf(stderr, "\n");
- exit(1);
-}
-
-/*---------------------------------------------------------------------------*
- * program entry
- *---------------------------------------------------------------------------*/
-int
-main(int argc, char **argv)
-{
- int i;
- msg_vr_req_t mvr;
-
-#ifdef I4B_EXTERNAL_MONITOR
- int sockfd = -1; /* local monitor socket */
-#ifndef I4B_NOTCPIP_MONITOR
- int remotesockfd = -1; /* tcp/ip monitor socket */
-#endif
-#endif
-
- while ((i = getopt(argc, argv, "bmc:d:fFlL:Pr:s:t:u:?")) != EOF)
- {
- switch (i)
- {
- case 'b':
- do_bell = 1;
- break;
-
- case 'm':
- inhibit_monitor = 1;
- break;
-
- case 'c':
- configfile = optarg;
- break;
-
-#ifdef DEBUG
- case 'd':
- if(*optarg == 'n')
- debug_noscreen = 1;
- else if((sscanf(optarg, "%i", &debug_flags)) == 1)
- do_debug = 1;
- else
- usage();
- break;
-#endif
-
- case 'f':
- do_fullscreen = 1;
- do_fork = 0;
-#ifndef USE_CURSES
- fprintf(stderr, "Sorry, no fullscreen mode available - daemon compiled without USE_CURSES\n");
- exit(1);
-#endif
- break;
-
- case 'F':
- do_fork = 0;
- break;
-
- case 'l':
- uselogfile = 1;
- break;
-
- case 'L':
- strcpy(logfile, optarg);
- break;
-
- case 'P':
- do_print = 1;
- break;
-
- case 'r':
- rdev = optarg;
- do_rdev = 1;
- break;
-
- case 's':
- if(isdigit(*optarg))
- {
- int facility;
- logfacility = strtoul(optarg, NULL, 10);
- facility = logfacility << 3;
-
- if((facility < LOG_KERN) ||
- (facility > LOG_FTP && facility < LOG_LOCAL0) ||
- (facility > LOG_LOCAL7))
- {
- fprintf(stderr, "Error, option -s has invalid logging facility %d", logfacility);
- usage();
- }
- logfacility = facility;
- }
- else
- {
- fprintf(stderr, "Error: option -s requires a numeric argument!\n");
- usage();
- }
- break;
-
- case 't':
- ttype = optarg;
- do_ttytype = 1;
- break;
-
- case 'u':
- if(isdigit(*optarg))
- {
- unit_length = strtoul(optarg, NULL, 10);
- if(unit_length < ULSRC_CMDLMIN)
- unit_length = ULSRC_CMDLMIN;
- else if(unit_length > ULSRC_CMDLMAX)
- unit_length = ULSRC_CMDLMAX;
- got_unitlen = 1;
- }
- else
- {
- fprintf(stderr, "Error: option -T requires a numeric argument!\n");
- usage();
- }
- break;
-
- case '?':
- default:
- usage();
- break;
- }
- }
-#ifdef DEBUG
- if(!do_debug)
- debug_noscreen = 0;
-#endif
-
- if(!do_print)
- {
- umask(UMASK); /* set our umask ... */
-
- init_log(); /* initialize the logging subsystem */
- }
-
- check_pid(); /* check if we are already running */
-
- if(!do_print)
- {
- if(do_fork || (do_fullscreen && do_rdev)) /* daemon mode ? */
- daemonize();
-
- write_pid(); /* write our pid to file */
-
- /* set signal handler(s) */
-
- signal(SIGCHLD, sigchild_handler); /* process handling */
- signal(SIGHUP, rereadconfig); /* reread configuration */
- signal(SIGUSR1, reopenfiles); /* reopen acct/log files*/
- signal(SIGPIPE, SIG_IGN); /* handled manually */
- signal(SIGINT, do_exit); /* clean up on SIGINT */
- signal(SIGTERM, do_exit); /* clean up on SIGTERM */
- signal(SIGQUIT, do_exit); /* clean up on SIGQUIT */
- }
-
- /* open isdn device */
-
- if((isdnfd = open(I4BDEVICE, O_RDWR)) < 0)
- {
- log(LL_ERR, "main: cannot open %s: %s", I4BDEVICE, strerror(errno));
- exit(1);
- }
-
- /* check kernel and userland have same version/release numbers */
-
- if((ioctl(isdnfd, I4B_VR_REQ, &mvr)) < 0)
- {
- log(LL_ERR, "main: ioctl I4B_VR_REQ failed: %s", strerror(errno));
- do_exit(1);
- }
-
- if(mvr.version != VERSION)
- {
- log(LL_ERR, "main: version mismatch, kernel %d, daemon %d", mvr.version, VERSION);
- do_exit(1);
- }
-
- if(mvr.release != REL)
- {
- log(LL_ERR, "main: release mismatch, kernel %d, daemon %d", mvr.release, REL);
- do_exit(1);
- }
-
- if(mvr.step != STEP)
- {
- log(LL_ERR, "main: step mismatch, kernel %d, daemon %d", mvr.step, STEP);
- do_exit(1);
- }
-
- /* init controller state array */
-
- init_controller();
-
- /* read runtime configuration file and configure ourselves */
-
- configure(configfile, 0);
-
- if(config_error_flag)
- {
- log(LL_ERR, "there were %d error(s) in the configuration file, terminating!", config_error_flag);
- exit(1);
- }
-
- /* handle the rates stuff */
-
- if((i = readrates(ratesfile)) == ERROR)
- {
- if(rate_error != NULL)
- log(LL_ERR, "%s", rate_error);
- exit(1);
- }
-
- if(i == GOOD)
- {
- got_rate = 1; /* flag, ratesfile read and ok */
- DBGL(DL_MSG, (log(LL_DBG, "ratesfile %s read successfully", ratesfile)));
- }
- else
- {
- if(rate_error != NULL)
- log(LL_WRN, "%s", rate_error);
- }
-
- /* if writing accounting info, open file, set unbuffered */
-
- if(useacctfile)
- {
- if((acctfp = fopen(acctfile, "a")) == NULL)
- {
- log(LL_ERR, "ERROR, can't open acctfile %s for writing, terminating!", acctfile);
- exit(1);
- }
- setvbuf(acctfp, (char *)NULL, _IONBF, 0);
- }
-
- /* initialize alias processing */
-
- if(aliasing)
- init_alias(aliasfile);
-
- /* init remote monitoring */
-
-#ifdef I4B_EXTERNAL_MONITOR
- if(do_monitor)
- {
- monitor_init();
- sockfd = monitor_create_local_socket();
-#ifndef I4B_NOTCPIP_MONITOR
- remotesockfd = monitor_create_remote_socket(monitorport);
-#endif
- }
-#endif
-
- /* in case fullscreendisplay, initialize */
-
-#ifdef USE_CURSES
- if(do_fullscreen)
- {
- init_screen();
- }
-#endif
-
- /* init realtime priority */
-
-#ifdef USE_RTPRIO
- if(rt_prio != RTPRIO_NOTUSED)
- {
- struct rtprio rtp;
-
- rtp.type = RTP_PRIO_REALTIME;
- rtp.prio = rt_prio;
-
- if((rtprio(RTP_SET, getpid(), &rtp)) == -1)
- {
- log(LL_ERR, "rtprio failed: %s", strerror(errno));
- do_exit(1);
- }
- }
-#endif
-
- srandom(580403); /* init random number gen */
-
- mloop( /* enter loop of no return .. */
-#ifdef I4B_EXTERNAL_MONITOR
- sockfd
-#ifndef I4B_NOTCPIP_MONITOR
- , remotesockfd
-#endif
-#endif
- );
- do_exit(0);
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * program exit
- *---------------------------------------------------------------------------*/
-void
-do_exit(int exitval)
-{
- close_allactive();
-
- unlink(PIDFILE);
-
- log(LL_DMN, "daemon terminating, exitval = %d", exitval);
-
-#ifdef USE_CURSES
- if(do_fullscreen)
- endwin();
-#endif
-
-#ifdef I4B_EXTERNAL_MONITOR
- monitor_exit();
-#endif
-
- exit(exitval);
-}
-
-/*---------------------------------------------------------------------------*
- * main loop
- *---------------------------------------------------------------------------*/
-static void
-mloop(
-#ifdef I4B_EXTERNAL_MONITOR
- int localmonitor
-#ifndef I4B_NOTCPIP_MONITOR
- , int remotemonitor
-#endif
-#endif
-)
-{
- fd_set set;
- struct timeval timeout;
- int ret;
- int high_selfd;
-
- /* go into loop */
-
- log(LL_DMN, "daemon started (pid = %d)", getpid());
-
- for(;;)
- {
- FD_ZERO(&set);
-
-#ifdef USE_CURSES
- if(do_fullscreen)
- FD_SET(fileno(stdin), &set);
-#endif
-
- FD_SET(isdnfd, &set);
-
- high_selfd = isdnfd;
-
-#ifdef I4B_EXTERNAL_MONITOR
- if(do_monitor)
- {
- if (localmonitor != -1) {
- /* always watch for new connections */
- FD_SET(localmonitor, &set);
- if(localmonitor > high_selfd)
- high_selfd = localmonitor;
- }
-#ifndef I4B_NOTCPIP_MONITOR
- if (remotemonitor != -1) {
- FD_SET(remotemonitor, &set);
- if(remotemonitor > high_selfd)
- high_selfd = remotemonitor;
- }
-#endif
-
- /* if there are client connections, let monitor module
- * enter them into the fdset */
- if(accepted)
- {
- monitor_prepselect(&set, &high_selfd);
- }
- }
-#endif
-
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
-
- ret = select(high_selfd + 1, &set, NULL, NULL, &timeout);
-
- if(ret > 0)
- {
- if(FD_ISSET(isdnfd, &set))
- isdnrdhdl();
-
-#ifdef USE_CURSES
- if(FD_ISSET(fileno(stdin), &set))
- kbdrdhdl();
-#endif
-
-#ifdef I4B_EXTERNAL_MONITOR
- if(do_monitor)
- {
- if(localmonitor != -1 && FD_ISSET(localmonitor, &set))
- monitor_handle_connect(localmonitor, 1);
-
-#ifndef I4B_NOTCPIP_MONITOR
- if(remotemonitor != -1 && FD_ISSET(remotemonitor, &set))
- monitor_handle_connect(remotemonitor, 0);
-#endif
- if(accepted)
- monitor_handle_input(&set);
- }
-#endif
- }
- else if(ret == -1)
- {
- if(errno != EINTR)
- log(LL_WRN, "ERROR, select error on isdn device, errno = %d!", errno);
- }
-
- /* handle timeout and recovery */
-
- handle_recovery();
- }
-}
-
-#ifdef USE_CURSES
-/*---------------------------------------------------------------------------*
- * data from keyboard available, read and process it
- *---------------------------------------------------------------------------*/
-static void
-kbdrdhdl(void)
-{
- int ch = getch();
-
- switch(ch)
- {
- case 0x0c: /* control L */
- wrefresh(curscr);
- break;
-
- case '\n':
- case '\r':
- do_menu();
- break;
- }
-}
-#endif
-
-/*---------------------------------------------------------------------------*
- * data from /dev/isdn available, read and process them
- *---------------------------------------------------------------------------*/
-static void
-isdnrdhdl(void)
-{
- static unsigned char msg_rd_buf[MSG_BUF_SIZ];
- msg_hdr_t *hp = (msg_hdr_t *)&msg_rd_buf[0];
-
- register int len;
-
- if((len = read(isdnfd, msg_rd_buf, MSG_BUF_SIZ)) > 0)
- {
- switch(hp->type)
- {
- case MSG_CONNECT_IND:
- msg_connect_ind((msg_connect_ind_t *)msg_rd_buf);
- break;
-
- case MSG_CONNECT_ACTIVE_IND:
- msg_connect_active_ind((msg_connect_active_ind_t *)msg_rd_buf);
- break;
-
- case MSG_DISCONNECT_IND:
- msg_disconnect_ind((msg_disconnect_ind_t *)msg_rd_buf);
- break;
-
- case MSG_DIALOUT_IND:
- msg_dialout((msg_dialout_ind_t *)msg_rd_buf);
- break;
-
- case MSG_ACCT_IND:
- msg_accounting((msg_accounting_ind_t *)msg_rd_buf);
- break;
-
- case MSG_IDLE_TIMEOUT_IND:
- msg_idle_timeout_ind((msg_idle_timeout_ind_t *)msg_rd_buf);
- break;
-
- case MSG_CHARGING_IND:
- msg_charging_ind((msg_charging_ind_t *)msg_rd_buf);
- break;
-
- case MSG_PROCEEDING_IND:
- msg_proceeding_ind((msg_proceeding_ind_t *)msg_rd_buf);
- break;
-
- case MSG_ALERT_IND:
- msg_alert_ind((msg_alert_ind_t *)msg_rd_buf);
- break;
-
- case MSG_DRVRDISC_REQ:
- msg_drvrdisc_req((msg_drvrdisc_req_t *)msg_rd_buf);
- break;
-
- case MSG_L12STAT_IND:
- msg_l12stat_ind((msg_l12stat_ind_t *)msg_rd_buf);
- break;
-
- case MSG_TEIASG_IND:
- msg_teiasg_ind((msg_teiasg_ind_t *)msg_rd_buf);
- break;
-
- case MSG_PDEACT_IND:
- msg_pdeact_ind((msg_pdeact_ind_t *)msg_rd_buf);
- break;
-
- case MSG_NEGCOMP_IND:
- msg_negcomplete_ind((msg_negcomplete_ind_t *)msg_rd_buf);
- break;
-
- case MSG_IFSTATE_CHANGED_IND:
- msg_ifstatechg_ind((msg_ifstatechg_ind_t *)msg_rd_buf);
- break;
-
- default:
- log(LL_WRN, "ERROR, unknown message received from /dev/isdn (0x%x)", msg_rd_buf[0]);
- break;
- }
- }
- else
- {
- log(LL_WRN, "ERROR, read error on isdn device, errno = %d, length = %d", errno, len);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * re-read the config file on SIGHUP or menu command
- *---------------------------------------------------------------------------*/
-void
-rereadconfig(int dummy)
-{
- extern int entrycount;
-
- log(LL_DMN, "re-reading configuration file");
-
- close_allactive();
-
- entrycount = -1;
- nentries = 0;
-
- /* read runtime configuration file and configure ourselves */
-
- configure(configfile, 1);
-
- if(config_error_flag)
- {
- log(LL_ERR, "there were %d error(s) in the configuration file, terminating!", config_error_flag);
- unlink(PIDFILE);
- exit(1);
- }
-
- if(aliasing)
- {
- /* reread alias database */
- free_aliases();
- init_alias(aliasfile);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * re-open the log/acct files on SIGUSR1
- *---------------------------------------------------------------------------*/
-void
-reopenfiles(int dummy)
-{
- if(useacctfile)
- {
- fflush(acctfp);
- fclose(acctfp);
-
- if((acctfp = fopen(acctfile, "a")) == NULL)
- {
- log(LL_ERR, "ERROR, can't open acctfile %s for writing, terminating!", acctfile);
- exit(1);
- }
- setvbuf(acctfp, (char *)NULL, _IONBF, 0);
- }
-
- if(uselogfile)
- {
- finish_log();
-
- if((logfp = fopen(logfile, "a")) == NULL)
- {
- fprintf(stderr, "ERROR, cannot open logfile %s: %s\n",
- logfile, strerror(errno));
- exit(1);
- }
-
- /* set unbuffered operation */
-
- setvbuf(logfp, (char *)NULL, _IONBF, 0);
- }
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/monitor.c b/usr.sbin/i4b/isdnd/monitor.c
deleted file mode 100644
index 884df137819b..000000000000
--- a/usr.sbin/i4b/isdnd/monitor.c
+++ /dev/null
@@ -1,811 +0,0 @@
-/*
- * Copyright (c) 1998 Martin Husemann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * 4. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software and/or documentation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - network monitor server module
- * ------------------------------------------
- *
- * $Id: monitor.c,v 1.6 1998/08/10 13:55:24 hm Exp $
- *
- * last edit-date: [Fri Jul 17 18:07:00 1998]
- *
- * -mh created
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-#ifndef I4B_EXTERNAL_MONITOR
-/* dummy version of routines needed by config file parser
- * (config files should be valid with and without external montioring
- * support compiled into the daemon) */
-void monitor_clear_rights()
-{ }
-int monitor_start_rights(const char *clientspec)
-{ return I4BMAR_OK; }
-void monitor_add_rights(int rights_mask)
-{ }
-void monitor_fixup_rights()
-{ }
-#else
-
-#include "monitor.h"
-#include "vararray.h"
-#include <sys/socket.h>
-#include <sys/un.h>
-#ifndef I4B_NOTCPIP_MONITOR
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#endif
-
-VARA_DECL(struct monitor_rights) rights = VARA_INITIALIZER;
-#define INITIAL_RIGHTS_ALLOC 10 /* most users will have one or two entries */
-
-static int local_rights = -1; /* index of entry for local socket, -1 if none */
-
-/* for each active monitor connection we have one of this: */
-struct monitor_connection {
- int sock; /* socket for this connection */
- int rights; /* active rights for this connection */
- int events; /* bitmask of events client is interested in */
-};
-static VARA_DECL(struct monitor_connection) connections = VARA_INITIALIZER;
-#define INITIAL_CONNECTIONS_ALLOC 30 /* high guess */
-
-/* derive channel number from config pointer */
-#define CHNO(cfgp) (((cfgp)->isdncontrollerused*2) + (cfgp)->isdnchannelused)
-
-/* local prototypes */
-static int cmp_rights(const void *a, const void *b);
-static int monitor_command(int con_index, int fd, int rights);
-static void cmd_dump_rights(int fd, int rights, BYTE *cmd);
-static void cmd_dump_mcons(int fd, int rights, BYTE *cmd);
-static void cmd_reread_cfg(int fd, int rights, BYTE *cmd);
-static void cmd_hangup(int fd, int rights, BYTE *cmd);
-static void monitor_broadcast(int mask, const BYTE *pkt, size_t bytes);
-static int anybody(int mask);
-
-/*
- * Due to the way we structure config files, the rights for an external
- * monitor might be stated in multiple steps. First a call to
- * monitor_start_rights opens an entry. Further (optional) calls to
- * montior_add_rights assemble additional rights for this "current"
- * entry. When closing the sys-file section of the config file, the
- * "current" entry becomes invalid.
- */
-static int cur_add_entry = -1;
-
-/*
- * Initialize the monitor server module. This affects only active
- * connections, the access rights are not modified here!
- */
-void monitor_init()
-{
- accepted = 0;
- VARA_EMPTY(connections);
-}
-
-/*
- * Prepare for exit
- */
-void monitor_exit()
-{
- int i;
-
- /* Close all open connections. */
- VARA_FOREACH(connections, i)
- close(VARA_AT(connections, i).sock);
-
- /* Remove their descriptions */
- VARA_EMPTY(connections);
-}
-
-/*
- * Initialize access rights. No active connections are affected!
- */
-void monitor_clear_rights()
-{
- VARA_EMPTY(rights);
- cur_add_entry = -1;
-}
-
-/*
- * Add an entry to the access lists. The clientspec either is
- * the name of the local socket or a host- or networkname or
- * numeric ip/host-bit-len spec.
- */
-int monitor_start_rights(const char *clientspec)
-{
- int i;
- struct monitor_rights r;
-
- /* initialize the new rights entry */
- memset(&r, 0, sizeof r);
-
- /* check clientspec */
- if (*clientspec == '/') {
- struct sockaddr_un sa;
-
- /* this is a local socket spec, check if we already have one */
- if (VARA_VALID(rights, local_rights))
- return I4BMAR_DUP;
- /* does it fit in a local socket address? */
- if (strlen(clientspec) > sizeof sa.sun_path)
- return I4BMAR_LENGTH;
- r.local = 1;
- strcpy(r.name, clientspec);
-#ifndef I4B_NOTCPIP_MONITOR
- } else {
- /* remote entry, parse host/net and cidr */
- char hostname[FILENAME_MAX];
- char *p;
- p = strchr(clientspec, '/');
- if (!p) {
- struct hostent *host;
- u_int32_t hn;
- /* must be a host spec */
- r.mask = ~0;
- host = gethostbyname(clientspec);
- if (!host)
- return I4BMAR_NOIP;
- memcpy(&hn, host->h_addr_list[0], sizeof hn);
- r.net = (u_int32_t)ntohl(hn);
- } else if (p[1]) {
- /* must be net/cidr spec */
- int l;
- struct netent *net;
- u_int32_t s = ~0U;
- int num = strtol(p+1, NULL, 10);
- if (num < 0 || num > 32)
- return I4BMAR_CIDR;
- s >>= num;
- s ^= ~0U;
- l = p - clientspec;
- if (l >= sizeof hostname)
- return I4BMAR_LENGTH;
- strncpy(hostname, clientspec, l);
- hostname[l] = '\0';
- net = getnetbyname(hostname);
- if (net == NULL)
- r.net = (u_int32_t)inet_network(hostname);
- else
- r.net = (u_int32_t)net->n_net;
- r.mask = s;
- r.net &= s;
- } else
- return I4BMAR_CIDR;
-
- /* check for duplicate entry */
- VARA_FOREACH(rights, i)
- if (VARA_AT(rights, i).mask == r.mask &&
- VARA_AT(rights, i).net == r.net &&
- VARA_AT(rights, i).local == r.local)
- return I4BMAR_DUP;
-#endif
- }
- r.rights = 0;
-
- /* entry ok, add it to the collection */
- cur_add_entry = i = VARA_NUM(rights);
- VARA_ADD_AT(rights, i, struct monitor_rights, INITIAL_RIGHTS_ALLOC);
- memcpy(&VARA_AT(rights, i), &r, sizeof r);
- if (r.local)
- local_rights = i;
-
- log(LL_DBG, "system: monitor = %s", clientspec);
-
- return I4BMAR_OK;
-}
-
-/*
- * Add rights to the currently constructed entry - if any.
- */
-void monitor_add_rights(int rights_mask)
-{
- if (cur_add_entry < 0) return; /* noone under construction */
-
- VARA_AT(rights, cur_add_entry).rights |= rights_mask;
-
- log(LL_DBG, "system: monitor-access = 0x%x", rights_mask);
-}
-
-/*
- * All rights have been added now. Sort the to get most specific
- * host/net masks first, so we can travel the list and use the first
- * match for actual rights.
- */
-void monitor_fixup_rights()
-{
- int i;
-
- /* no more rights may be added to the current entry */
- cur_add_entry = -1;
-
- /* sort the rights array */
- qsort(VARA_PTR(rights), VARA_NUM(rights), sizeof(struct monitor_rights), cmp_rights);
-
- /* now the local entry may have moved, update its index */
- if (VARA_VALID(rights, local_rights)) {
- local_rights = -1;
- VARA_FOREACH(rights, i) {
- if (VARA_AT(rights, i).local) {
- local_rights = i;
- break;
- }
- }
- }
-}
-
-/* comparator for rights */
-static int cmp_rights(const void *a, const void *b)
-{
- u_int32_t mask;
- struct monitor_rights const * pa = (struct monitor_rights const*)a;
- struct monitor_rights const * pb = (struct monitor_rights const*)b;
-
- /* local sorts first */
- if (pa->local)
- return -1;
-
- /* which is the less specific netmask? */
- mask = pa->mask;
- if ((pb->mask & mask) == 0)
- mask = pb->mask;
- /* are the entries disjunct? */
- if ((pa->net & mask) != (pb->net & mask)) {
- /* simply compare net part of address */
- return ((pa->net & mask) < (pb->net & mask)) ? -1 : 1;
- }
- /* One entry is part of the others net. We already now "mask" is
- * the netmask of the less specific (i.e. greater) one */
- return (pa->mask == mask) ? 1 : -1;
-}
-
-#ifndef I4B_NOTCPIP_MONITOR
-/*
- * Check if access rights for a remote socket are specified and
- * create this socket. Return -1 otherwise.
- */
-int monitor_create_remote_socket(int portno)
-{
- struct sockaddr_in sa;
- int val;
- int remotesockfd = socket(AF_INET, SOCK_STREAM, 0);
- if (remotesockfd == -1) {
- log(LL_ERR, "could not create remote monitor socket, errno = %d", errno);
- exit(1);
- }
- val = 1;
- if (setsockopt(remotesockfd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val)) {
- log(LL_ERR, "could not setsockopt, errno = %d", errno);
- exit(1);
- }
- memset(&sa, 0, sizeof sa);
- sa.sin_len = sizeof sa;
- sa.sin_family = AF_INET;
- sa.sin_port = htons(portno);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
- if (bind(remotesockfd, (struct sockaddr *)&sa, sizeof sa) == -1) {
- log(LL_ERR, "could not bind remote monitor socket to port %d, errno = %d", portno, errno);
- exit(1);
- }
- if (listen(remotesockfd, 0)) {
- log(LL_ERR, "could not listen on monitor socket, errno = %d", errno);
- exit(1);
- }
-
- return remotesockfd;
-}
-#endif
-
-/*
- * Check if access rights for a local socket are specified and
- * create this socket. Return -1 otherwise.
- */
-int monitor_create_local_socket()
-{
- int s;
- struct sockaddr_un sa;
-
- /* check for a local entry */
- if (!VARA_VALID(rights, local_rights))
- return -1;
-
- /* create and setup socket */
- s = socket(AF_LOCAL, SOCK_STREAM, 0);
- if (s == -1) {
- log(LL_ERR, "could not create local monitor socket, errno = %d", errno);
- exit(1);
- }
- unlink(VARA_AT(rights, local_rights).name);
- memset(&sa, 0, sizeof sa);
- sa.sun_len = sizeof sa;
- sa.sun_family = AF_LOCAL;
- strcpy(sa.sun_path, VARA_AT(rights, local_rights).name);
- if (bind(s, (struct sockaddr *)&sa, sizeof sa)) {
- log(LL_ERR, "could not bind local monitor socket [%s], errno = %d", VARA_AT(rights, local_rights).name, errno);
- exit(1);
- }
- if (listen(s, 0)) {
- log(LL_ERR, "could not listen on local monitor socket, errno = %d", errno);
- exit(1);
- }
-
- return s;
-}
-
-/*
- * Prepare a fd_set for a select call. Add all our local
- * filedescriptors to the set, increment max_fd if appropriate.
- */
-void monitor_prepselect(fd_set *selset, int *max_fd)
-{
- int i;
-
- VARA_FOREACH(connections, i) {
- int fd = VARA_AT(connections, i).sock;
- if (fd > *max_fd)
- *max_fd = fd;
- FD_SET(fd, selset);
- }
-}
-
-/*
- * Check if the result from a select call indicates something
- * to do for us.
- */
-void monitor_handle_input(fd_set *selset)
-{
- int i;
-
- VARA_FOREACH(connections, i) {
- int fd = VARA_AT(connections, i).sock;
- if (FD_ISSET(fd, selset)) {
- /* handle command from this client */
- if (monitor_command(i, fd, VARA_AT(connections, i).rights) != 0) {
- /* broken or closed connection */
- log(LL_DBG, "monitor connection #%d closed", i);
- VARA_REMOVEAT(connections, i);
- i--;
- }
- }
- }
-
- /* all connections gone? */
- if (VARA_NUM(connections) == 0)
- accepted = 0;
-}
-
-/*
- * Try new incoming connection on the given socket.
- * Setup client descriptor and send initial data.
- */
-void monitor_handle_connect(int sockfd, int is_local)
-{
- struct monitor_connection *con;
-#ifndef I4B_NOTCPIP_MONITOR
- struct sockaddr_in ia;
- u_int32_t ha = 0;
-#endif
- struct sockaddr_un ua;
- BYTE idata[I4B_MON_IDATA_SIZE];
- int fd = -1, s, i, r_mask;
- char source[FILENAME_MAX];
-
- /* accept the connection */
- if (is_local) {
- s = sizeof ua;
- fd = accept(sockfd, (struct sockaddr *)&ua, &s);
- strcpy(source, "local connection");
-#ifndef I4B_NOTCPIP_MONITOR
- } else {
- s = sizeof ia;
- fd = accept(sockfd, (struct sockaddr *)&ia, &s);
- snprintf(source, sizeof source, "tcp/ip connection from %s\n",
- inet_ntoa(ia.sin_addr));
- memcpy(&ha, &ia.sin_addr.s_addr, sizeof ha);
- ha = ntohl(ha);
-#endif
- }
-
- /* check the access rights of this connection */
- r_mask = 0;
- VARA_FOREACH(rights, i) {
- struct monitor_rights *r = &VARA_AT(rights, i);
- if (r->local) {
- if (is_local) {
- r_mask = r->rights;
- break;
- }
-#ifndef I4B_NOTCPIP_MONITOR
- } else {
- if ((ha & r->mask) == r->net) {
- r_mask = r->rights;
- break;
- }
-#endif
- }
- }
-
- if (r_mask == 0) {
- /* no rights - go away */
- log(LL_DBG, "monitor access denied: %s", source);
- close(fd);
- return;
- }
-
- accepted = 1;
- i = VARA_NUM(connections);
- VARA_ADD_AT(connections, i, struct monitor_connection, INITIAL_CONNECTIONS_ALLOC);
- con = &VARA_AT(connections, i);
- memset(con, 0, sizeof *con);
- con->sock = fd;
- con->rights = r_mask;
- log(LL_DBG, "monitor access granted, rights = %x, #%d, %s",
- r_mask, i, source);
-
- /* send initial data */
- I4B_PREP_CMD(idata, I4B_MON_IDATA_CODE);
- I4B_PUT_2B(idata, I4B_MON_IDATA_VERSMAJOR, MPROT_VERSION);
- I4B_PUT_2B(idata, I4B_MON_IDATA_VERSMINOR, MPROT_REL);
- I4B_PUT_2B(idata, I4B_MON_IDATA_NUMCTRL, ncontroller);
- I4B_PUT_4B(idata, I4B_MON_IDATA_CLACCESS, r_mask);
- write(fd, idata, sizeof idata);
-
- for (i = 0; i < ncontroller; i++) {
- BYTE ictrl[I4B_MON_ICTRL_SIZE];
- I4B_PREP_CMD(ictrl, I4B_MON_ICTRL_CODE);
- I4B_PUT_STR(ictrl, I4B_MON_ICTRL_NAME, name_of_controller(isdn_ctrl_tab[i].ctrl_type, isdn_ctrl_tab[i].card_type));
- I4B_PUT_2B(ictrl, I4B_MON_ICTRL_BUSID, 0);
- I4B_PUT_4B(ictrl, I4B_MON_ICTRL_FLAGS, 0);
- I4B_PUT_4B(ictrl, I4B_MON_ICTRL_NCHAN, 2);
- write(fd, ictrl, sizeof ictrl);
- }
-}
-
-/* dump all monitor rights */
-static void cmd_dump_rights(int fd, int r_mask, BYTE *cmd)
-{
- int i;
- BYTE drini[I4B_MON_DRINI_SIZE];
- BYTE dr[I4B_MON_DR_SIZE];
-
- I4B_PREP_EVNT(drini, I4B_MON_DRINI_CODE);
- I4B_PUT_2B(drini, I4B_MON_DRINI_COUNT, VARA_NUM(rights));
- write(fd, drini, sizeof drini);
-
- VARA_FOREACH(rights, i) {
- I4B_PREP_EVNT(dr, I4B_MON_DR_CODE);
- I4B_PUT_4B(dr, I4B_MON_DR_RIGHTS, VARA_AT(rights, i).rights);
- I4B_PUT_4B(dr, I4B_MON_DR_NET, VARA_AT(rights, i).net);
- I4B_PUT_4B(dr, I4B_MON_DR_MASK, VARA_AT(rights, i).mask);
- I4B_PUT_1B(dr, I4B_MON_DR_LOCAL, VARA_AT(rights, i).local);
- write(fd, dr, sizeof dr);
- }
-}
-
-/* rescan config file */
-static void cmd_reread_cfg(int fd, int rights, BYTE *cmd)
-{
- rereadconfig(42);
-}
-
-/* drop one connection */
-static void cmd_hangup(int fd, int rights, BYTE *cmd)
-{
- int channel = I4B_GET_4B(cmd, I4B_MON_HANGUP_CHANNEL);
- hangup_channel(channel);
-}
-
-/* dump all active monitor connections */
-static void cmd_dump_mcons(int fd, int rights, BYTE *cmd)
-{
- int i;
- BYTE dcini[I4B_MON_DCINI_SIZE];
-
- I4B_PREP_EVNT(dcini, I4B_MON_DCINI_CODE);
- I4B_PUT_2B(dcini, I4B_MON_DCINI_COUNT, VARA_NUM(connections));
- write(fd, dcini, sizeof dcini);
-
- VARA_FOREACH(connections, i) {
-#ifndef I4B_NOTCPIP_MONITOR
- int namelen;
- struct sockaddr_in name;
-#endif
- BYTE dc[I4B_MON_DC_SIZE];
-
- I4B_PREP_EVNT(dc, I4B_MON_DC_CODE);
- I4B_PUT_4B(dc, I4B_MON_DC_RIGHTS, VARA_AT(connections, i).rights);
-#ifndef I4B_NOTCPIP_MONITOR
- namelen = sizeof name;
- if (getpeername(VARA_AT(connections, i).sock, (struct sockaddr*)&name, &namelen) == 0)
- memcpy(dc+I4B_MON_DC_WHO, &name.sin_addr, sizeof name.sin_addr);
-#endif
- write(fd, dc, sizeof dc);
- }
-}
-
-/*
- * Handle a command from the given socket. The client
- * has rights as specified in the rights parameter.
- * Return non-zero if connection is closed.
- */
-static int monitor_command(int con_index, int fd, int rights)
-{
- char cmd[I4B_MAX_MON_CLIENT_CMD];
- u_int code;
- /* command dispatch table */
- typedef void (*cmd_func_t)(int fd, int rights, BYTE *cmd);
- static struct {
- cmd_func_t call; /* function to execute */
- u_int rights; /* necessary rights */
- } cmd_tab[] =
- {
- /* 0 */ { NULL, 0 },
- /* 1 */ { cmd_dump_rights, I4B_CA_COMMAND_FULL },
- /* 2 */ { cmd_dump_mcons, I4B_CA_COMMAND_FULL },
- /* 3 */ { cmd_reread_cfg, I4B_CA_COMMAND_FULL },
- /* 4 */ { cmd_hangup, I4B_CA_COMMAND_FULL },
- };
-#define NUMCMD (sizeof cmd_tab / sizeof cmd_tab[0])
-
- u_long u;
- int bytes;
-
- /* Network transfer may deliver two or more packets concatenated.
- * Peek at the header and read only one event at a time... */
- ioctl(fd, FIONREAD, &u);
- if (u < I4B_MON_CMD_HDR) {
- if (u == 0) {
- /* socket closed by peer */
- close(fd);
- return 1;
- }
- return 0; /* not enough data there yet */
- }
- bytes = recv(fd, cmd, I4B_MON_CMD_HDR, MSG_PEEK);
- if (bytes < I4B_MON_CMD_HDR)
- return 0; /* errh? something must be wrong... */
- bytes = I4B_GET_2B(cmd, I4B_MON_CMD_LEN);
- if (bytes >= sizeof cmd) {
- close(fd);
- log(LL_ERR, "garbage on monitor connection #%d, closing it", con_index);
- return 1;
- }
- /* now we know the size, it fits, so lets read it! */
- if (read(fd, cmd, bytes) <= 0) {
- close(fd);
- return 1;
- }
-
- /* decode command */
- code = I4B_GET_2B(cmd, I4B_MON_CMD);
-
- /* special case: may modify our connection descriptor, is
- * beyound all rights checks */
- if (code == I4B_MON_CCMD_SETMASK) {
- /*
- u_int major = I4B_GET_2B(cmd, I4B_MON_ICLIENT_VERMAJOR);
- u_int minor = I4B_GET_2B(cmd, I4B_MON_ICLIENT_VERMINOR);
- */
- int events = I4B_GET_4B(cmd, I4B_MON_ICLIENT_EVENTS);
- VARA_AT(connections, con_index).events = events & rights;
- return 0;
- }
-
- if (code < 0 || code >= NUMCMD) {
- log(LL_ERR, "illegal command from client #%d: code = %d\n",
- con_index, code);
- return 0;
- }
- if (cmd_tab[code].call == NULL)
- return 0;
- if ((cmd_tab[code].rights & rights) == cmd_tab[code].rights)
- cmd_tab[code].call(fd, rights, cmd);
-
- return 0;
-}
-
-/*
- * Check if somebody would receive an event with this mask.
- * We are lazy and try to avoid assembling unneccesary packets.
- * Return 0 if no one interested, nonzero otherwise.
- */
-static int anybody(int mask)
-{
- int i;
-
- VARA_FOREACH(connections, i)
- if ((VARA_AT(connections, i).events & mask) == mask)
- return 1;
-
- return 0;
-}
-
-/*
- * Send an event to every connection interested in this kind of
- * event
- */
-static void monitor_broadcast(int mask, const BYTE *pkt, size_t bytes)
-{
- int i;
-
- VARA_FOREACH(connections, i) {
- if ((VARA_AT(connections, i).events & mask) == mask) {
- int fd = VARA_AT(connections, i).sock;
- write(fd, pkt, bytes);
- }
- }
-}
-
-/*
- * Post a logfile event
- */
-void monitor_evnt_log(int prio, const char * what, const char * msg)
-{
- BYTE evnt[I4B_MON_LOGEVNT_SIZE];
- time_t now;
-
- if (!anybody(I4B_CA_EVNT_I4B)) return;
-
- time(&now);
- I4B_PREP_EVNT(evnt, I4B_MON_LOGEVNT_CODE);
- I4B_PUT_4B(evnt, I4B_MON_LOGEVNT_TSTAMP, (long)now);
- I4B_PUT_4B(evnt, I4B_MON_LOGEVNT_PRIO, prio);
- I4B_PUT_STR(evnt, I4B_MON_LOGEVNT_WHAT, what);
- I4B_PUT_STR(evnt, I4B_MON_LOGEVNT_MSG, msg);
-
- monitor_broadcast(I4B_CA_EVNT_I4B, evnt, sizeof evnt);
-}
-
-/*
- * Post a charging event on the connection described
- * by the given config entry.
- */
-void monitor_evnt_charge(cfg_entry_t *cep, int units, int estimate)
-{
- int chno = CHNO(cep);
- int mask = (cep->direction == DIR_IN) ? I4B_CA_EVNT_CALLIN : I4B_CA_EVNT_CALLOUT;
- time_t now;
- BYTE evnt[I4B_MON_CHRG_SIZE];
-
- if (!anybody(mask)) return;
-
- time(&now);
- I4B_PREP_EVNT(evnt, I4B_MON_CHRG_CODE);
- I4B_PUT_4B(evnt, I4B_MON_CHRG_TSTAMP, (long)now);
- I4B_PUT_4B(evnt, I4B_MON_CHRG_CHANNEL, chno);
- I4B_PUT_4B(evnt, I4B_MON_CHRG_UNITS, units);
- I4B_PUT_4B(evnt, I4B_MON_CHRG_ESTIMATED, estimate ? 1 : 0);
-
- monitor_broadcast(mask, evnt, sizeof evnt);
-}
-
-/*
- * Post a connection event
- */
-void monitor_evnt_connect(cfg_entry_t *cep)
-{
- BYTE evnt[I4B_MON_CONNECT_SIZE];
- char devname[I4B_MAX_MON_STRING];
- int chno = CHNO(cep);
- int mask = (cep->direction == DIR_IN) ? I4B_CA_EVNT_CALLIN : I4B_CA_EVNT_CALLOUT;
- time_t now;
-
- if (!anybody(mask)) return;
-
- time(&now);
- snprintf(devname, sizeof devname, "%s%d", bdrivername(cep->usrdevicename), cep->usrdeviceunit);
- I4B_PREP_EVNT(evnt, I4B_MON_CONNECT_CODE);
- I4B_PUT_4B(evnt, I4B_MON_CONNECT_TSTAMP, (long)now);
- I4B_PUT_4B(evnt, I4B_MON_CONNECT_DIR, cep->direction == DIR_OUT ? 1 : 0);
- I4B_PUT_4B(evnt, I4B_MON_CONNECT_CHANNEL, chno);
- I4B_PUT_STR(evnt, I4B_MON_CONNECT_CFGNAME, cep->name);
- I4B_PUT_STR(evnt, I4B_MON_CONNECT_DEVNAME, devname);
- I4B_PUT_STR(evnt, I4B_MON_CONNECT_REMPHONE, cep->real_phone_incoming);
- I4B_PUT_STR(evnt, I4B_MON_CONNECT_LOCPHONE, cep->remote_phone_dialout);
-
- monitor_broadcast(mask, evnt, sizeof evnt);
-}
-
-/*
- * Post a disconnect event
- */
-void monitor_evnt_disconnect(cfg_entry_t *cep)
-{
- BYTE evnt[I4B_MON_DISCONNECT_SIZE];
- int chno = CHNO(cep);
- int mask = (cep->direction == DIR_IN) ? I4B_CA_EVNT_CALLIN : I4B_CA_EVNT_CALLOUT;
- time_t now;
-
- if (!anybody(mask)) return;
-
- time(&now);
- I4B_PREP_EVNT(evnt, I4B_MON_DISCONNECT_CODE);
- I4B_PUT_4B(evnt, I4B_MON_DISCONNECT_TSTAMP, (long)now);
- I4B_PUT_4B(evnt, I4B_MON_DISCONNECT_CHANNEL, chno);
-
- monitor_broadcast(mask, evnt, sizeof evnt);
-}
-
-/*
- * Post an up/down event
- */
-void monitor_evnt_updown(cfg_entry_t *cep, int up)
-{
- BYTE evnt[I4B_MON_UPDOWN_SIZE];
- int chno = CHNO(cep);
- int mask = (cep->direction == DIR_IN) ? I4B_CA_EVNT_CALLIN : I4B_CA_EVNT_CALLOUT;
- time_t now;
-
- if (!anybody(mask)) return;
-
- time(&now);
- I4B_PREP_EVNT(evnt, I4B_MON_UPDOWN_CODE);
- I4B_PUT_4B(evnt, I4B_MON_UPDOWN_TSTAMP, (long)now);
- I4B_PUT_4B(evnt, I4B_MON_UPDOWN_CHANNEL, chno);
- I4B_PUT_4B(evnt, I4B_MON_UPDOWN_ISUP, up);
-
- monitor_broadcast(mask, evnt, sizeof evnt);
-}
-
-void hangup_channel(int channel)
-{
- int i;
- cfg_entry_t * cep = NULL;
-
- for (i = 0; i < ncontroller; i++)
- {
- if(isdn_ctrl_tab[i].state != CTRL_UP)
- continue;
- if(isdn_ctrl_tab[i].stateb1 != CHAN_IDLE)
- {
- cep = get_cep_by_cc(i, 0);
- if (cep != NULL && CHNO(cep) == channel)
- goto found;
- }
- if(isdn_ctrl_tab[i].stateb2 != CHAN_IDLE)
- {
- cep = get_cep_by_cc(i, 1);
- if (cep != NULL && CHNO(cep) == channel)
- goto found;
- }
- }
- /* not found */
- return;
-
-found:
- cep->hangup = 1;
- return;
-}
-
-#endif /* I4B_EXTERNAL_MONITOR */
diff --git a/usr.sbin/i4b/isdnd/msghdl.c b/usr.sbin/i4b/isdnd/msghdl.c
deleted file mode 100644
index 61ac0edae289..000000000000
--- a/usr.sbin/i4b/isdnd/msghdl.c
+++ /dev/null
@@ -1,983 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - message from kernel handling routines
- * --------------------------------------------------
- *
- * $Id: msghdl.c,v 1.54 1998/12/19 09:03:16 hm Exp $
- *
- * last edit-date: [Sat Dec 19 09:57:16 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-/*---------------------------------------------------------------------------*
- * handle incoming CONNECT_IND (=SETUP) message
- *---------------------------------------------------------------------------*/
-void
-msg_connect_ind(msg_connect_ind_t *mp)
-{
- cfg_entry_t *cep;
- char *src_tela = "ERROR-src_tela";
- char *dst_tela = "ERROR-dst_tela";
-
-#define SRC (aliasing == 0 ? mp->src_telno : src_tela)
-#define DST (aliasing == 0 ? mp->dst_telno : dst_tela)
-
- if((cep = find_matching_entry_incoming(mp)) == NULL)
- {
- /* log message generated in find_matching_entry_incoming() */
- sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
- return;
- }
-
- if(cep->cdid != CDID_UNUSED && cep->cdid != CDID_RESERVED)
- {
- /*
- * This is an incoming call on a number we just dialed out.
- * Stop our dial-out and accept the incoming call.
- */
- if(cep->saved_call.cdid != CDID_UNUSED &&
- cep->saved_call.cdid != CDID_RESERVED)
- {
- int cdid;
-
- /* disconnect old, not new */
-
- cdid = cep->cdid;
- cep->cdid = cep->saved_call.cdid;
- sendm_disconnect_req(cep, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- cep->cdid = cdid;
-
- /*
- * Shortcut the state machine and mark this
- * entry as free
- */
-/* XXX */ cep->state = ST_IDLE; /* this is an invalid */
- /* transition, */
- /* so no next_state() */
- /* we have to wait here for an incoming */
- /* disconnect message !!! (-hm) */
- }
- }
-
- if(aliasing)
- {
- src_tela = get_alias(mp->src_telno);
- dst_tela = get_alias(mp->dst_telno);
- }
-
- if(cep->inout == DIR_OUTONLY)
- {
- log(LL_CHD, "%05d %s incoming call from %s to %s not allowed by configuration!",
- mp->header.cdid, cep->name, SRC, DST);
- sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
- return;
- }
-
- cep->charge = 0;
- cep->last_charge = 0;
-
- switch(cep->dialin_reaction)
- {
- case REACT_ACCEPT:
- log(LL_CHD, "%05d %s accepting: incoming call from %s to %s",
- mp->header.cdid, cep->name, SRC, DST);
- decr_free_channels(mp->controller);
- next_state(cep, EV_MCI);
- break;
-
- case REACT_REJECT:
- log(LL_CHD, "%05d %s rejecting: incoming call from %s to %s",
- mp->header.cdid, cep->name, SRC, DST);
- sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
- (CAUSET_I4B << 8) | CAUSE_I4B_REJECT);
- cep->cdid = CDID_UNUSED;
- break;
-
- case REACT_IGNORE:
- log(LL_CHD, "%05d %s ignoring: incoming call from %s to %s",
- mp->header.cdid, cep->name, SRC, DST);
- sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
- break;
-
- case REACT_ANSWER:
- decr_free_channels(mp->controller);
- if(cep->alert)
- {
- if(mp->display)
- {
- log(LL_CHD, "%05d %s alerting: incoming call from %s to %s (%s)",
- mp->header.cdid, cep->name, SRC, DST, mp->display);
- }
- else
- {
- log(LL_CHD, "%05d %s alerting: incoming call from %s to %s",
- mp->header.cdid, cep->name, SRC, DST);
- }
- next_state(cep, EV_ALRT);
- }
- else
- {
- if(mp->display)
- {
- log(LL_CHD, "%05d %s answering: incoming call from %s to %s (%s)",
- mp->header.cdid, cep->name, SRC, DST, mp->display);
- }
- else
- {
- log(LL_CHD, "%05d %s answering: incoming call from %s to %s",
- mp->header.cdid, cep->name, SRC, DST);
- }
- next_state(cep, EV_MCI);
- }
- break;
-
- case REACT_CALLBACK:
-#ifdef NOTDEF
-/*XXX reserve channel ??? */ decr_free_channels(mp->controller);
-#endif
- if(cep->cdid == CDID_RESERVED)
- {
- log(LL_CHD, "%05d %s reserved: incoming call from %s to %s",
- mp->header.cdid, cep->name, SRC, DST);
- sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
- (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- /* no state change */
- }
- else
- {
- log(LL_CHD, "%05d %s callback: incoming call from %s to %s",
- mp->header.cdid, cep->name, SRC, DST);
- sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
- (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- cep->last_release_time = time(NULL);
- cep->cdid = CDID_RESERVED;
- next_state(cep, EV_CBRQ);
- }
- break;
-
- default:
- log(LL_WRN, "msg_connect_ind: unknown response type, tx SETUP_RESP_DNTCRE");
- sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
- break;
- }
-#undef SRC
-#undef DST
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming CONNECT_ACTIVE_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_connect_active_ind(msg_connect_active_ind_t *mp)
-{
- cfg_entry_t *cep;
-
- if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
- {
- log(LL_WRN, "msg_connect_active_ind: cdid not found!");
- return;
- }
-
- cep->isdncontrollerused = mp->controller;
- cep->isdnchannelused = mp->channel;
-
- cep->aoc_now = cep->connect_time = time(NULL);
- cep->aoc_last = 0;
- cep->aoc_diff = 0;
- cep->aoc_valid = AOC_INVALID;
-
- cep->local_disconnect = DISCON_REM;
-
- cep->inbytes = INVALID;
- cep->outbytes = INVALID;
- cep->hangup = 0;
-
- /* set the B-channel to active */
-
- if((set_channel_busy(cep->isdncontrollerused, cep->isdnchannelused)) == ERROR)
- log(LL_ERR, "msg_connect_active_ind: set_channel_busy failed!");
-
- if(cep->direction == DIR_OUT)
- {
- log(LL_CHD, "%05d %s outgoing call active (ctl %d, ch %d)",
- cep->cdid, cep->name,
- cep->isdncontrollerused, cep->isdnchannelused);
- }
- else
- {
- log(LL_CHD, "%05d %s incoming call active (ctl %d, ch %d)",
- cep->cdid, cep->name,
- cep->isdncontrollerused, cep->isdnchannelused);
- }
-
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_connect(cep);
-#endif
-#ifdef I4B_EXTERNAL_MONITOR
- if(do_monitor && accepted)
- monitor_evnt_connect(cep);
-#endif
-
- if(isdntime && (mp->datetime[0] != '\0'))
- {
- log(LL_DMN, "date/time from exchange = %s", mp->datetime);
- }
-
- next_state(cep, EV_MCAI);
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming PROCEEDING_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_proceeding_ind(msg_proceeding_ind_t *mp)
-{
- cfg_entry_t *cep;
-
- if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
- {
- log(LL_WRN, "msg_proceeding_ind: cdid not found!");
- return;
- }
-
- cep->isdncontrollerused = mp->controller;
- cep->isdnchannelused = mp->channel;
-
- /* set the B-channels active */
-
- if((set_channel_busy(cep->isdncontrollerused, cep->isdnchannelused)) == ERROR)
- log(LL_ERR, "msg_proceeding_ind: set_channel_busy failed!");
-
- log(LL_CHD, "%05d %s outgoing call proceeding (ctl %d, ch %d)",
- cep->cdid, cep->name,
- cep->isdncontrollerused, cep->isdnchannelused);
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming ALERT_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_alert_ind(msg_alert_ind_t *mp)
-{
- cfg_entry_t *cep;
-
- if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
- {
- log(LL_WRN, "msg_alert_ind: cdid not found!");
- return;
- }
-#ifdef NOTDEF
- log(LL_CHD, "%05d %s incoming alert", cep->cdid, cep->name);
-#endif
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming L12STAT_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_l12stat_ind(msg_l12stat_ind_t *ml)
-{
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_l12stat(ml->controller, ml->layer, ml->state);
-#endif
-
- DBGL(DL_CNST, (log(LL_DBG, "msg_l12stat_ind: unit %d, layer %d, state %d",
- ml->controller, ml->layer, ml->state)));
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming TEIASG_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_teiasg_ind(msg_teiasg_ind_t *mt)
-{
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_tei(mt->controller, mt->tei);
-#endif
-
- DBGL(DL_CNST, (log(LL_DBG, "msg_teiasg_ind: unit %d, tei = %d",
- mt->controller, mt->tei)));
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming L12STAT_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_pdeact_ind(msg_pdeact_ind_t *md)
-{
- int i;
- int ctrl = md->controller;
- cfg_entry_t *cep;
-
-#ifdef USE_CURSES
- if(do_fullscreen)
- {
- display_l12stat(ctrl, LAYER_ONE, LAYER_IDLE);
- display_l12stat(ctrl, LAYER_TWO, LAYER_IDLE);
- display_tei(ctrl, -1);
- }
-#endif
-
- DBGL(DL_CNST, (log(LL_DBG, "msg_pdeact_ind: unit %d, persistent deactivation", ctrl)));
-
- for(i=0; i < nentries; i++)
- {
- if((cfg_entry_tab[i].cdid != CDID_UNUSED) &&
- (cfg_entry_tab[i].isdncontrollerused == ctrl))
- {
- cep = &cfg_entry_tab[i];
-
- if(cep->cdid == CDID_RESERVED)
- {
- cep->cdid = CDID_UNUSED;
- continue;
- }
-
- cep->cdid = CDID_UNUSED;
-
- cep->last_release_time = time(NULL);
-
- SET_CAUSE_TYPE(cep->disc_cause, CAUSET_I4B);
- SET_CAUSE_VAL(cep->disc_cause, CAUSE_I4B_L1ERROR);
-
- if(cep->direction == DIR_OUT)
- {
- log(LL_CHD, "%05d %s outgoing call disconnected (local)",
- cep->cdid, cep->name);
- }
- else
- {
- log(LL_CHD, "%05d %s incoming call disconnected (local)",
- cep->cdid, cep->name);
- }
-
- log(LL_CHD, "%05d %s cause %s",
- cep->cdid, cep->name, print_i4b_cause(cep->disc_cause));
-
-#ifdef USE_CURSES
- if(do_fullscreen && (cep->connect_time > 0))
- display_disconnect(cep);
-#endif
-
-#ifdef I4B_EXTERNAL_MONITOR
- if(do_monitor && accepted)
- monitor_evnt_disconnect(cep);
-#endif
- if(cep->disconnectprog)
- exec_connect_prog(cep, cep->disconnectprog, 1);
-
- if(cep->connect_time > 0)
- {
- if(cep->direction == DIR_OUT)
- {
- log(LL_CHD, "%05d %s charging: %d units, %d seconds",
- cep->cdid, cep->name, cep->charge,
- (int)difftime(time(NULL), cep->connect_time));
- }
- else
- {
- log(LL_CHD, "%05d %s connected %d seconds",
- cep->cdid, cep->name,
- (int)difftime(time(NULL), cep->connect_time));
- }
-
- if((cep->inbytes != INVALID) && (cep->outbytes != INVALID))
- {
- if((cep->ioutbytes != cep->outbytes) ||
- (cep->iinbytes != cep->inbytes))
- {
- log(LL_CHD, "%05d %s accounting: in %d, out %d (in %d, out %d)",
- cep->cdid, cep->name,
- cep->inbytes, cep->outbytes,
- cep->iinbytes, cep->ioutbytes);
- }
- else
- {
- log(LL_CHD, "%05d %s accounting: in %d, out %d",
- cep->cdid, cep->name,
- cep->inbytes, cep->outbytes);
- }
- }
- }
-
- if(useacctfile && (cep->connect_time > 0))
- {
- int con_secs;
- char logdatetime[41];
- struct tm *tp;
-
- con_secs = difftime(time(NULL), cep->connect_time);
-
- tp = localtime(&cep->connect_time);
-
- strftime(logdatetime,40,I4B_TIME_FORMAT,tp);
-
- if(cep->inbytes != INVALID && cep->outbytes != INVALID)
- {
- fprintf(acctfp, "%s - %s %s %d (%d) (%d/%d)\n",
- logdatetime, getlogdatetime(),
- cep->name, cep->charge, con_secs,
- cep->inbytes, cep->outbytes);
- }
- else
- {
- fprintf(acctfp, "%s - %s %s %d (%d)\n",
- logdatetime, getlogdatetime(),
- cep->name, cep->charge, con_secs);
- }
- }
-
- /* set the B-channel inactive */
-
- if((set_channel_idle(cep->isdncontrollerused, cep->isdnchannelused)) == ERROR)
- log(LL_ERR, "msg_pdeact_ind: set_channel_idle failed!");
-
- incr_free_channels(cep->isdncontrollerused);
-
- cep->connect_time = 0;
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming NEGCOMP_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_negcomplete_ind(msg_negcomplete_ind_t *mp)
-{
- cfg_entry_t *cep;
-
- if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
- {
- log(LL_WRN, "msg_negcomp_ind: cdid not found");
- return;
- }
-
- if(cep->connectprog)
- exec_connect_prog(cep, cep->connectprog, 0);
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming IFSTATE_CHANGED indication
- *---------------------------------------------------------------------------*/
-void
-msg_ifstatechg_ind(msg_ifstatechg_ind_t *mp)
-{
- cfg_entry_t *cep;
- char *device;
-
- if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
- {
- log(LL_WRN, "msg_negcomp_ind: cdid not found");
- return;
- }
-
- device = bdrivername(cep->usrdevicename);
- log(LL_DBG, "%s%d: switched to state %d\n", device, cep->usrdeviceunit, mp->state);
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming DISCONNECT_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_disconnect_ind(msg_disconnect_ind_t *mp)
-{
- cfg_entry_t *cep;
-
- if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
- {
- log(LL_WRN, "msg_disconnect_ind: cdid not found");
- return;
- }
-
- /* is this an aborted out-call prematurely called back? */
- if (cep->saved_call.cdid == mp->header.cdid)
- {
- DBGL(DL_CNST, (log(LL_DBG, "aborted outcall %05d disconnected",
- mp->header.cdid)));
- cep->saved_call.cdid = CDID_UNUSED;
-
- if((set_channel_idle(cep->saved_call.controller, cep->saved_call.channel)) == ERROR)
- log(LL_ERR, "msg_disconnect_ind: set_channel_idle failed!");
-
- incr_free_channels(cep->saved_call.controller);
- return;
- }
-
- cep->last_release_time = time(NULL);
- cep->disc_cause = mp->cause;
-
- if(cep->direction == DIR_OUT)
- {
- log(LL_CHD, "%05d %s outgoing call disconnected %s",
- cep->cdid, cep->name,
- cep->local_disconnect == DISCON_LOC ?
- "(local)" : "(remote)");
- }
- else
- {
- log(LL_CHD, "%05d %s incoming call disconnected %s",
- cep->cdid, cep->name,
- cep->local_disconnect == DISCON_LOC ?
- "(local)" : "(remote)");
- }
-
- log(LL_CHD, "%05d %s cause %s",
- cep->cdid, cep->name, print_i4b_cause(mp->cause));
-
-#ifdef USE_CURSES
- if(do_fullscreen && (cep->connect_time > 0))
- display_disconnect(cep);
-#endif
-
-#ifdef I4B_EXTERNAL_MONITOR
- if(do_monitor && accepted)
- monitor_evnt_disconnect(cep);
-#endif
-
- if(cep->disconnectprog)
- exec_connect_prog(cep, cep->disconnectprog, 1);
-
- if(cep->connect_time > 0)
- {
- if(cep->direction == DIR_OUT)
- {
- log(LL_CHD, "%05d %s charging: %d units, %d seconds",
- cep->cdid, cep->name, cep->charge,
- (int)difftime(time(NULL), cep->connect_time));
- }
- else
- {
- log(LL_CHD, "%05d %s connected %d seconds",
- cep->cdid, cep->name,
- (int)difftime(time(NULL), cep->connect_time));
- }
-
- if((cep->inbytes != INVALID) && (cep->outbytes != INVALID))
- {
- if((cep->ioutbytes != cep->outbytes) ||
- (cep->iinbytes != cep->inbytes))
- {
- log(LL_CHD, "%05d %s accounting: in %d, out %d (in %d, out %d)",
- cep->cdid, cep->name,
- cep->inbytes, cep->outbytes,
- cep->iinbytes, cep->ioutbytes);
- }
- else
- {
- log(LL_CHD, "%05d %s accounting: in %d, out %d",
- cep->cdid, cep->name,
- cep->inbytes, cep->outbytes);
- }
- }
- }
-
- if(useacctfile && (cep->connect_time > 0))
- {
- int con_secs;
- char logdatetime[41];
- struct tm *tp;
-
- con_secs = difftime(time(NULL), cep->connect_time);
-
- tp = localtime(&cep->connect_time);
-
- strftime(logdatetime,40,I4B_TIME_FORMAT,tp);
-
- if(cep->inbytes != INVALID && cep->outbytes != INVALID)
- {
- fprintf(acctfp, "%s - %s %s %d (%d) (%d/%d)\n",
- logdatetime, getlogdatetime(),
- cep->name, cep->charge, con_secs,
- cep->inbytes, cep->outbytes);
- }
- else
- {
- fprintf(acctfp, "%s - %s %s %d (%d)\n",
- logdatetime, getlogdatetime(),
- cep->name, cep->charge, con_secs);
- }
- }
-
- /* set the B-channel inactive */
-
- if((set_channel_idle(cep->isdncontrollerused, cep->isdnchannelused)) == ERROR)
- log(LL_ERR, "msg_disconnect_ind: set_channel_idle failed!");
-
- incr_free_channels(cep->isdncontrollerused);
-
- cep->connect_time = 0;
-
- next_state(cep, EV_MDI);
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming DIALOUT message
- *---------------------------------------------------------------------------*/
-void
-msg_dialout(msg_dialout_ind_t *mp)
-{
- cfg_entry_t *cep;
-
- DBGL(DL_DRVR, (log(LL_DBG, "msg_dialout: dial req from %s, unit %d", bdrivername(mp->driver), mp->driver_unit)));
-
- if((cep = find_by_device_for_dialout(mp->driver, mp->driver_unit)) == NULL)
- {
- DBGL(DL_DRVR, (log(LL_DBG, "msg_dialout: config entry reserved or no match")));
- return;
- }
-
- if(cep->inout == DIR_INONLY)
- {
- dialresponse(cep, DSTAT_INONLY);
- return;
- }
-
- if((cep->cdid = get_cdid()) == 0)
- {
- DBGL(DL_DRVR, (log(LL_DBG, "msg_dialout: get_cdid() returned 0!")));
- return;
- }
-
- cep->charge = 0;
- cep->last_charge = 0;
-
- next_state(cep, EV_MDO);
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming DRVRDISC_REQ message
- *---------------------------------------------------------------------------*/
-void
-msg_drvrdisc_req(msg_drvrdisc_req_t *mp)
-{
- cfg_entry_t *cep;
-
- DBGL(DL_DRVR, (log(LL_DBG, "msg_drvrdisc_req: req from %s, unit %d", bdrivername(mp->driver), mp->driver_unit)));
-
- if((cep = get_cep_by_driver(mp->driver, mp->driver_unit)) == NULL)
- {
- DBGL(DL_DRVR, (log(LL_DBG, "msg_drvrdisc_req: config entry not found")));
- return;
- }
- next_state(cep, EV_DRQ);
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming ACCOUNTING message
- *---------------------------------------------------------------------------*/
-void
-msg_accounting(msg_accounting_ind_t *mp)
-{
- cfg_entry_t *cep;
-
- if((cep = find_active_entry_by_driver(mp->driver, mp->driver_unit)) == NULL)
- {
- log(LL_WRN, "msg_accounting: no config entry found!");
- return;
- }
-
- cep->inbytes = mp->inbytes;
- cep->iinbytes = mp->iinbytes;
- cep->outbytes = mp->outbytes;
- cep->ioutbytes = mp->ioutbytes;
- cep->inbps = mp->inbps;
- cep->outbps = mp->outbps;
-
- if(mp->accttype == ACCT_DURING)
- {
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_acct(cep);
-#endif
-#ifdef NOTDEF
- else
- DBGL(DL_DRVR, (log(LL_DBG, "msg_accounting: %s%d, ioutb=%d, iinb=%d, outb=%d, inb=%d, outbps=%d, inbps=%d",
- bdrivername(mp->driver), mp->driver_unit,
- mp->ioutbytes, mp->iinbytes,
- mp->outbytes, mp->inbytes,
- mp->outbps, mp->inbps)));
-#endif
- }
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming CHARGING message
- *---------------------------------------------------------------------------*/
-void
-msg_charging_ind(msg_charging_ind_t *mp)
-{
- static char *cttab[] = {
- "invalid",
- "AOCD",
- "AOCE",
- "estimated" };
-
- cfg_entry_t *cep;
-
- if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
- {
- log(LL_WRN, "msg_charging_ind: cdid not found");
- return;
- }
-
- if(mp->units_type < CHARGE_INVALID || mp->units_type > CHARGE_CALC)
- {
- log(LL_ERR, "msg_charging: units_type %d out of range!", mp->units_type);
- do_exit(1);
- }
-
- DBGL(DL_DRVR, (log(LL_DBG, "msg_charging: %d unit(s) (%s)",
- mp->units, cttab[mp->units_type])));
-
- switch(mp->units_type)
- {
- case CHARGE_AOCD:
- cep->charge = mp->units;
-
- if((cep->unitlengthsrc == ULSRC_DYN) &&
- (cep->charge != cep->last_charge))
- {
- cep->last_charge = cep->charge;
- handle_charge(cep);
- }
- break;
-
- case CHARGE_AOCE:
- cep->charge = mp->units;
- break;
-
- case CHARGE_CALC:
- cep->charge = mp->units;
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_ccharge(cep, mp->units);
-#endif
-#ifdef I4B_EXTERNAL_MONITOR
- if(do_monitor && accepted)
- monitor_evnt_charge(cep, mp->units, 1);
-#endif
- break;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * handle incoming IDLE_TIMEOUT_IND message
- *---------------------------------------------------------------------------*/
-void
-msg_idle_timeout_ind(msg_idle_timeout_ind_t *mp)
-{
- cfg_entry_t *cep;
-
- if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
- {
- log(LL_WRN, "msg_idle_timeout_ind: cdid not found!");
- return;
- }
-
- cep->local_disconnect = DISCON_LOC;
-
- DBGL(DL_DRVR, (log(LL_DBG, "msg_idle_timeout_ind: idletimeout, kernel sent disconnect!")));
-
- check_and_kill(cep);
-}
-
-/*---------------------------------------------------------------------------*
- * get a cdid from kernel
- *---------------------------------------------------------------------------*/
-int
-get_cdid(void)
-{
- msg_cdid_req_t mcr;
-
- mcr.cdid = 0;
-
- if((ioctl(isdnfd, I4B_CDID_REQ, &mcr)) < 0)
- {
- log(LL_ERR, "get_cdid: ioctl I4B_CDID_REQ failed: %s", strerror(errno));
- do_exit(1);
- }
-
- return(mcr.cdid);
-}
-
-/*---------------------------------------------------------------------------*
- * send message "connect request" to kernel
- *---------------------------------------------------------------------------*/
-int
-sendm_connect_req(cfg_entry_t *cep)
-{
- msg_connect_req_t mcr;
- int ret;
-
- cep->local_disconnect = DISCON_REM;
-
- cep->unitlength = get_current_rate(cep, 1);
-
- mcr.cdid = cep->cdid;
-
- mcr.controller = cep->isdncontrollerused;
- mcr.channel = cep->isdnchannelused;
- mcr.txdelay = cep->isdntxdelout;
-
- mcr.bprot = cep->b1protocol;
-
- mcr.driver = cep->usrdevicename;
- mcr.driver_unit = cep->usrdeviceunit;
-
- mcr.unitlen_time = cep->unitlength;
- mcr.idle_time = cep->idle_time_out;
- mcr.earlyhup_time = cep->earlyhangup;
-
- if(cep->unitlengthsrc == ULSRC_DYN)
- mcr.unitlen_method = ULEN_METHOD_DYNAMIC;
- else
- mcr.unitlen_method = ULEN_METHOD_STATIC;
-
- strcpy(mcr.dst_telno, cep->remote_phone_dialout);
- strcpy(mcr.src_telno, cep->local_phone_dialout);
-
- cep->last_dial_time = time(NULL);
- cep->direction = DIR_OUT;
-
- DBGL(DL_CNST, (log(LL_DBG, "sendm_connect_req: ctrl = %d, chan = %d", cep->isdncontrollerused, cep->isdnchannelused)));
-
- if((ret = ioctl(isdnfd, I4B_CONNECT_REQ, &mcr)) < 0)
- {
- log(LL_ERR, "sendm_connect_req: ioctl I4B_CONNECT_REQ failed: %s", strerror(errno));
- do_exit(1);
- }
-
- decr_free_channels(cep->isdncontrollerused);
-
- log(LL_CHD, "%05d %s dialing out from %s to %s",
- cep->cdid,
- cep->name,
- aliasing ? get_alias(cep->local_phone_dialout) : cep->local_phone_dialout,
- aliasing ? get_alias(cep->remote_phone_dialout) : cep->remote_phone_dialout);
-
- return(ret);
-}
-
-/*---------------------------------------------------------------------------*
- * send message "connect response" to kernel
- *---------------------------------------------------------------------------*/
-int
-sendm_connect_resp(cfg_entry_t *cep, int cdid, int response, int cause)
-{
- msg_connect_resp_t mcr;
- int ret;
-
- mcr.cdid = cdid;
-
- mcr.response = response;
-
- if(response == SETUP_RESP_REJECT)
- {
- mcr.cause = cause;
- }
- else if(response == SETUP_RESP_ACCEPT)
- {
- cep->direction = DIR_IN;
-
- mcr.txdelay = cep->isdntxdelin;
-
- mcr.bprot = cep->b1protocol;
-
- mcr.driver = cep->usrdevicename;
- mcr.driver_unit = cep->usrdeviceunit;
-
- mcr.max_idle_time = cep->idle_time_in;
- }
-
- if((ret = ioctl(isdnfd, I4B_CONNECT_RESP, &mcr)) < 0)
- {
- log(LL_ERR, "sendm_connect_resp: ioctl I4B_CONNECT_RESP failed: %s", strerror(errno));
- do_exit(1);
- }
-
- DBGL(DL_DRVR, (log(LL_DBG, "sendm_connect_resp: sent CONNECT_RESP")));
-
- return(ret);
-}
-
-/*---------------------------------------------------------------------------*
- * send message "disconnect request" to kernel
- *---------------------------------------------------------------------------*/
-int
-sendm_disconnect_req(cfg_entry_t *cep, int cause)
-{
- msg_discon_req_t mcr;
- int ret;
-
- mcr.cdid = cep->cdid;
-
- mcr.cause = cause;
-
- cep->local_disconnect = DISCON_LOC;
-
- if((ret = ioctl(isdnfd, I4B_DISCONNECT_REQ, &mcr)) < 0)
- {
- log(LL_ERR, "sendm_disconnect_req: ioctl I4B_DISCONNECT_REQ failed: %s", strerror(errno));
- do_exit(1);
- }
- else
- {
- DBGL(DL_DRVR, (log(LL_DBG, "sendm_disconnect_req: sent DISCONNECT_REQ")));
- }
- return(ret);
-}
-
-/*---------------------------------------------------------------------------*
- * send message "alert request" to kernel
- *---------------------------------------------------------------------------*/
-int
-sendm_alert_req(cfg_entry_t *cep)
-{
- msg_alert_req_t mar;
- int ret;
-
- mar.cdid = cep->cdid;
-
- if((ret = ioctl(isdnfd, I4B_ALERT_REQ, &mar)) < 0)
- {
- log(LL_ERR, "sendm_alert_req: ioctl I4B_ALERT_REQ failed: %s", strerror(errno));
- do_exit(1);
- }
- else
- {
- DBGL(DL_DRVR, (log(LL_DBG, "sendm_alert_req: sent ALERT_REQ")));
- }
- return(ret);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/pathnames.h b/usr.sbin/i4b/isdnd/pathnames.h
deleted file mode 100644
index 75afec945463..000000000000
--- a/usr.sbin/i4b/isdnd/pathnames.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - location of files
- * ------------------------------
- *
- * $Id: pathnames.h,v 1.5 1998/12/05 18:03:30 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:11:17 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _PATHNAMES_H_
-#define _PATHNAMES_H_
-
-#define I4BDEVICE "/dev/i4b"
-
-#define ETCPATH "/etc/isdn"
-#define CONFIG_FILE_DEF "/etc/isdn/isdnd.rc"
-#define RATES_FILE_DEF "/etc/isdn/isdnd.rates"
-
-#define LIBDIR "/usr/local/lib/isdn"
-
-#define LOG_FILE_DEF "/var/log/isdnd.log"
-#define ACCT_FILE_DEF "/var/log/isdnd.acct"
-
-#define PIDFILE "/var/run/isdnd.pid"
-
-#endif /* _PATHNAMES_H_ */
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/pcause.c b/usr.sbin/i4b/isdnd/pcause.c
deleted file mode 100644
index c782f2c7181b..000000000000
--- a/usr.sbin/i4b/isdnd/pcause.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * printing cause values
- * ---------------------
- *
- * $Id: pcause.c,v 1.9 1998/12/05 18:03:31 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:11:31 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-static char *cause_i4b_tab[CAUSE_I4B_MAX+1];
-static char *cause_q850_tab[CAUSE_Q850_MAX];
-
-char *
-print_i4b_cause(cause_t code)
-{
- static char error_message[128];
-
- sprintf(error_message, "%d: ", GET_CAUSE_VAL(code));
-
- switch(GET_CAUSE_TYPE(code))
- {
- case CAUSET_Q850:
- strcat(error_message, cause_q850_tab[GET_CAUSE_VAL(code)]);
- strcat(error_message, " (Q.850)");
- break;
-
- case CAUSET_I4B:
- if((GET_CAUSE_VAL(code) < CAUSE_I4B_NORMAL) ||
- (GET_CAUSE_VAL(code) >= CAUSE_I4B_MAX))
- {
- SET_CAUSE_VAL(code, CAUSE_I4B_MAX);
- }
- strcat(error_message, cause_i4b_tab[GET_CAUSE_VAL(code)]);
- strcat(error_message, " (I4B)");
- break;
-
- default:
- strcat(error_message, "ERROR: unknown cause type!");
- break;
- }
- return(error_message);
-}
-
-static char *cause_i4b_tab[CAUSE_I4B_MAX+1] = {
- "normal call clearing",
- "user busy",
- "channel not available",
- "incompatible source or destination",
- "call rejected",
- "destination out of order",
- "temporary failure",
- "layer 1 error / persistent deactivation",
- "ERROR, invalid I4B cause value!"
-};
-
-static char *cause_q850_tab[CAUSE_Q850_MAX] = {
- "Normal D-channel shutdown",
- "Unallocated (unassigned) number",
- "No route to specified transit network (national use)",
- "No route to destination",
- "Send special information tone",
- "Misdialled trunk prefix (national use)",
- "Channel unacceptable",
- "Call awarded and being delivered in an established channel",
- "Preemption",
- "Preemption - circuit reserved for reuse",
-
-/*10*/ "cause code 10: error, unassigned in Q.850 (03/93)",
- "cause code 11: error, unassigned in Q.850 (03/93)",
- "cause code 12: error, unassigned in Q.850 (03/93)",
- "cause code 13: error, unassigned in Q.850 (03/93)",
- "cause code 14: error, unassigned in Q.850 (03/93)",
- "cause code 15: error, unassigned in Q.850 (03/93)",
- "Normal call clearing",
- "User busy",
- "No user responding",
- "No answer from user (user alerted)",
-
-/*20*/ "Subscriber absent",
- "Call rejected",
- "Number changed",
- "cause code 23: error, unassigned in Q.850 (03/93)",
- "cause code 24: error, unassigned in Q.850 (03/93)",
- "cause code 25: error, unassigned in Q.850 (03/93)",
- "Non-selected user clearing",
- "Destination out of order",
- "Invalid number format",
- "Facility rejected",
-
-/*30*/ "Response to STATUS ENQUIRY",
- "Normal, unspecified",
- "cause code 32: error, unassigned in Q.850 (03/93)",
- "cause code 33: error, unassigned in Q.850 (03/93)",
- "No circuit / channel available",
- "cause code 35: error, unassigned in Q.850 (03/93)",
- "cause code 36: error, unassigned in Q.850 (03/93)",
- "cause code 37: error, unassigned in Q.850 (03/93)",
- "Network out of order",
- "Permanent frame mode connection out of service",
-
-/*40*/ "Permanent frame mode connection operational",
- "Temporary failure",
- "Switching equipment congestion",
- "Access information discarded",
- "Requested circuit/channel not available",
- "cause code 45: error, unassigned in Q.850 (03/93)",
- "Precedence call blocked",
- "Resources unavailable, unspecified",
- "cause code 48: error, unassigned in Q.850 (03/93)",
- "Quality of service unavailable",
-
-/*50*/ "Requested facility not subscribed",
- "cause code 51: error, unassigned in Q.850 (03/93)",
- "cause code 52: error, unassigned in Q.850 (03/93)",
- "Outgoing calls barred within CUG",
- "cause code 54: error, unassigned in Q.850 (03/93)",
- "Incoming calls barred within CUG",
- "cause code 56: error, unassigned in Q.850 (03/93)",
- "Bearer capability not authorized",
- "Bearer capability not presently available",
- "cause code 59: error, unassigned in Q.850 (03/93)",
-
-/*60*/ "cause code 60: error, unassigned in Q.850 (03/93)",
- "cause code 61: error, unassigned in Q.850 (03/93)",
- "Inconsistenciy in designated outg. access info and subscriber class",
- "Service or option not available, unspecified",
- "cause code 64: error, unassigned in Q.850 (03/93)",
- "Bearer capability not implemented",
- "Channel type not implemented",
- "cause code 67: error, unassigned in Q.850 (03/93)",
- "cause code 68: error, unassigned in Q.850 (03/93)",
- "Requested facility not implemented",
-
-/*70*/ "Only restricted digital information bearer capability is available",
- "cause code 71: error, unassigned in Q.850 (03/93)",
- "cause code 72: error, unassigned in Q.850 (03/93)",
- "cause code 73: error, unassigned in Q.850 (03/93)",
- "cause code 74: error, unassigned in Q.850 (03/93)",
- "cause code 75: error, unassigned in Q.850 (03/93)",
- "cause code 76: error, unassigned in Q.850 (03/93)",
- "cause code 77: error, unassigned in Q.850 (03/93)",
- "cause code 78: error, unassigned in Q.850 (03/93)",
- "Service or option not implemented, unspecified",
-
-/*80*/ "cause code 80: error, unassigned in Q.850 (03/93)",
- "Invalid call reference value",
- "Identified channel does not exist",
- "A suspended call exists, but this call identity does not",
- "Call identity in use",
- "No call suspended",
- "Call having the requested call identity has been cleared",
- "User not member of CUG",
- "Incompatible destination",
- "cause code 89: error, unassigned in Q.850 (03/93)",
-
-/*90*/ "Non-existent CUG",
- "Invalid transit network selection",
- "cause code 92: error, unassigned in Q.850 (03/93)",
- "cause code 93: error, unassigned in Q.850 (03/93)",
- "cause code 94: error, unassigned in Q.850 (03/93)",
- "Invalid message, unspecified",
- "Mandatory information element is missing",
- "Message type non-existent or not implemented",
- "Message not compatible with call state or message type non-existent or not implemented",
- "Information element/parameter non-existent or not implemented",
-
-/*100*/ "Invalid information element contents",
- "Message not compatible with call state",
- "Recovery on timer expiry",
- "Parameter non-existent or not implemented, passed on",
- "cause code 104: error, unassigned in Q.850 (03/93)",
- "cause code 105: error, unassigned in Q.850 (03/93)",
- "cause code 106: error, unassigned in Q.850 (03/93)",
- "cause code 107: error, unassigned in Q.850 (03/93)",
- "cause code 108: error, unassigned in Q.850 (03/93)",
- "cause code 109: error, unassigned in Q.850 (03/93)",
-
-/*110*/ "Message with unrecognized parameter, discarded",
- "Protocol error, unspecified",
- "cause code 112: error, unassigned in Q.850 (03/93)",
- "cause code 113: error, unassigned in Q.850 (03/93)",
- "cause code 114: error, unassigned in Q.850 (03/93)",
- "cause code 115: error, unassigned in Q.850 (03/93)",
- "cause code 116: error, unassigned in Q.850 (03/93)",
- "cause code 117: error, unassigned in Q.850 (03/93)",
- "cause code 118: error, unassigned in Q.850 (03/93)",
- "cause code 119: error, unassigned in Q.850 (03/93)",
-
-/*120*/ "cause code 120: error, unassigned in Q.850 (03/93)",
- "cause code 121: error, unassigned in Q.850 (03/93)",
- "cause code 122: error, unassigned in Q.850 (03/93)",
- "cause code 123: error, unassigned in Q.850 (03/93)",
- "cause code 124: error, unassigned in Q.850 (03/93)",
- "cause code 125: error, unassigned in Q.850 (03/93)",
- "cause code 126: error, unassigned in Q.850 (03/93)",
- "Interworking, unspecified"
-};
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/process.c b/usr.sbin/i4b/isdnd/process.c
deleted file mode 100644
index 47c9eda550a1..000000000000
--- a/usr.sbin/i4b/isdnd/process.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - process handling routines
- * --------------------------------------
- *
- * $Id: process.c,v 1.6 1998/12/05 18:03:33 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:11:42 1998]
- *
- * -hm debugging processhandling
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-/*---------------------------------------------------------------------------*
- * check if another instance of us is already running
- *---------------------------------------------------------------------------*/
-void
-check_pid(void)
-{
- FILE *fp;
-
- /* check if another lock-file already exists */
-
- if((fp = fopen(PIDFILE, "r")) != NULL)
- {
- /* lockfile found, check */
-
- int oldpid;
-
- /* read pid from file */
-
- if((fscanf(fp, "%d", &oldpid)) != 1)
- {
- log(LL_ERR, "ERROR, reading pid from lockfile failed, terminating!");
- exit(1);
- }
-
- /* check if process got from file is still alive */
-
- if((kill(oldpid, 0)) != 0)
- {
- /* process does not exist */
-
- /* close file */
-
- fclose(fp);
-
- DBGL(DL_PROC, (log(LL_DBG, "removing old lock-file %s", PIDFILE)));
-
- /* remove file */
-
- unlink(PIDFILE);
- }
- else
- {
- /* process is still alive */
-
- log(LL_ERR, "ERROR, another daemon is already running, pid = %d, terminating!", oldpid);
- exit(1);
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * establish and init process lock file
- *---------------------------------------------------------------------------*/
-void
-write_pid(void)
-{
- FILE *fp;
-
- /* write my pid into lock-file */
-
- if((fp = fopen(PIDFILE, "w")) == NULL)
- {
- log(LL_ERR, "ERROR, can't open lockfile for writing, terminating");
- do_exit(1);
- }
-
- if((fprintf(fp, "%d", (int)getpid())) == EOF)
- {
- log(LL_ERR, "ERROR, can't write pid to lockfile, terminating");
- do_exit(1);
- }
-
- fsync(fileno(fp));
-
- fclose(fp);
-}
-
-/*---------------------------------------------------------------------------*
- * become a daemon
- *---------------------------------------------------------------------------*/
-void
-daemonize(void)
-{
- int fd;
-
- switch (fork())
- {
- case -1: /* error */
- log(LL_ERR, "ERROR, daemonize/fork: %s", strerror(errno));
- exit(1);
- case 0: /* child */
- break;
- default: /* parent */
- exit(0);
- }
-
- /* new session / no control tty */
-
- if(setsid() == -1)
- {
- log(LL_ERR, "ERROR, setsid returns: %s", strerror(errno));
- exit(1);
- }
-
- /* go away from mounted dir */
-
- chdir("/");
-
- /* move i/o to another device ? */
-
- if(do_fullscreen && do_rdev)
- {
- char *tp;
-
- if((fd = open(rdev, O_RDWR, 0)) != -1)
- {
- if(!isatty(fd))
- {
- log(LL_ERR, "ERROR, device %s is not a tty!", rdev);
- exit(1);
- }
- if((dup2(fd, STDIN_FILENO)) == -1)
- {
- log(LL_ERR, "ERROR, dup2 stdin: %s", strerror(errno));
- exit(1);
- }
- if((dup2(fd, STDOUT_FILENO)) == -1)
- {
- log(LL_ERR, "ERROR, dup2 stdout: %s", strerror(errno));
- exit(1);
- }
- if((dup2(fd, STDERR_FILENO)) == -1)
- {
- log(LL_ERR, "ERROR, dup2 stderr: %s", strerror(errno));
- exit(1);
- }
- }
- else
- {
- log(LL_ERR, "ERROR, cannot open redirected device: %s", strerror(errno));
- exit(1);
- }
-
- if(fd > 2)
- {
- if((close(fd)) == -1)
- {
- log(LL_ERR, "ERROR, close in daemonize: %s", strerror(errno));
- exit(1);
- }
- }
-
- /* curses output && fork NEEDS controlling tty */
-
- if((ioctl(STDIN_FILENO, TIOCSCTTY, (char *)NULL)) < 0)
- {
- log(LL_ERR, "ERROR, cannot setup tty as controlling terminal: %s", strerror(errno));
- exit(1);
- }
-
- /* in case there is no environment ... */
-
- if(((tp = getenv("TERM")) == NULL) || (*tp == '\0'))
- {
- if(do_ttytype == 0)
- {
- log(LL_ERR, "ERROR, no environment variable TERM found and -t not specified!");
- exit(1);
- }
-
- if((setenv("TERM", ttype, 1)) != 0)
- {
- log(LL_ERR, "ERROR, setenv TERM=%s failed: %s", ttype, strerror(errno));
- exit(1);
- }
- }
- }
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/rates.c b/usr.sbin/i4b/isdnd/rates.c
deleted file mode 100644
index c1b11636a5c7..000000000000
--- a/usr.sbin/i4b/isdnd/rates.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * Copyright (c) 1997 Gary Jennejohn. All rights reserved.
- *
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * 4. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software and/or documentation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - charging rates description file handling
- * -----------------------------------------------------
- *
- * $Id: rates.c,v 1.7 1998/12/05 18:03:34 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:11:55 1998]
- *
- *---------------------------------------------------------------------------*/
-
-static char error[256];
-
-#ifdef PARSE_DEBUG_MAIN
-
-#include <stdio.h>
-
-#define MAIN
-
-#define ERROR (-1)
-
-int main()
-{
- int ret;
- ret = readrates("/etc/isdn/isdnd.rates");
- if(ret == ERROR)
- fprintf(stderr, "readrates returns [%d], [%s]\n", ret, error);
- else
- fprintf(stderr, "readrates returns [%d]\n", ret);
- return(ret);
-}
-
-#endif
-
-#include "isdnd.h"
-
-static int getrate(cfg_entry_t *cep);
-
-/*---------------------------------------------------------------------------*
- * parse rates file
- *---------------------------------------------------------------------------*/
-int
-readrates(char *filename)
-{
- char buffer[1024];
- register char *bp;
- struct rates *rt, *ort;
- int rateindx;
- int indx;
- int line = 0;
- FILE *fp;
- int first;
-#if DEBUG
- int i, j;
-#endif
-
- indx = 0;
- rt = ort = NULL;
-
- if((fp = fopen(filename, "r")) == NULL)
- {
- sprintf(error, "error open %s: %s", filename, sys_errlist[errno]);
- rate_error = error;
- return(WARNING);
- }
-
- while((fgets(buffer, MAXPATHLEN, fp)) != NULL)
- {
- line++;
-
-/* comments */
- if(buffer[0] == '#' || buffer[0] == ' ' ||
- buffer[0] == '\t' || buffer[0] == '\n')
- {
- continue;
- }
-
- bp = &buffer[0];
-
- /* rate type */
-
- if (*bp == 'r' && *(bp+1) == 'a' && isdigit(*(bp+2)))
- {
- rateindx = *(bp+2) - '0';
- bp += 3;
-
- /* eat space delimiter */
-
- while(isspace(*bp))
- bp++;
- }
- else
- {
- sprintf(error, "rates: invalid rate type %c%c%c in line %d", *bp, *(bp+1), *(bp+2), line);
- goto rate_error;
- }
- if (rateindx >= NRATES)
- {
- sprintf(error, "rates: invalid rate index %d in line %d", rateindx, line);
- goto rate_error;
- }
-
- /* day */
-
- if(isdigit(*bp) && *bp >= '0' && *bp <= '6')
- {
- indx = *bp - '0';
-
- DBGL(DL_RATES, (log(LL_DBG, "rates: index = %d", indx)));
- }
- else
- {
- sprintf(error, "rates: invalid day digit %c in line %d", *bp, line);
- goto rate_error;
- }
-
- if(rates[rateindx][indx] == NULL)
- {
- rt = (struct rates *)malloc(sizeof (struct rates));
- if (rt == NULL)
- {
- sprintf(error, "rates: cannot malloc space for rate structure");
- goto rate_error;
- }
- rt->next = NULL;
- rates[rateindx][indx] = rt;
- }
-
- bp++;
-
- /* eat space delimiter */
-
- while(isspace(*bp))
- bp++;
-
- /* now loop to get the rates entries */
-
- first = 1;
-
- while(*bp && isdigit(*bp))
- {
- if(first)
- {
- first = 0;
- }
- else
- {
- ort = rt;
-
- rt = (struct rates *)malloc(sizeof (struct rates));
- if (rt == NULL)
- {
- sprintf(error, "rates: cannot malloc space2 for rate structure");
- goto rate_error;
- }
- ort->next = rt;
- rt->next = NULL;
- }
-
- /* start hour */
-
- if(isdigit(*bp) && isdigit(*(bp+1)))
- {
- rt->start_hr = atoi(bp);
- bp += 2;
- }
- else
- {
- sprintf(error, "rates: start_hr error in line %d", line);
- goto rate_error;
- }
-
- /* point */
-
- if(*bp == '.')
- {
- bp++;
- }
- else
- {
- sprintf(error, "rates: no '.' after start_hr in line %d", line);
- goto rate_error;
- }
-
- /* start minute */
-
- if(isdigit(*bp) && isdigit(*(bp+1)))
- {
- rt->start_min = atoi(bp);
- bp += 2;
- }
- else
- {
- sprintf(error, "rates: start_min error in line %d", line);
- goto rate_error;
- }
-
- /* minus */
-
- if(*bp == '-')
- {
- bp++;
- }
- else
- {
- sprintf(error, "rates: no '-' after start_min in line %d", line);
- goto rate_error;
- }
-
- /* end hour */
-
- if(isdigit(*bp) && isdigit(*(bp+1)))
- {
- rt->end_hr = atoi(bp);
- bp += 2;
- }
- else
- {
- sprintf(error, "rates: end_hr error in line %d", line);
- goto rate_error;
- }
-
- /* point */
-
- if(*bp == '.')
- {
- bp++;
- }
- else
- {
- sprintf(error, "rates: no '.' after end_hr in line %d", line);
- goto rate_error;
- }
-
- /* end minute */
-
- if(isdigit(*bp) && isdigit(*(bp+1)))
- {
- rt->end_min = atoi(bp);
- bp += 2;
- }
- else
- {
- sprintf(error, "rates: end_min error in line %d", line);
- goto rate_error;
- }
-
- /* colon */
-
- if(*bp == ':')
- {
- bp++;
- }
- else
- {
- sprintf(error, "rates: no ':' after end_min in line %d", line);
- goto rate_error;
- }
-
- /* time */
-
- if(isdigit(*bp))
- {
- rt->rate = atoi(bp);
- while(!isspace(*bp))
- bp++;
- }
- else
- {
- sprintf(error, "rates: first rate digit error in line %d", line);
- goto rate_error;
- }
-
- /* eat space delimiter */
-
- while(isspace(*bp))
- bp++;
- }
- }
-
-#if DEBUG
- if(debug_flags & DL_RATES)
- {
- for (j = 0; j < NRATES; j++)
- {
- for (i = 0; i < NDAYS; i++)
- {
- if (rates [j][i] != NULL)
- {
- rt = rates [j][i];
- for (; rt; rt = rt->next)
- {
- log(LL_DBG, "rates: index %d day %d = %d.%d-%d.%d:%d",
- j, i, rt->start_hr, rt->start_min,
- rt->end_hr,rt->end_min,rt->rate);
- }
- }
- else
- {
- log(LL_DBG, "rates: NO entry for day %d !!\n", i);
- }
- }
- }
- }
-#endif
- fclose(fp);
- return(GOOD);
-
-rate_error:
- fclose(fp);
- rate_error = error;
- return(ERROR);
-}
-
-#ifndef PARSE_DEBUG_MAIN
-
-/*---------------------------------------------------------------------------*
- * get unit length time from configured source
- *---------------------------------------------------------------------------*/
-int
-get_current_rate(cfg_entry_t *cep, int logit)
-{
- int rt;
-
- switch(cep->unitlengthsrc)
- {
- case ULSRC_CMDL: /* specified on commandline */
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (cmdl)",
- cep->cdid, cep->name, unit_length);
- return(unit_length);
- break;
-
- case ULSRC_CONF: /* get it from config file */
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (conf)",
- cep->cdid, cep->name, cep->unitlength);
- return(cep->unitlength);
-
- case ULSRC_RATE: /* get it dynamic from ratesfile*/
- if(!got_rate) /* got valid rates struct ?? */
- {
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (no ratefile)",
- cep->cdid, cep->name, UNITLENGTH_DEFAULT);
- return(UNITLENGTH_DEFAULT);
- }
- if((cep->ratetype >= NRATES) ||
- (cep->ratetype == INVALID_RATE))
- {
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (rate out of range)",
- cep->cdid, cep->name, UNITLENGTH_DEFAULT);
- return(UNITLENGTH_DEFAULT);
- }
-
- if((rt = getrate(cep)) != -1)
- {
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (rate)",
- cep->cdid, cep->name, rt);
- return(rt);
- }
-
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (ratescan fail)",
- cep->cdid, cep->name, UNITLENGTH_DEFAULT);
-
- return(UNITLENGTH_DEFAULT);
- break;
-
- case ULSRC_DYN: /* dynamically calculated from AOC */
- if((rt = getrate(cep)) != -1)
- {
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (aocd, rate)",
- cep->cdid, cep->name, rt);
- return(rt);
- }
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (aocd, default)",
- cep->cdid, cep->name, UNITLENGTH_DEFAULT);
-
- return(UNITLENGTH_DEFAULT);
- break;
-
- default:
- if(logit)
- log(LL_CHD, "%05d %s rate %d sec/unit (unitlen unknown)",
- cep->cdid, cep->name, UNITLENGTH_DEFAULT);
-
- return(UNITLENGTH_DEFAULT);
- break;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * get the currently active rate
- *---------------------------------------------------------------------------*/
-static int
-getrate(cfg_entry_t *cep)
-{
- struct tm *ptr;
- time_t now;
- register struct rates *hd;
-
- if((!got_rate) ||
- (cep->ratetype >= NRATES) ||
- (cep->ratetype == INVALID_RATE))
- {
- return(-1);
- }
-
- time(&now); /* get current time */
-
- ptr = localtime(&now);
-
- /* walk thru the rates for weekday until rate for current time found */
-
- for (hd = rates[cep->ratetype][ptr->tm_wday]; hd; hd = hd->next)
- {
- /* current time within window ? */
- if((hd->start_hr <= ptr->tm_hour) &&
- (hd->end_hr > ptr->tm_hour))
- {
- DBGL(DL_RATES, (log(LL_DBG, "rate=%d sec/unit (day=%d, beg=%d, end=%d, current=%d)",
- hd->rate,
- ptr->tm_wday,
- hd->start_hr,
- hd->end_hr,
- ptr->tm_hour)));
-
- return (hd->rate);
- }
- }
- return(-1);
-}
-
-#endif /* PARSE_DEBUG_MAIN */
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/rc_config.c b/usr.sbin/i4b/isdnd/rc_config.c
deleted file mode 100644
index 884edfa10fe2..000000000000
--- a/usr.sbin/i4b/isdnd/rc_config.c
+++ /dev/null
@@ -1,1140 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - config file processing
- * -----------------------------------
- *
- * $Id: rc_config.c,v 1.35 1998/12/16 13:39:47 hm Exp $
- *
- * last edit-date: [Mon Dec 14 13:41:41 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "isdnd.h"
-#include "y.tab.h"
-
-#include "monitor.h"
-#include "vararray.h"
-
-extern int entrycount;
-extern int lineno;
-extern char *yytext;
-
-extern FILE *yyin;
-extern int yyparse();
-
-static void set_config_defaults(void);
-static void check_config(void);
-static void print_config(void);
-
-static int nregexpr = 0;
-static int nregprog = 0;
-
-/*---------------------------------------------------------------------------*
- * called from main to read and process config file
- *---------------------------------------------------------------------------*/
-void
-configure(char *filename, int reread)
-{
- extern void reset_scanner(FILE *inputfile);
-
- set_config_defaults();
-
- yyin = fopen(filename, "r");
-
- if(reread)
- {
- reset_scanner(yyin);
- }
-
- if (yyin == NULL)
- {
- log(LL_ERR, "cannot fopen file [%s]", filename);
- exit(1);
- }
-
- yyparse();
-
- monitor_fixup_rights();
-
- check_config(); /* validation and consistency check */
-
- fclose(yyin);
-
- if(do_print)
- {
- if(config_error_flag)
- {
- log(LL_ERR, "there were %d error(s) in the configuration file, terminating!", config_error_flag);
- exit(1);
- }
- print_config();
- do_exit(0);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * yacc error routine
- *---------------------------------------------------------------------------*/
-void
-yyerror(const char *msg)
-{
- log(LL_ERR, "configuration error: %s at line %d, token \"%s\"", msg, lineno+1, yytext);
- config_error_flag++;
-}
-
-/*---------------------------------------------------------------------------*
- * fill all config entries with default values
- *---------------------------------------------------------------------------*/
-static void
-set_config_defaults(void)
-{
- cfg_entry_t *cep = &cfg_entry_tab[0]; /* ptr to config entry */
- int i;
-
- /* system section cleanup */
-
- nregprog = nregexpr = 0;
-
- rt_prio = RTPRIO_NOTUSED;
-
- /* clean regular expression table */
-
- for(i=0; i < MAX_RE; i++)
- {
- if(rarr[i].re_expr)
- free(rarr[i].re_expr);
- rarr[i].re_expr = NULL;
-
- if(rarr[i].re_prog)
- free(rarr[i].re_prog);
- rarr[i].re_prog = NULL;
-
- rarr[i].re_flg = 0;
- }
-
- /* entry section cleanup */
-
- for(i=0; i < CFG_ENTRY_MAX; i++, cep++)
- {
- bzero(cep, sizeof(cfg_entry_t));
-
- /* ====== filled in at startup configuration, then static */
-
- sprintf(cep->name, "ENTRY%d", i);
-
- cep->isdncontroller = INVALID;
- cep->isdnchannel = CHAN_ANY;
-
- cep->usrdevicename = INVALID;
- cep->usrdeviceunit = INVALID;
-
- cep->remote_numbers_handling = RNH_LAST;
-
- cep->dialin_reaction = REACT_IGNORE;
-
- cep->b1protocol = BPROT_NONE;
-
- cep->unitlength = UNITLENGTH_DEFAULT;
-
- cep->earlyhangup = EARLYHANGUP_DEFAULT;
-
- cep->ratetype = INVALID_RATE;
-
- cep->unitlengthsrc = ULSRC_NONE;
-
- cep->answerprog = ANSWERPROG_DEF;
-
- cep->callbackwait = CALLBACKWAIT_MIN;
-
- cep->calledbackwait = CALLEDBACKWAIT_MIN;
-
- cep->dialretries = DIALRETRIES_DEF;
-
- cep->recoverytime = RECOVERYTIME_MIN;
-
- cep->dialouttype = DIALOUT_NORMAL;
-
- cep->inout = DIR_INOUT;
-
- /* ======== filled in after start, then dynamic */
-
- cep->cdid = CDID_UNUSED;
-
- cep->state = ST_IDLE;
-
- cep->aoc_valid = AOC_INVALID;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * extract values from config and fill table
- *---------------------------------------------------------------------------*/
-void
-cfg_setval(int keyword)
-{
- int i;
-
- switch(keyword)
- {
- case ACCTALL:
- acct_all = yylval.booln;
- log(LL_DBG, "system: acctall = %d", yylval.booln);
- break;
-
- case ACCTFILE:
- strcpy(acctfile, yylval.str);
- log(LL_DBG, "system: acctfile = %s", yylval.str);
- break;
-
- case ALERT:
- if(yylval.num < MINALERT)
- {
- yylval.num = MINALERT;
- log(LL_DBG, "entry %d: alert < %d, min = %d", entrycount, MINALERT, yylval.num);
- }
- else if(yylval.num > MAXALERT)
- {
- yylval.num = MAXALERT;
- log(LL_DBG, "entry %d: alert > %d, min = %d", entrycount, MAXALERT, yylval.num);
- }
-
- log(LL_DBG, "entry %d: alert = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].alert = yylval.num;
- break;
-
- case ALIASING:
- log(LL_DBG, "system: aliasing = %d", yylval.booln);
- aliasing = yylval.booln;
- break;
-
- case ALIASFNAME:
- strcpy(aliasfile, yylval.str);
- log(LL_DBG, "system: aliasfile = %s", yylval.str);
- break;
-
- case ANSWERPROG:
- if((cfg_entry_tab[entrycount].answerprog = malloc(strlen(yylval.str)+1)) == NULL)
- {
- log(LL_ERR, "entry %d: answerstring, malloc failed!", entrycount);
- do_exit(1);
- }
- strcpy(cfg_entry_tab[entrycount].answerprog, yylval.str);
- log(LL_DBG, "entry %d: answerprog = %s", entrycount, yylval.str);
- break;
-
- case B1PROTOCOL:
- log(LL_DBG, "entry %d: b1protocol = %s", entrycount, yylval.str);
- if(!(strcmp(yylval.str, "raw")))
- cfg_entry_tab[entrycount].b1protocol = BPROT_NONE;
- else if(!(strcmp(yylval.str, "hdlc")))
- cfg_entry_tab[entrycount].b1protocol = BPROT_RHDLC;
- else
- {
- log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"b1protocol\" at line %d!", lineno);
- config_error_flag++;
- }
- break;
-
- case CALLBACKWAIT:
- if(yylval.num < CALLBACKWAIT_MIN)
- {
- yylval.num = CALLBACKWAIT_MIN;
- log(LL_DBG, "entry %d: callbackwait < %d, min = %d", entrycount, CALLBACKWAIT_MIN, yylval.num);
- }
-
- log(LL_DBG, "entry %d: callbackwait = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].callbackwait = yylval.num;
- break;
-
- case CALLEDBACKWAIT:
- if(yylval.num < CALLEDBACKWAIT_MIN)
- {
- yylval.num = CALLEDBACKWAIT_MIN;
- log(LL_DBG, "entry %d: calledbackwait < %d, min = %d", entrycount, CALLEDBACKWAIT_MIN, yylval.num);
- }
-
- log(LL_DBG, "entry %d: calledbackwait = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].calledbackwait = yylval.num;
- break;
-
- case CONNECTPROG:
- if((cfg_entry_tab[entrycount].connectprog = malloc(strlen(yylval.str)+1)) == NULL)
- {
- log(LL_ERR, "entry %d: connectprog, malloc failed!", entrycount);
- do_exit(1);
- }
- strcpy(cfg_entry_tab[entrycount].connectprog, yylval.str);
- log(LL_DBG, "entry %d: connectprog = %s", entrycount, yylval.str);
- break;
-
- case DIALOUTTYPE:
- log(LL_DBG, "entry %d: dialouttype = %s", entrycount, yylval.str);
- if(!(strcmp(yylval.str, "normal")))
- cfg_entry_tab[entrycount].dialouttype = DIALOUT_NORMAL;
- else if(!(strcmp(yylval.str, "calledback")))
- cfg_entry_tab[entrycount].dialouttype = DIALOUT_CALLEDBACK;
- else
- {
- log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"dialout-type\" at line %d!", lineno);
- config_error_flag++;
- }
- break;
-
- case DIALRETRIES:
- log(LL_DBG, "entry %d: dialretries = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].dialretries = yylval.num;
- break;
-
- case DIALRANDINCR:
- log(LL_DBG, "entry %d: dialrandincr = %d", entrycount, yylval.booln);
- cfg_entry_tab[entrycount].dialrandincr = yylval.booln;
- break;
-
- case DIRECTION:
- log(LL_DBG, "entry %d: direction = %s", entrycount, yylval.str);
-
- if(!(strcmp(yylval.str, "inout")))
- cfg_entry_tab[entrycount].inout = DIR_INOUT;
- else if(!(strcmp(yylval.str, "in")))
- cfg_entry_tab[entrycount].inout = DIR_INONLY;
- else if(!(strcmp(yylval.str, "out")))
- cfg_entry_tab[entrycount].inout = DIR_OUTONLY;
- else
- {
- log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"direction\" at line %d!", lineno);
- config_error_flag++;
- }
- break;
-
- case DISCONNECTPROG:
- if((cfg_entry_tab[entrycount].disconnectprog = malloc(strlen(yylval.str)+1)) == NULL)
- {
- log(LL_ERR, "entry %d: disconnectprog, malloc failed!", entrycount);
- do_exit(1);
- }
- strcpy(cfg_entry_tab[entrycount].disconnectprog, yylval.str);
- log(LL_DBG, "entry %d: disconnectprog = %s", entrycount, yylval.str);
- break;
-
- case DOWNTRIES:
- if(yylval.num > DOWN_TRIES_MAX)
- yylval.num = DOWN_TRIES_MAX;
- else if(yylval.num < DOWN_TRIES_MIN)
- yylval.num = DOWN_TRIES_MIN;
-
- log(LL_DBG, "entry %d: downtries = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].downtries = yylval.num;
- break;
-
- case DOWNTIME:
- if(yylval.num > DOWN_TIME_MAX)
- yylval.num = DOWN_TIME_MAX;
- else if(yylval.num < DOWN_TIME_MIN)
- yylval.num = DOWN_TIME_MIN;
-
- log(LL_DBG, "entry %d: downtime = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].downtime = yylval.num;
- break;
-
- case EARLYHANGUP:
- log(LL_DBG, "entry %d: earlyhangup = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].earlyhangup = yylval.num;
- break;
-
- case IDLETIME_IN:
- log(LL_DBG, "entry %d: idle_time_in = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].idle_time_in = yylval.num;
- break;
-
- case IDLETIME_OUT:
- log(LL_DBG, "entry %d: idle_time_out = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].idle_time_out = yylval.num;
- break;
-
- case ISDNCONTROLLER:
- cfg_entry_tab[entrycount].isdncontroller = yylval.num;
- log(LL_DBG, "entry %d: isdncontroller = %d", entrycount, yylval.num);
- break;
-
- case ISDNCHANNEL:
- switch(yylval.num)
- {
- case 0:
- case -1:
- cfg_entry_tab[entrycount].isdnchannel = CHAN_ANY;
- log(LL_DBG, "entry %d: isdnchannel = any", entrycount);
- break;
- case 1:
- cfg_entry_tab[entrycount].isdnchannel = CHAN_B1;
- log(LL_DBG, "entry %d: isdnchannel = one", entrycount);
- break;
- case 2:
- cfg_entry_tab[entrycount].isdnchannel = CHAN_B2;
- log(LL_DBG, "entry %d: isdnchannel = two", entrycount);
- break;
- default:
- log(LL_DBG, "entry %d: isdnchannel value out of range", entrycount);
- config_error_flag++;
- break;
- }
- break;
-
- case ISDNTIME:
- log(LL_DBG, "system: isdntime = %d", yylval.booln);
- isdntime = yylval.booln;
- break;
-
- case ISDNTXDELIN:
- cfg_entry_tab[entrycount].isdntxdelin = yylval.num;
- log(LL_DBG, "entry %d: isdntxdel-incoming = %d", entrycount, yylval.num);
- break;
-
- case ISDNTXDELOUT:
- cfg_entry_tab[entrycount].isdntxdelout = yylval.num;
- log(LL_DBG, "entry %d: isdntxdel-outgoing = %d", entrycount, yylval.num);
- break;
-
- case LOCAL_PHONE_DIALOUT:
- log(LL_DBG, "entry %d: local_phone_dialout = %s", entrycount, yylval.str);
- strcpy(cfg_entry_tab[entrycount].local_phone_dialout, yylval.str);
- break;
-
- case LOCAL_PHONE_INCOMING:
- log(LL_DBG, "entry %d: local_phone_incoming = %s", entrycount, yylval.str);
- strcpy(cfg_entry_tab[entrycount].local_phone_incoming, yylval.str);
- break;
-
- case MONITORPORT:
- monitorport = yylval.num;
- log(LL_DBG, "system: monitorport = %d", yylval.num);
- break;
-
- case MONITORSW:
- if (yylval.booln && inhibit_monitor) {
- do_monitor = 0;
- log(LL_DBG, "system: monitor-enable overriden by command line flag");
- } else {
- do_monitor = yylval.booln;
- log(LL_DBG, "system: monitor-enable = %d", yylval.booln);
- }
- break;
-
- case NAME:
- log(LL_DBG, "entry %d: name = %s", entrycount, yylval.str);
- strcpy(cfg_entry_tab[entrycount].name, yylval.str);
- break;
-
- case REACTION:
- log(LL_DBG, "entry %d: dialin_reaction = %s", entrycount, yylval.str);
- if(!(strcmp(yylval.str, "accept")))
- cfg_entry_tab[entrycount].dialin_reaction = REACT_ACCEPT;
- else if(!(strcmp(yylval.str, "reject")))
- cfg_entry_tab[entrycount].dialin_reaction = REACT_REJECT;
- else if(!(strcmp(yylval.str, "ignore")))
- cfg_entry_tab[entrycount].dialin_reaction = REACT_IGNORE;
- else if(!(strcmp(yylval.str, "answer")))
- cfg_entry_tab[entrycount].dialin_reaction = REACT_ANSWER;
- else if(!(strcmp(yylval.str, "callback")))
- cfg_entry_tab[entrycount].dialin_reaction = REACT_CALLBACK;
- else
- {
- log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"dialin_reaction\" at line %d!", lineno);
- config_error_flag++;
- }
- break;
-
- case REMOTE_PHONE_DIALOUT:
- if(cfg_entry_tab[entrycount].remote_numbers_count >= MAXRNUMBERS)
- {
- log(LL_ERR, "ERROR parsing config file: too many remote numbers at line %d!", lineno);
- config_error_flag++;
- break;
- }
-
- log(LL_DBG, "entry %d: remote_phone_dialout #%d = %s",
- entrycount, cfg_entry_tab[entrycount].remote_numbers_count, yylval.str);
-
- strcpy(cfg_entry_tab[entrycount].remote_numbers[cfg_entry_tab[entrycount].remote_numbers_count].number, yylval.str);
- cfg_entry_tab[entrycount].remote_numbers[cfg_entry_tab[entrycount].remote_numbers_count].flag = 0;
-
- cfg_entry_tab[entrycount].remote_numbers_count++;
-
- break;
-
- case REMOTE_NUMBERS_HANDLING:
- log(LL_DBG, "entry %d: remdial_handling = %s", entrycount, yylval.str);
- if(!(strcmp(yylval.str, "next")))
- cfg_entry_tab[entrycount].remote_numbers_handling = RNH_NEXT;
- else if(!(strcmp(yylval.str, "last")))
- cfg_entry_tab[entrycount].remote_numbers_handling = RNH_LAST;
- else if(!(strcmp(yylval.str, "first")))
- cfg_entry_tab[entrycount].remote_numbers_handling = RNH_FIRST;
- else
- {
- log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"remdial_handling\" at line %d!", lineno);
- config_error_flag++;
- }
- break;
-
- case REMOTE_PHONE_INCOMING:
- {
- int n;
- n = cfg_entry_tab[entrycount].incoming_numbers_count;
- if (n >= MAX_INCOMING)
- {
- log(LL_ERR, "ERROR parsing config file: too many \"remote_phone_incoming\" entries at line %d!", lineno);
- config_error_flag++;
- break;
- }
- log(LL_DBG, "entry %d: remote_phone_incoming #%d = %s", entrycount, n, yylval.str);
- strcpy(cfg_entry_tab[entrycount].remote_phone_incoming[n].number, yylval.str);
- cfg_entry_tab[entrycount].incoming_numbers_count++;
- }
- break;
-
- case RATESFILE:
- strcpy(ratesfile, yylval.str);
- log(LL_DBG, "system: ratesfile = %s", yylval.str);
- break;
-
- case RATETYPE:
- log(LL_DBG, "entry %d: ratetype = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].ratetype = yylval.num;
- break;
-
- case RECOVERYTIME:
- if(yylval.num < RECOVERYTIME_MIN)
- {
- yylval.num = RECOVERYTIME_MIN;
- log(LL_DBG, "entry %d: recoverytime < %d, min = %d", entrycount, RECOVERYTIME_MIN, yylval.num);
- }
-
- log(LL_DBG, "entry %d: recoverytime = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].recoverytime = yylval.num;
- break;
-
- case REGEXPR:
- if(nregexpr >= MAX_RE)
- {
- log(LL_DBG, "system: regexpr #%d >= MAX_RE", nregexpr);
- config_error_flag++;
- break;
- }
-
- if((i = regcomp(&(rarr[nregexpr].re), yylval.str, REG_EXTENDED|REG_NOSUB)) != 0)
- {
- char buf[256];
- regerror(i, &(rarr[nregexpr].re), buf, sizeof(buf));
- log(LL_DBG, "system: regcomp error for %s: [%s]", yylval.str, buf);
- config_error_flag++;
- break;
- }
- else
- {
- if((rarr[nregexpr].re_expr = malloc(strlen(yylval.str)+1)) == NULL)
- {
- log(LL_DBG, "system: regexpr malloc error error for %s", yylval.str);
- config_error_flag++;
- break;
- }
- strcpy(rarr[nregexpr].re_expr, yylval.str);
-
- log(LL_DBG, "system: regexpr %s stored into slot %d", yylval.str, nregexpr);
-
- if(rarr[nregexpr].re_prog != NULL)
- rarr[nregexpr].re_flg = 1;
-
- nregexpr++;
-
- }
- break;
-
- case REGPROG:
- if(nregprog >= MAX_RE)
- {
- log(LL_DBG, "system: regprog #%d >= MAX_RE", nregprog);
- config_error_flag++;
- break;
- }
- if((rarr[nregprog].re_prog = malloc(strlen(yylval.str)+1)) == NULL)
- {
- log(LL_DBG, "system: regprog malloc error error for %s", yylval.str);
- config_error_flag++;
- break;
- }
- strcpy(rarr[nregprog].re_prog, yylval.str);
-
- log(LL_DBG, "system: regprog %s stored into slot %d", yylval.str, nregprog);
-
- if(rarr[nregprog].re_expr != NULL)
- rarr[nregprog].re_flg = 1;
-
- nregprog++;
- break;
-
- case RTPRIO:
-#ifdef USE_RTPRIO
- rt_prio = yylval.num;
- if(rt_prio < RTP_PRIO_MIN || rt_prio > RTP_PRIO_MAX)
- {
- config_error_flag++;
- log(LL_DBG, "system: error, rtprio (%d) out of range!", yylval.num);
- }
- else
- {
- log(LL_DBG, "system: rtprio = %d", yylval.num);
- }
-#else
- rt_prio = RTPRIO_NOTUSED;
-#endif
- break;
-
- case UNITLENGTH:
- log(LL_DBG, "entry %d: unitlength = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].unitlength = yylval.num;
- break;
-
- case UNITLENGTHSRC:
- log(LL_DBG, "entry %d: unitlengthsrc = %s", entrycount, yylval.str);
- if(!(strcmp(yylval.str, "none")))
- cfg_entry_tab[entrycount].unitlengthsrc = ULSRC_NONE;
- else if(!(strcmp(yylval.str, "cmdl")))
- cfg_entry_tab[entrycount].unitlengthsrc = ULSRC_CMDL;
- else if(!(strcmp(yylval.str, "conf")))
- cfg_entry_tab[entrycount].unitlengthsrc = ULSRC_CONF;
- else if(!(strcmp(yylval.str, "rate")))
- cfg_entry_tab[entrycount].unitlengthsrc = ULSRC_RATE;
- else if(!(strcmp(yylval.str, "aocd")))
- cfg_entry_tab[entrycount].unitlengthsrc = ULSRC_DYN;
- else
- {
- log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"unitlengthsrc\" at line %d!", lineno);
- config_error_flag++;
- }
- break;
-
- case USRDEVICENAME:
- log(LL_DBG, "entry %d: usrdevicename = %s", entrycount, yylval.str);
- if(!strcmp(yylval.str, "rbch"))
- cfg_entry_tab[entrycount].usrdevicename = BDRV_RBCH;
- else if(!strcmp(yylval.str, "tel"))
- cfg_entry_tab[entrycount].usrdevicename = BDRV_TEL;
- else if(!strcmp(yylval.str, "ipr"))
- cfg_entry_tab[entrycount].usrdevicename = BDRV_IPR;
- else if(!strcmp(yylval.str, "isp"))
- cfg_entry_tab[entrycount].usrdevicename = BDRV_ISPPP;
- else
- {
- log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"usrdevicename\" at line %d!", lineno);
- config_error_flag++;
- }
- break;
-
- case USRDEVICEUNIT:
- log(LL_DBG, "entry %d: usrdeviceunit = %d", entrycount, yylval.num);
- cfg_entry_tab[entrycount].usrdeviceunit = yylval.num;
- break;
-
- case USEACCTFILE:
- useacctfile = yylval.booln;
- log(LL_DBG, "system: useacctfile = %d", yylval.booln);
- break;
-
- case USEDOWN:
- log(LL_DBG, "entry %d: usedown = %d", entrycount, yylval.booln);
- cfg_entry_tab[entrycount].usedown = yylval.booln;
- break;
-
- default:
- log(LL_ERR, "ERROR parsing config file: unknown keyword at line %d!", lineno);
- config_error_flag++;
- break;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * configuration validation and consistency check
- *---------------------------------------------------------------------------*/
-static void
-check_config(void)
-{
- cfg_entry_t *cep = &cfg_entry_tab[0]; /* ptr to config entry */
- int i;
- int error = 0;
-
- /* regular expression table */
-
- for(i=0; i < MAX_RE; i++)
- {
- if((rarr[i].re_expr != NULL) && (rarr[i].re_prog == NULL))
- {
- log(LL_ERR, "check_config: regular expression %d without program!", i);
- error++;
- }
- if((rarr[i].re_prog != NULL) && (rarr[i].re_expr == NULL))
- {
- log(LL_ERR, "check_config: regular expression program %d without expression!", i);
- error++;
- }
- }
-
- /* entry sections */
-
- for(i=0; i <= entrycount; i++, cep++)
- {
- /* isdn controller number */
-
- if((cep->isdncontroller < 0) || (cep->isdncontroller > (ncontroller-1)))
- {
- log(LL_ERR, "check_config: isdncontroller out of range in entry %d!", i);
- error++;
- }
-
- /* numbers used for dialout */
-
- if((cep->inout != DIR_INONLY) && (cep->dialin_reaction != REACT_ANSWER))
- {
- if(cep->remote_numbers_count == 0)
- {
- log(LL_ERR, "check_config: remote-phone-dialout not set in entry %d!", i);
- error++;
- }
- if(strlen(cep->local_phone_dialout) == 0)
- {
- log(LL_ERR, "check_config: local-phone-dialout not set in entry %d!", i);
- error++;
- }
- }
-
- /* numbers used for incoming calls */
-
- if(cep->inout != DIR_OUTONLY)
- {
- if(strlen(cep->local_phone_incoming) == 0)
- {
- log(LL_ERR, "check_config: local-phone-incoming not set in entry %d!", i);
- error++;
- }
- if(cep->incoming_numbers_count == 0)
- {
- log(LL_ERR, "check_config: remote-phone-incoming not set in entry %d!", i);
- error++;
- }
- }
-
- if((cep->dialin_reaction == REACT_ANSWER) && (cep->b1protocol != BPROT_NONE))
- {
- log(LL_ERR, "check_config: b1protocol not raw for telephony in entry %d!", i);
- error++;
- }
- }
- if(error)
- {
- log(LL_ERR, "check_config: %d error(s) in configuration file, exit!", error);
- do_exit(1);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * print the configuration
- *---------------------------------------------------------------------------*/
-static void
-print_config(void)
-{
-#define PFILE stdout
-
- cfg_entry_t *cep = &cfg_entry_tab[0]; /* ptr to config entry */
- int i, j;
- extern VARA_DECL(struct monitor_rights) rights;
- time_t clock;
- char mytime[64];
-
- time(&clock);
- strcpy(mytime, ctime(&clock));
- mytime[strlen(mytime)-1] = '\0';
-
- fprintf(PFILE, "#---------------------------------------------------------------------------\n");
- fprintf(PFILE, "# system section (generated %s)\n", mytime);
- fprintf(PFILE, "#---------------------------------------------------------------------------\n");
- fprintf(PFILE, "system\n");
- fprintf(PFILE, "useacctfile = %s\n", useacctfile ? "on\t\t\t\t# update accounting information file" : "off\t\t\t\t# don't update accounting information file");
- fprintf(PFILE, "acctall = %s\n", acct_all ? "on\t\t\t\t# put all events into accounting file" : "off\t\t\t\t# put only charged events into accounting file");
- fprintf(PFILE, "acctfile = %s\t\t# accounting information file\n", acctfile);
- fprintf(PFILE, "ratesfile = %s\t\t# charging rates database file\n", ratesfile);
-
-#ifdef USE_RTPRIO
- if(rt_prio == RTPRIO_NOTUSED)
- fprintf(PFILE, "# rtprio is unused\n");
- else
- fprintf(PFILE, "rtprio = %d\t\t\t\t# isdnd runs at realtime priority\n", rt_prio);
-#endif
-
- /* regular expression table */
-
- for(i=0; i < MAX_RE; i++)
- {
- if(rarr[i].re_expr != NULL)
- {
- fprintf(PFILE, "regexpr = \"%s\"\t\t# scan logfile for this expression\n", rarr[i].re_expr);
- }
- if(rarr[i].re_prog != NULL)
- {
- fprintf(PFILE, "regprog = %s\t\t# program to run when expression is matched\n", rarr[i].re_prog);
- }
- }
-
-#ifdef I4B_EXTERNAL_MONITOR
-
- fprintf(PFILE, "monitor-allowed = %s\n", do_monitor ? "on\t\t\t\t# remote isdnd monitoring allowed" : "off\t\t\t\t# remote isdnd monitoring disabled");
- fprintf(PFILE, "monitor-port = %d\t\t\t\t# TCP/IP port number used for remote monitoring\n", monitorport);
-
- if(VARA_NUM(rights))
- {
- char *s = "error\n";
- char b[512];
-
- VARA_FOREACH(rights, i)
- {
- if(VARA_AT(rights, i).local)
- {
- fprintf(PFILE, "monitor = \"%s\"\t\t# local socket name for monitoring\n", VARA_AT(rights, i).name);
- }
- else
- {
- struct in_addr ia;
- ia.s_addr = ntohl(VARA_AT(rights, i).net);
-
- switch(VARA_AT(rights, i).mask)
- {
- case 0xffffffff:
- s = "32";
- break;
- case 0xfffffffe:
- s = "31";
- break;
- case 0xfffffffc:
- s = "30";
- break;
- case 0xfffffff8:
- s = "29";
- break;
- case 0xfffffff0:
- s = "28";
- break;
- case 0xffffffe0:
- s = "27";
- break;
- case 0xffffffc0:
- s = "26";
- break;
- case 0xffffff80:
- s = "25";
- break;
- case 0xffffff00:
- s = "24";
- break;
- case 0xfffffe00:
- s = "23";
- break;
- case 0xfffffc00:
- s = "22";
- break;
- case 0xfffff800:
- s = "21";
- break;
- case 0xfffff000:
- s = "20";
- break;
- case 0xffffe000:
- s = "19";
- break;
- case 0xffffc000:
- s = "18";
- break;
- case 0xffff8000:
- s = "17";
- break;
- case 0xffff0000:
- s = "16";
- break;
- case 0xfffe0000:
- s = "15";
- break;
- case 0xfffc0000:
- s = "14";
- break;
- case 0xfff80000:
- s = "13";
- break;
- case 0xfff00000:
- s = "12";
- break;
- case 0xffe00000:
- s = "11";
- break;
- case 0xffc00000:
- s = "10";
- break;
- case 0xff800000:
- s = "9";
- break;
- case 0xff000000:
- s = "8";
- break;
- case 0xfe000000:
- s = "7";
- break;
- case 0xfc000000:
- s = "6";
- break;
- case 0xf8000000:
- s = "5";
- break;
- case 0xf0000000:
- s = "4";
- break;
- case 0xe0000000:
- s = "3";
- break;
- case 0xc0000000:
- s = "2";
- break;
- case 0x80000000:
- s = "1";
- break;
- case 0x00000000:
- s = "0";
- break;
- }
- fprintf(PFILE, "monitor = \"%s/%s\"\t\t# host (net/mask) allowed to connect for monitoring\n", inet_ntoa(ia), s);
- }
- b[0] = '\0';
-
- if((VARA_AT(rights, i).rights) & I4B_CA_COMMAND_FULL)
- strcat(b, "fullcmd,");
- if((VARA_AT(rights, i).rights) & I4B_CA_COMMAND_RESTRICTED)
- strcat(b, "restrictedcmd,");
- if((VARA_AT(rights, i).rights) & I4B_CA_EVNT_CHANSTATE)
- strcat(b, "channelstate,");
- if((VARA_AT(rights, i).rights) & I4B_CA_EVNT_CALLIN)
- strcat(b, "callin,");
- if((VARA_AT(rights, i).rights) & I4B_CA_EVNT_CALLOUT)
- strcat(b, "callout,");
- if((VARA_AT(rights, i).rights) & I4B_CA_EVNT_I4B)
- strcat(b, "logevents,");
-
- if(b[strlen(b)-1] == ',')
- b[strlen(b)-1] = '\0';
-
- fprintf(PFILE, "monitor-access = %s\t\t# monitor access rights\n", b);
- }
- }
-
-#endif
- /* entry sections */
-
- for(i=0; i <= entrycount; i++, cep++)
- {
- fprintf(PFILE, "\n");
- fprintf(PFILE, "#---------------------------------------------------------------------------\n");
- fprintf(PFILE, "# entry section %d\n", i);
- fprintf(PFILE, "#---------------------------------------------------------------------------\n");
- fprintf(PFILE, "entry\n");
-
- fprintf(PFILE, "name = %s\t\t# name for this entry section\n", cep->name);
-
- fprintf(PFILE, "isdncontroller = %d\t\t# ISDN card number used for this entry\n", cep->isdncontroller);
- fprintf(PFILE, "isdnchannel = ");
- switch(cep->isdnchannel)
- {
- case CHAN_ANY:
- fprintf(PFILE, "-1\t\t# any ISDN B-channel may be used\n");
- break;
- case CHAN_B1:
- fprintf(PFILE, "1\t\t# only ISDN B-channel 1 may be used\n");
- break;
- case CHAN_B2:
- fprintf(PFILE, "2\t\t# only ISDN B-channel 2 ay be used\n");
- break;
- }
-
- fprintf(PFILE, "usrdevicename = %s\t\t# name of userland ISDN B-channel device\n", bdrivername(cep->usrdevicename));
- fprintf(PFILE, "usrdeviceunit = %d\t\t# unit number of userland ISDN B-channel device\n", cep->usrdeviceunit);
-
- fprintf(PFILE, "b1protocol = %s\n", cep->b1protocol ? "hdlc\t\t# B-channel layer 1 protocol is HDLC" : "raw\t\t# No B-channel layer 1 protocol used");
-
- if(!(cep->usrdevicename == BDRV_TEL))
- {
- fprintf(PFILE, "direction = ");
- switch(cep->inout)
- {
- case DIR_INONLY:
- fprintf(PFILE, "in\t\t# only incoming connections allowed\n");
- break;
- case DIR_OUTONLY:
- fprintf(PFILE, "out\t\t# only outgoing connections allowed\n");
- break;
- case DIR_INOUT:
- fprintf(PFILE, "inout\t\t# incoming and outgoing connections allowed\n");
- break;
- }
- }
-
- if(!((cep->usrdevicename == BDRV_TEL) || (cep->inout == DIR_INONLY)))
- {
- if(cep->remote_numbers_count > 1)
- {
- for(j=0; j<cep->remote_numbers_count; j++)
- fprintf(PFILE, "remote-phone-dialout = %s\t\t# telephone number %d for dialing out to remote\n", cep->remote_numbers[j].number, j+1);
-
- fprintf(PFILE, "remdial-handling = ");
-
- switch(cep->remote_numbers_handling)
- {
- case RNH_NEXT:
- fprintf(PFILE, "next\t\t# use next number after last successfull for new dial\n");
- break;
- case RNH_LAST:
- fprintf(PFILE, "last\t\t# use last successfull number for new dial\n");
- break;
- case RNH_FIRST:
- fprintf(PFILE, "first\t\t# always start with first number for new dial\n");
- break;
- }
- }
- else
- {
- fprintf(PFILE, "remote-phone-dialout = %s\t\t# telephone number for dialing out to remote\n", cep->remote_numbers[0].number);
- }
-
- fprintf(PFILE, "local-phone-dialout = %s\t\t# show this number to remote when dialling out\n", cep->local_phone_dialout);
- fprintf(PFILE, "dialout-type = %s\n", cep->dialouttype ? "calledback\t\t# i am called back by remote" : "normal\t\t# i am not called back by remote");
- }
-
- if(!(cep->inout == DIR_OUTONLY))
- {
- int n;
-
- fprintf(PFILE, "local-phone-incoming = %s\t\t# incoming calls must match this (mine) telephone number\n", cep->local_phone_incoming);
- for (n = 0; n < cep->incoming_numbers_count; n++)
- fprintf(PFILE, "remote-phone-incoming = %s\t\t# this is a valid remote number to call me\n",
- cep->remote_phone_incoming[n].number);
-
- fprintf(PFILE, "dialin-reaction = ");
- switch(cep->dialin_reaction)
- {
- case REACT_ACCEPT:
- fprintf(PFILE, "accept\t\t# i accept a call from remote and connect\n");
- break;
- case REACT_REJECT:
- fprintf(PFILE, "reject\t\t# i reject the call from remote\n");
- break;
- case REACT_IGNORE:
- fprintf(PFILE, "ignore\t\t# i ignore the call from remote\n");
- break;
- case REACT_ANSWER:
- fprintf(PFILE, "answer\t\t# i will start telephone answering when remote calls in\n");
- break;
- case REACT_CALLBACK:
- fprintf(PFILE, "callback\t\t# when remote calls in, i will hangup and call back\n");
- break;
- }
- }
-
- if(!((cep->inout == DIR_INONLY) || (cep->usrdevicename == BDRV_TEL)))
- fprintf(PFILE, "idletime-outgoing = %d\t\t# outgoing call idle timeout\n", cep->idle_time_out);
-
- if(!(cep->inout == DIR_OUTONLY))
- fprintf(PFILE, "idletime-incoming = %d\t\t# incoming call idle timeout\n", cep->idle_time_in);
-
- if(!(cep->usrdevicename == BDRV_TEL))
- {
- fprintf(PFILE, "unitlengthsrc = ");
- switch(cep->unitlengthsrc)
- {
- case ULSRC_NONE:
- fprintf(PFILE, "none\t\t# no unit length specified, using default\n");
- break;
- case ULSRC_CMDL:
- fprintf(PFILE, "cmdl\t\t# using unit length specified on commandline\n");
- break;
- case ULSRC_CONF:
- fprintf(PFILE, "conf\t\t# using unitlength specified by unitlength-keyword\n");
- fprintf(PFILE, "unitlength = %d\t\t# fixed unitlength\n", cep->unitlength);
- break;
- case ULSRC_RATE:
- fprintf(PFILE, "rate\t\t# using unitlength specified in rate database\n");
- fprintf(PFILE, "ratetype = %d\t\t# type of rate from rate database\n", cep->ratetype);
- break;
- case ULSRC_DYN:
- fprintf(PFILE, "aocd\t\t# using dynamically calculated unitlength based on AOCD subscription\n");
- fprintf(PFILE, "ratetype = %d\t\t# type of rate from rate database\n", cep->ratetype);
- break;
- }
-
- fprintf(PFILE, "earlyhangup = %d\t\t# early hangup safety time\n", cep->earlyhangup);
-
- }
-
- if(cep->usrdevicename == BDRV_TEL)
- {
- fprintf(PFILE, "answerprog = %s\t\t# program used to answer incoming telephone calls\n", cep->answerprog);
- fprintf(PFILE, "alert = %d\t\t# number of seconds to wait before accepting a call\n", cep->alert);
- }
-
- if(!(cep->usrdevicename == BDRV_TEL))
- {
- if(cep->dialin_reaction == REACT_CALLBACK)
- fprintf(PFILE, "callbackwait = %d\t\t# i am waiting this time before calling back remote\n", cep->callbackwait);
-
- if(cep->dialouttype == DIALOUT_CALLEDBACK)
- fprintf(PFILE, "calledbackwait = %d\t\t# i am waiting this time for a call back from remote\n", cep->calledbackwait);
-
- if(!(cep->inout == DIR_INONLY))
- {
- fprintf(PFILE, "dialretries = %d\t\t# number of dialing retries\n", cep->dialretries);
- fprintf(PFILE, "recoverytime = %d\t\t# time to wait between dialling retries\n", cep->recoverytime);
- fprintf(PFILE, "dialrandincr = %s\t\t# use random dialing time addon\n", cep->dialrandincr ? "on" : "off");
-
- fprintf(PFILE, "usedown = %s\n", cep->usedown ? "on\t\t# ISDN device switched off on excessive dial failures" : "off\t\t# no device switchoff on excessive dial failures");
- if(cep->usedown)
- {
- fprintf(PFILE, "downtries = %d\t\t# number of dialretries failures before switching off\n", cep->downtries);
- fprintf(PFILE, "downtime = %d\t\t# time device is switched off\n", cep->downtime);
- }
- }
- }
- }
- fprintf(PFILE, "\n");
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/rc_parse.y b/usr.sbin/i4b/isdnd/rc_parse.y
deleted file mode 100644
index 6c1cf1440ab6..000000000000
--- a/usr.sbin/i4b/isdnd/rc_parse.y
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright (c) 1997 Joerg Wunsch. All rights reserved.
- *
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - runtime configuration parser
- * -----------------------------------------
- *
- * $Id: rc_parse.y,v 1.15 1998/12/05 18:03:38 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:12:26 1998]
- *
- *---------------------------------------------------------------------------*/
-
-%{
-
-/* #define YYDEBUG 1 */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "monitor.h" /* monitor access rights bit definitions */
-#include "isdnd.h"
-
-#ifndef FALSE
-# define FALSE 0
-#endif
-
-#ifndef TRUE
-# define TRUE 1
-#endif
-
-extern void cfg_setval(int keyword);
-extern void reset_scanner(FILE *infile);
-extern void yyerror(const char *msg);
-extern int yylex();
-
-extern int lineno;
-extern char *yytext;
-extern int nentries;
-
-int saw_system = 0;
-int entrycount = -1;
-
-%}
-
-%token ACCTALL
-%token ACCTFILE
-%token ALERT
-%token ALIASING
-%token ALIASFNAME
-%token ANSWERPROG
-%token B1PROTOCOL
-%token CALLBACKWAIT
-%token CALLEDBACKWAIT
-%token CONNECTPROG
-%token DIALRETRIES
-%token DIALRANDINCR
-%token DIALOUTTYPE
-%token DIRECTION
-%token DISCONNECTPROG
-%token DOWNTRIES
-%token DOWNTIME
-%token EARLYHANGUP
-%token ENTRY
-%token IDLETIME_IN
-%token IDLETIME_OUT
-%token ISDNCONTROLLER
-%token ISDNCHANNEL
-%token ISDNTIME
-%token ISDNTXDELIN
-%token ISDNTXDELOUT
-%token LOCAL_PHONE_DIALOUT
-%token LOCAL_PHONE_INCOMING
-%token MONITORSW
-%token MONITORPORT
-%token MONITOR
-%token MONITORACCESS
-%token FULLCMD
-%token RESTRICTEDCMD
-%token CHANNELSTATE
-%token CALLIN
-%token CALLOUT
-%token LOGEVENTS
-%token NAME
-%token NO
-%token OFF
-%token ON
-%token RATESFILE
-%token RATETYPE
-%token REMOTE_NUMBERS_HANDLING
-%token REMOTE_PHONE_INCOMING
-%token REMOTE_PHONE_DIALOUT
-%token REACTION
-%token RECOVERYTIME
-%token REGEXPR
-%token REGPROG
-%token RTPRIO
-%token SYSTEM
-%token UNITLENGTH
-%token UNITLENGTHSRC
-%token USEACCTFILE
-%token USRDEVICENAME
-%token USRDEVICEUNIT
-%token USEDOWN
-%token YES
-
-%token <str> NUMBERSTR
-
-%token <str> STRING
-
-%type <booln> boolean
-
-%type <num> sysfilekeyword sysnumkeyword sysstrkeyword sysboolkeyword
-%type <num> numkeyword strkeyword boolkeyword monrights monright
-%type <str> filename
-
-%union {
- int booln;
- int num;
- char *str;
-}
-
-%%
-
-config: sections
- ;
-
-sections: possible_nullentries
- syssect
- entrysects
- ;
-
-possible_nullentries:
- /* lambda */
- | possible_nullentries error '\n'
- | possible_nullentries nullentry
- ;
-
-nullentry: '\n'
- ;
-
-entrysects: entrysect
- | entrysects entrysect
- ;
-
-syssect: SYSTEM sysentries
- ;
-
-sysentries: sysentry
- {
- saw_system = 1;
- monitor_clear_rights();
- }
- | sysentries sysentry
- ;
-
-sysentry: sysfileentry
- | sysboolentry
- | sysnumentry
- | sysstrentry
- | sysmonitorstart
- | sysmonitorrights
- | nullentry
- | error '\n'
- ;
-
-
-sysmonitorstart:
- MONITOR '=' STRING '\n'
- {
- char *err = NULL;
- switch (monitor_start_rights($3)) {
- case I4BMAR_OK:
- break;
- case I4BMAR_LENGTH:
- err = "local socket name too long: %s";
- break;
- case I4BMAR_DUP:
- err = "duplicate entry: %s";
- break;
- case I4BMAR_CIDR:
- err = "invalid CIDR specification: %s";
- break;
- case I4BMAR_NOIP:
- err = "could not resolve host or net specification: %s";
- break;
- }
- if (err) {
- char msg[1024];
- snprintf(msg, sizeof msg, err, $3);
- yyerror(msg);
- }
- }
- ;
-
-sysmonitorrights:
- MONITORACCESS '=' monrights '\n'
- { monitor_add_rights($3); }
- ;
-
-monrights: monrights ',' monright { $$ = $1 | $3; }
- | monright { $$ = $1; }
- ;
-
-monright: FULLCMD { $$ = I4B_CA_COMMAND_FULL; }
- | RESTRICTEDCMD { $$ = I4B_CA_COMMAND_RESTRICTED; }
- | CHANNELSTATE { $$ = I4B_CA_EVNT_CHANSTATE; }
- | CALLIN { $$ = I4B_CA_EVNT_CALLIN; }
- | CALLOUT { $$ = I4B_CA_EVNT_CALLOUT; }
- | LOGEVENTS { $$ = I4B_CA_EVNT_I4B; }
- ;
-
-sysfileentry: sysfilekeyword '=' filename '\n'
- {
- cfg_setval($1);
- }
- ;
-
-sysboolentry: sysboolkeyword '=' boolean '\n'
- {
- yylval.booln = $3;
- cfg_setval($1);
- }
- ;
-
-sysnumentry: sysnumkeyword '=' NUMBERSTR '\n'
- {
- yylval.num = atoi($3);
- cfg_setval($1);
- }
- ;
-
-sysstrentry: sysstrkeyword '=' STRING '\n'
- {
- cfg_setval($1);
- }
- | sysstrkeyword '=' NUMBERSTR '\n'
- {
- cfg_setval($1);
- }
- ;
-
-filename: STRING {
- if ($1[0] != '/')
- {
- yyerror("filename doesn't start with a slash");
- YYERROR;
- }
- $$ = $1;
- }
- ;
-
-boolean: NO { $$ = FALSE; }
- | OFF { $$ = FALSE; }
- | ON { $$ = TRUE; }
- | YES { $$ = TRUE; }
- ;
-
-sysfilekeyword: RATESFILE { $$ = RATESFILE; }
- | ACCTFILE { $$ = ACCTFILE; }
- | ALIASFNAME { $$ = ALIASFNAME; }
- ;
-
-sysboolkeyword: USEACCTFILE { $$ = USEACCTFILE; }
- | ALIASING { $$ = ALIASING; }
- | ACCTALL { $$ = ACCTALL; }
- | ISDNTIME { $$ = ISDNTIME; }
- | MONITORSW { $$ = MONITORSW; }
- ;
-
-sysnumkeyword: MONITORPORT { $$ = MONITORPORT; }
- | RTPRIO { $$ = RTPRIO; }
- ;
-
-sysstrkeyword: REGEXPR { $$ = REGEXPR; }
- | REGPROG { $$ = REGPROG; }
- ;
-
-entrysect: ENTRY
- {
- entrycount++;
- nentries++;
- }
- entries
- ;
-
-entries: entry
- | entries entry
- ;
-
-entry: strentry
- | numentry
- | boolentry
- | nullentry
- | error '\n'
- ;
-
-strentry: strkeyword '=' STRING '\n'
- {
- cfg_setval($1);
- }
- | strkeyword '=' NUMBERSTR '\n'
- {
- cfg_setval($1);
- }
- ;
-
-boolentry: boolkeyword '=' boolean '\n'
- {
- yylval.booln = $3;
- cfg_setval($1);
- }
- ;
-
-numentry: numkeyword '=' NUMBERSTR '\n'
- {
- yylval.num = atoi($3);
- cfg_setval($1);
- }
- ;
-
-strkeyword: ANSWERPROG { $$ = ANSWERPROG; }
- | B1PROTOCOL { $$ = B1PROTOCOL; }
- | CONNECTPROG { $$ = CONNECTPROG; }
- | DIALOUTTYPE { $$ = DIALOUTTYPE; }
- | DIRECTION { $$ = DIRECTION; }
- | DISCONNECTPROG { $$ = DISCONNECTPROG; }
- | LOCAL_PHONE_INCOMING { $$ = LOCAL_PHONE_INCOMING; }
- | LOCAL_PHONE_DIALOUT { $$ = LOCAL_PHONE_DIALOUT; }
- | NAME { $$ = NAME; }
- | REACTION { $$ = REACTION; }
- | REMOTE_NUMBERS_HANDLING { $$ = REMOTE_NUMBERS_HANDLING; }
- | REMOTE_PHONE_INCOMING { $$ = REMOTE_PHONE_INCOMING; }
- | REMOTE_PHONE_DIALOUT { $$ = REMOTE_PHONE_DIALOUT; }
- | UNITLENGTHSRC { $$ = UNITLENGTHSRC; }
- | USRDEVICENAME { $$ = USRDEVICENAME; }
- ;
-
-numkeyword: ALERT { $$ = ALERT; }
- | CALLBACKWAIT { $$ = CALLBACKWAIT; }
- | CALLEDBACKWAIT { $$ = CALLEDBACKWAIT; }
- | DIALRETRIES { $$ = DIALRETRIES; }
- | EARLYHANGUP { $$ = EARLYHANGUP; }
- | IDLETIME_IN { $$ = IDLETIME_IN; }
- | IDLETIME_OUT { $$ = IDLETIME_OUT; }
- | ISDNCONTROLLER { $$ = ISDNCONTROLLER; }
- | ISDNCHANNEL { $$ = ISDNCHANNEL; }
- | ISDNTXDELIN { $$ = ISDNTXDELIN; }
- | ISDNTXDELOUT { $$ = ISDNTXDELOUT; }
- | RATETYPE { $$ = RATETYPE; }
- | RECOVERYTIME { $$ = RECOVERYTIME; }
- | UNITLENGTH { $$ = UNITLENGTH; }
- | USRDEVICEUNIT { $$ = USRDEVICEUNIT; }
- | DOWNTIME { $$ = DOWNTIME; }
- | DOWNTRIES { $$ = DOWNTRIES; }
- ;
-
-boolkeyword: DIALRANDINCR { $$ = DIALRANDINCR; }
- | USEDOWN { $$ = USEDOWN; }
- ;
-
-%%
diff --git a/usr.sbin/i4b/isdnd/rc_scan.l b/usr.sbin/i4b/isdnd/rc_scan.l
deleted file mode 100644
index dfca28ce6961..000000000000
--- a/usr.sbin/i4b/isdnd/rc_scan.l
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 1997 Joerg Wunsch. All rights reserved.
- *
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - runtime configuration lexical analyzer
- * ---------------------------------------------------
- *
- * $Id: rc_scan.l,v 1.19 1998/12/18 17:17:57 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:08:25 1998]
- *
- *---------------------------------------------------------------------------*/
-
-%{
-
-#include <err.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sysexits.h>
-
-#include "y.tab.h"
-
-int lineno;
-
-%}
-
-%option noyywrap
-%option nounput
-
-%%
-
-#.*$ { /*
- * Drop comment. NB: this prevents a hash
- * sign from appearing inside a quoted string.
- */
- }
-
-["][^"]*["] {
- char *str;
- if ((str = malloc(yyleng - 1)) == 0)
- errx(EX_OSERR, "Out of virtual memory");
- memcpy(str, yytext + 1, yyleng - 2);
- str[yyleng - 2] = 0;
- yylval.str = str;
- return STRING;
- }
-
-(-*[0-9]+)|\* {
- char *str;
- char *p = yytext;
- int i = 0;
- if ((str = malloc(128)) == 0)
- errx(EX_OSERR, "Out of virtual memory");
- while(*p == '-' || isdigit(*p) || *p == '*')
- str[i++] = *p++;
- str[i] = '\0';
- yylval.str = str;
- return NUMBERSTR;
- }
-
-acctall { return ACCTALL; }
-acctfile { return ACCTFILE; }
-alert { return ALERT; }
-aliasing { return ALIASING; }
-aliasfile { return ALIASFNAME; }
-answerprog { return ANSWERPROG; }
-b1protocol { return B1PROTOCOL; }
-callbackwait { return CALLBACKWAIT; }
-calledbackwait { return CALLEDBACKWAIT; }
-connectprog { return CONNECTPROG; }
-dialin-reaction { return REACTION; }
-dialout-type { return DIALOUTTYPE; }
-dialrandincr { return DIALRANDINCR; }
-dialretries { return DIALRETRIES; }
-direction { return DIRECTION; }
-disconnectprog { return DISCONNECTPROG; }
-downtries { return DOWNTRIES; }
-downtime { return DOWNTIME; }
-earlyhangup { return EARLYHANGUP; }
-entry { return ENTRY; }
-idletime-incoming { return IDLETIME_IN; }
-idletime-outgoing { return IDLETIME_OUT; }
-isdncontroller { return ISDNCONTROLLER; }
-isdnchannel { return ISDNCHANNEL; }
-isdntime { return ISDNTIME; }
-isdntxdel-incoming { return ISDNTXDELIN; }
-isdntxdel-outgoing { return ISDNTXDELOUT; }
-local-phone-dialout { return LOCAL_PHONE_DIALOUT; }
-local-phone-incoming { return LOCAL_PHONE_INCOMING; }
-monitor-allowed { return MONITORSW; }
-monitor-port { return MONITORPORT; }
-monitor { return MONITOR; }
-monitor-access { return MONITORACCESS; }
-fullcmd { return FULLCMD; }
-restrictedcmd { return RESTRICTEDCMD; }
-channelstate { return CHANNELSTATE; }
-callin { return CALLIN; }
-callout { return CALLOUT; }
-logevents { return LOGEVENTS; }
-name { return NAME; }
-no { return NO; }
-off { return OFF; }
-on { return ON; }
-ratesfile { return RATESFILE; }
-ratetype { return RATETYPE; }
-recoverytime { return RECOVERYTIME; }
-regexpr { return REGEXPR; }
-regprog { return REGPROG; }
-remdial-handling { return REMOTE_NUMBERS_HANDLING; }
-remote-phone-dialout { return REMOTE_PHONE_DIALOUT; }
-remote-phone-incoming { return REMOTE_PHONE_INCOMING; }
-rtprio { return RTPRIO; }
-system { return SYSTEM; }
-unitlength { return UNITLENGTH; }
-unitlengthsrc { return UNITLENGTHSRC; }
-useacctfile { return USEACCTFILE; }
-usrdevicename { return USRDEVICENAME; }
-usrdeviceunit { return USRDEVICEUNIT; }
-usedown { return USEDOWN; }
-yes { return YES; }
-
-\n { lineno++; return '\n'; }
-
-[A-Za-z/.][-A-Za-z0-9_/.]* {
- char *str;
- if ((str = strdup(yytext)) == 0)
- err(EX_OSERR, "Out of virtual memory");
- yylval.str = str;
- return STRING;
- }
-
-[ \t] { /* drop white space */ }
-
-. { return yytext[0]; }
-
-%%
-
-void
-reset_scanner(FILE *infile)
-{
- yyrestart(infile);
- lineno = 1;
-}
diff --git a/usr.sbin/i4b/isdnd/support.c b/usr.sbin/i4b/isdnd/support.c
deleted file mode 100644
index 77c08410ef40..000000000000
--- a/usr.sbin/i4b/isdnd/support.c
+++ /dev/null
@@ -1,831 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - misc support routines
- * ----------------------------------
- *
- * $Id: support.c,v 1.43 1998/12/18 09:47:09 hm Exp $
- *
- * last edit-date: [Mon Dec 14 11:17:22 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-#define SRC (aliasing == 0 ? mp->src_telno : src_tela)
-#define DST (aliasing == 0 ? mp->dst_telno : dst_tela)
-
-/*---------------------------------------------------------------------------*
- * find an active entry by driver type and driver unit
- *---------------------------------------------------------------------------*/
-cfg_entry_t *
-find_active_entry_by_driver(int drivertype, int driverunit)
-{
- cfg_entry_t *cep = NULL;
- int i;
-
- for(i=0; i < nentries; i++)
- {
- cep = &cfg_entry_tab[i]; /* ptr to config entry */
-
- if(!((cep->usrdevicename == drivertype) &&
- (cep->usrdeviceunit == driverunit)))
- {
- continue;
- }
-
- /* found */
-
- if(cep->cdid == CDID_UNUSED)
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_active_entry_by_driver: entry %d, cdid is CDID_UNUSED!", i)));
- return(NULL);
- }
- else if(cep->cdid == CDID_RESERVED)
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_active_entry_by_driver: entry %d, cdid is CDID_RESERVED!", i)));
- return(NULL);
- }
- return(cep);
- }
- return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- * find entry by drivertype and driverunit and setup for dialing out
- *---------------------------------------------------------------------------*/
-cfg_entry_t *
-find_by_device_for_dialout(int drivertype, int driverunit)
-{
- cfg_entry_t *cep = NULL;
- int i;
-
- for(i=0; i < nentries; i++)
- {
- cep = &cfg_entry_tab[i]; /* ptr to config entry */
-
- /* compare driver type and unit */
-
- if(!((cep->usrdevicename == drivertype) &&
- (cep->usrdeviceunit == driverunit)))
- {
- continue;
- }
-
- /* found, check if already reserved */
-
- if(cep->cdid == CDID_RESERVED)
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialout: entry %d, cdid reserved!", i)));
- return(NULL);
- }
-
- /* check if this entry is already in use ? */
-
- if(cep->cdid != CDID_UNUSED)
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialout: entry %d, cdid in use", i)));
- return(NULL);
- }
-
- if((setup_dialout(cep)) == GOOD)
- {
- /* found an entry to be used for calling out */
-
- DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialout: found entry %d!", i)));
- return(cep);
- }
- else
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialout: entry %d, setup_dialout() failed!", i)));
- return(NULL);
- }
- }
-
- DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialout: no entry found!")));
- return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- * find entry by drivertype and driverunit and setup for dialing out
- *---------------------------------------------------------------------------*/
-int
-setup_dialout(cfg_entry_t *cep)
-{
- /* check controller operational */
-
- if((get_controller_state(cep->isdncontroller)) != CTRL_UP)
- {
- DBGL(DL_MSG, (log(LL_DBG, "setup_dialout: entry %s, controller is down", cep->name)));
- return(ERROR);
- }
-
- cep->isdncontrollerused = cep->isdncontroller;
-
- /* check channel available */
-
- switch(cep->isdnchannel)
- {
- case CHAN_B1:
- case CHAN_B2:
- if((ret_channel_state(cep->isdncontroller, cep->isdnchannel)) != CHAN_IDLE)
- {
- DBGL(DL_MSG, (log(LL_DBG, "setup_dialout: entry %s, channel not free", cep->name)));
- return(ERROR);
- }
- cep->isdnchannelused = cep->isdnchannel;
- break;
-
- case CHAN_ANY:
- if(((ret_channel_state(cep->isdncontroller, CHAN_B1)) != CHAN_IDLE) &&
- ((ret_channel_state(cep->isdncontroller, CHAN_B2)) != CHAN_IDLE))
- {
- DBGL(DL_MSG, (log(LL_DBG, "setup_dialout: entry %s, no channel free", cep->name)));
- return(ERROR);
- }
- cep->isdnchannelused = CHAN_ANY;
- break;
-
- default:
- DBGL(DL_MSG, (log(LL_DBG, "setup_dialout: entry %s, channel undefined", cep->name)));
- return(ERROR);
- break;
- }
-
- DBGL(DL_MSG, (log(LL_DBG, "setup_dialout: entry %s ok!", cep->name)));
-
- /* preset disconnect cause */
-
- SET_CAUSE_TYPE(cep->disc_cause, CAUSET_I4B);
- SET_CAUSE_VAL(cep->disc_cause, CAUSE_I4B_NORMAL);
-
- return(GOOD);
-}
-
-/*---------------------------------------------------------------------------*
- * find entry by drivertype and driverunit
- *---------------------------------------------------------------------------*/
-cfg_entry_t *
-get_cep_by_driver(int drivertype, int driverunit)
-{
- cfg_entry_t *cep = NULL;
- int i;
-
- for(i=0; i < nentries; i++)
- {
- cep = &cfg_entry_tab[i]; /* ptr to config entry */
-
- if(!((cep->usrdevicename == drivertype) &&
- (cep->usrdeviceunit == driverunit)))
- {
- continue;
- }
-
- DBGL(DL_MSG, (log(LL_DBG, "get_cep_by_driver: found entry %d!", i)));
- return(cep);
- }
- return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- * find a matching entry for an incoming call
- *
- * - not found/no match: log output with LL_CHD and return NULL
- * - found/match: make entry in free cep, return address
- *---------------------------------------------------------------------------*/
-cfg_entry_t *
-find_matching_entry_incoming(msg_connect_ind_t *mp)
-{
- cfg_entry_t *cep = NULL;
- int i;
- char *src_tela = "ERROR-src_tela";
- char *dst_tela = "ERROR-dst_tela";
-
- for(i=0; i < nentries; i++)
- {
- int n;
- cep = &cfg_entry_tab[i]; /* ptr to config entry */
-
- /* check my number */
-
- if(strncmp(cep->local_phone_incoming, mp->dst_telno, strlen(cep->local_phone_incoming)))
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, myno %s != incomingno %s", i,
- cep->local_phone_incoming, mp->dst_telno)));
- continue;
- }
-
- /* check all allowed remote number's for this entry */
-
- for (n = 0; n < cep->incoming_numbers_count; n++)
- {
- incoming_number_t *in = &cep->remote_phone_incoming[n];
- if(in->number[0] == '*')
- break;
- if(strncmp(in->number, mp->src_telno, strlen(in->number)))
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, remno %s != incomingfromno %s", i,
- in->number, mp->src_telno)));
- }
- else
- break;
- }
- if (n >= cep->incoming_numbers_count)
- continue;
-
- /* screening indicator XXX */
-
- switch(mp->scr_ind)
- {
- case SCR_NONE:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - no screening indicator", mp->src_telno)));
- break;
-
- case SCR_USR_NOSC:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - screening user provided, not screened", mp->src_telno)));
- break;
-
- case SCR_USR_PASS:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - screening user provided, verified & passed", mp->src_telno)));
- break;
-
- case SCR_USR_FAIL:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - screening user provided, verified & failed", mp->src_telno)));
- break;
-
- case SCR_NET:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - screening network provided", mp->src_telno)));
- break;
-
- default:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: ERROR %s - invalid screening indicator!", mp->src_telno)));
- break;
- }
-
- /* check b protocol */
-
- if(cep->b1protocol != mp->bprot)
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, bprot %d != incomingprot %d", i,
- cep->b1protocol, mp->bprot)));
- continue;
- }
-
- /* is this entry currently in use ? */
-
- if(cep->cdid != CDID_UNUSED)
- {
- if(cep->cdid == CDID_RESERVED)
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, cdid is reserved", i)));
- }
- else if (cep->dialin_reaction == REACT_ACCEPT
- && cep->dialouttype == DIALOUT_CALLEDBACK)
- {
- /*
- * We might consider doing this even if this is
- * not a calledback config entry - BUT: there are
- * severe race conditions and timinig problems
- * ex. if both sides run I4B with no callback
- * delay - both may shutdown the outgoing call
- * and never be able to establish a connection.
- * In the called-back case this should not happen.
- */
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, incoming call for callback in progress (cdid %05d)", i, cep->cdid)));
-
- /* save the current call state, we're going to overwrite it with the
- * new incoming state below... */
- cep->saved_call.cdid = cep->cdid;
- cep->saved_call.controller = cep->isdncontrollerused;
- cep->saved_call.channel = cep->isdnchannelused;
- }
- else
- {
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, cdid in use", i)));
- continue; /* yes, next */
- }
- }
-
- /* check controller value ok */
-
- if(mp->controller > ncontroller)
- {
- log(LL_CHD, "%05d %s incoming call with invalid controller %d",
- mp->header.cdid, cep->name, mp->controller);
- return(NULL);
- }
-
- /* check controller marked up */
-
- if((get_controller_state(mp->controller)) != CTRL_UP)
- {
- log(LL_CHD, "%05d %s incoming call, controller %d DOWN!",
- mp->header.cdid, cep->name, mp->controller);
- return(NULL);
- }
-
- /* check channel he wants */
-
- switch(mp->channel)
- {
- case CHAN_B1:
- case CHAN_B2:
- if((ret_channel_state(mp->controller, mp->channel)) != CHAN_IDLE)
- {
- log(LL_CHD, "%05d %s incoming call, channel %s not free!",
- mp->header.cdid, cep->name, mp->channel == CHAN_B1 ? "B1" : "B2");
- return(NULL);
- }
- break;
-
- case CHAN_ANY:
- if(((ret_channel_state(mp->controller, CHAN_B1)) != CHAN_IDLE) &&
- ((ret_channel_state(mp->controller, CHAN_B2)) != CHAN_IDLE))
- {
- log(LL_CHD, "%05d %s incoming call, no channel free!",
- mp->header.cdid, cep->name);
- return(NULL);
- }
- break;
-
- case CHAN_NO:
- log(LL_CHD, "%05d %s incoming call, call waiting (no channel available)!",
- mp->header.cdid, cep->name);
- return(NULL);
- break;
-
- default:
- log(LL_CHD, "%05d %s incoming call, ERROR, channel undefined!",
- mp->header.cdid, cep->name);
- return(NULL);
- break;
- }
-
- /* found a matching entry */
-
- cep->cdid = mp->header.cdid;
- cep->isdncontrollerused = mp->controller;
- cep->isdnchannelused = mp->channel;
-/*XXX*/ cep->disc_cause = 0;
-
- /* cp number to real one used */
-
- strcpy(cep->real_phone_incoming, mp->src_telno);
-
- /* copy display string */
-
- strcpy(cep->display, mp->display);
-
- /* entry currently down ? */
-
- if(cep->state == ST_DOWN)
- {
- msg_updown_ind_t mui;
-
- /* set interface up */
-
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, ", i)));
-
- mui.driver = cep->usrdevicename;
- mui.driver_unit = cep->usrdeviceunit;
- mui.updown = SOFT_ENA;
-
- if((ioctl(isdnfd, I4B_UPDOWN_IND, &mui)) < 0)
- {
- log(LL_ERR, "find_matching_entry_incoming: ioctl I4B_UPDOWN_IND failed: %s", strerror(errno));
- do_exit(1);
- }
-
- cep->down_retry_count = 0;
- cep->state = ST_IDLE;
- }
- return(cep);
- }
-
- if(aliasing)
- {
- src_tela = get_alias(mp->src_telno);
- dst_tela = get_alias(mp->dst_telno);
- }
- log(LL_CHD, /* A number not listed in /etc/isdn/isdnd.rc */
- ( (!aliasing) ?
- "%05d <unknown> incoming call from %s to %s" :
- /* Probably a phone call, likely from someone
- in phone book /etc/isdn/isdntel.alias, so
- avoid looking silly by saying "unknown",
- & allow more space to print names.
- */
- "%05d Call from %s to %s"
- ) ,
- mp->header.cdid, SRC, DST, mp->dst_telno);
-
- return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- * return address of ACTIVE config entry by controller and channel
- *---------------------------------------------------------------------------*/
-cfg_entry_t *
-get_cep_by_cc(int ctrlr, int chan)
-{
- int i;
-
- if((chan != CHAN_B1) && (chan != CHAN_B2))
- return(NULL);
-
- for(i=0; i < nentries; i++)
- {
- if((cfg_entry_tab[i].cdid != CDID_UNUSED) &&
- (cfg_entry_tab[i].cdid != CDID_RESERVED) &&
- (cfg_entry_tab[i].isdnchannelused == chan) &&
- (cfg_entry_tab[i].isdncontrollerused == ctrlr) &&
- ((ret_channel_state(ctrlr, chan)) == CHAN_RUN))
- {
- return(&cfg_entry_tab[i]);
- }
- }
- return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- * return address of config entry identified by cdid
- *---------------------------------------------------------------------------*/
-cfg_entry_t *
-get_cep_by_cdid(int cdid)
-{
- int i;
-
- for(i=0; i < nentries; i++)
- {
- if(cfg_entry_tab[i].cdid == cdid
- || cfg_entry_tab[i].saved_call.cdid == cdid)
- return(&cfg_entry_tab[i]);
- }
- return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- * get name of a controller
- *---------------------------------------------------------------------------*/
-const char *
-name_of_controller(int ctrl_type, int card_type)
-{
- static char *passive_card[] = {
- "Teles S0/8",
- "Teles S0/16",
- "Teles S0/16.3",
- "AVM A1 or Fritz!Card",
- "Teles S0/16.3 PnP",
- "Creatix S0 PnP",
- "USRobotics Sportster ISDN TA",
- "Dr. Neuhaus NICCY Go@",
- "Sedlbauer win speed",
- "Dynalink IS64PH",
- "ISDN Master or Blaster",
- "AVM PCMCIA Fritz!Card",
- "ELSA QuickStep 1000pro/ISA",
- "ELSA QuickStep 1000pro/PCI",
- "Siemens I-Talk",
- "ELSA MicroLink ISDN/MC",
- "ELSA MicroLink MCall",
- "ITK ix1 micro"
- };
- static char *daic_card[] = {
- "EICON.Diehl S",
- "EICON.Diehl SX/SXn",
- "EICON.Diehl SCOM",
- "EICON.Diehl QUADRO",
- };
-
- if (ctrl_type == CTRL_PASSIVE) {
- int index = card_type - CARD_TYPEP_8;
- if (index >= 0 && index < (sizeof passive_card / sizeof passive_card[0]))
- return passive_card[index];
- } else if (ctrl_type == CTRL_DAIC) {
- int index = card_type - CARD_TYPEA_DAIC_S;
- if (index >= 0 && index < (sizeof daic_card / sizeof daic_card[0] ))
- return daic_card[index];
- }
-
- return "unknown card type";
-}
-
-/*---------------------------------------------------------------------------*
- * init controller state array
- *---------------------------------------------------------------------------*/
-void
-init_controller(void)
-{
- int i;
- int max = 1;
- msg_ctrl_info_req_t mcir;
-
- for(i=0; i < max; i++)
- {
- mcir.controller = i;
-
- if((ioctl(isdnfd, I4B_CTRL_INFO_REQ, &mcir)) < 0)
- {
- log(LL_ERR, "init_controller: ioctl I4B_CTRL_INFO_REQ failed: %s", strerror(errno));
- do_exit(1);
- }
-
- if((ncontroller = max = mcir.ncontroller) == 0)
- {
- log(LL_ERR, "init_controller: no ISDN controller found!");
- do_exit(1);
- }
-
- if(mcir.ctrl_type == -1 || mcir.card_type == -1)
- {
- log(LL_ERR, "init_controller: ctrl/card is invalid!");
- do_exit(1);
- }
-
- /* init controller tab */
-
- if((init_controller_state(i, mcir.ctrl_type, mcir.card_type, mcir.tei)) == ERROR)
- {
- log(LL_ERR, "init_controller: init_controller_state for controller %d failed", i);
- do_exit(1);
- }
- }
- log(LL_DMN, "init_controller: found %d ISDN controller(s)", max);
-}
-
-/*---------------------------------------------------------------------------*
- * return b channel driver type name string
- *---------------------------------------------------------------------------*/
-char *
-bdrivername(int drivertype)
-{
- static char *bdtab[] = {
- "rbch",
- "tel",
- "ipr",
- "isp"
- };
-
- if(drivertype >= BDRV_RBCH && drivertype <= BDRV_ISPPP)
- return(bdtab[drivertype]);
- else
- return("unknown");
-}
-
-/*---------------------------------------------------------------------------*
- * process AOCD charging messages
- *---------------------------------------------------------------------------*/
-void
-handle_charge(cfg_entry_t *cep)
-{
- time_t now = time(NULL);
-
- if(cep->aoc_last == 0) /* no last timestamp yet ? */
- {
- cep->aoc_last = now; /* add time stamp */
- }
- else if(cep->aoc_now == 0) /* no current timestamp yet ? */
- {
- cep->aoc_now = now; /* current timestamp */
- }
- else
- {
- cep->aoc_last = cep->aoc_now;
- cep->aoc_now = now;
- cep->aoc_diff = cep->aoc_now - cep->aoc_last;
- cep->aoc_valid = AOC_VALID;
- }
-
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_charge(cep);
-#endif
-
-#ifdef I4B_EXTERNAL_MONITOR
- if(do_monitor && accepted)
- monitor_evnt_charge(cep, cep->charge, 0);
-#endif
-
- if(cep->aoc_valid == AOC_VALID)
- {
- if(cep->aoc_diff != cep->unitlength)
- {
- DBGL(DL_MSG, (log(LL_DBG, "handle_charge: AOCD unit length updated %d -> %d secs", cep->unitlength, cep->aoc_diff)));
-
- cep->unitlength = cep->aoc_diff;
-
- unitlen_chkupd(cep);
- }
- else
- {
-#ifdef NOTDEF
- DBGL(DL_MSG, (log(LL_DBG, "handle_charge: AOCD unit length still %d secs", cep->unitlength)));
-#endif
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-void
-unitlen_chkupd(cfg_entry_t *cep)
-{
- msg_timeout_upd_t tupd;
-
-/* XXX check if the values are possible, if not, adjust them */
-
- tupd.cdid = cep->cdid;
- tupd.unitlen_time = cep->unitlength;
- tupd.idle_time = cep->idle_time_out;
- tupd.earlyhup_time = cep->earlyhangup;
-
- if((ioctl(isdnfd, I4B_TIMEOUT_UPD, &tupd)) < 0)
- {
- log(LL_ERR, "ioctl I4B_TIMEOUT_UPD failed: %s", strerror(errno));
- do_exit(1);
- }
-}
-
-/*--------------------------------------------------------------------------*
- * this is intended to be called by do_exit and closes down all
- * active connections before the daemon exits or is reconfigured.
- *--------------------------------------------------------------------------*/
-void
-close_allactive(void)
-{
- int i, j;
- cfg_entry_t *cep = NULL;
-
- j = 0;
-
- for (i = 0; i < ncontroller; i++)
- {
- if((get_controller_state(i)) != CTRL_UP)
- continue;
-
- if((ret_channel_state(i, CHAN_B1)) == CHAN_RUN)
- {
- if((cep = get_cep_by_cc(i, CHAN_B1)) != NULL)
- {
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_disconnect(cep);
-#endif
-#ifdef I4B_EXTERNAL_MONITOR
- monitor_evnt_disconnect(cep);
-#endif
- next_state(cep, EV_DRQ);
- j++;
- }
- }
-
- if((ret_channel_state(i, CHAN_B2)) == CHAN_RUN)
- {
- if((cep = get_cep_by_cc(i, CHAN_B2)) != NULL)
- {
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_disconnect(cep);
-#endif
-#ifdef I4B_EXTERNAL_MONITOR
- monitor_evnt_disconnect(cep);
-#endif
- next_state(cep, EV_DRQ);
- j++;
- }
- }
- }
-
- if(j)
- {
- log(LL_DMN, "close_allactive: waiting for all connections terminated");
- sleep(5);
- }
-}
-
-/*--------------------------------------------------------------------------*
- * set an interface up
- *--------------------------------------------------------------------------*/
-void
-if_up(cfg_entry_t *cep)
-{
- msg_updown_ind_t mui;
-
- /* set interface up */
-
- DBGL(DL_MSG, (log(LL_DBG, "if_up: taking %s%d up", bdrivername(cep->usrdevicename), cep->usrdeviceunit)));
-
- mui.driver = cep->usrdevicename;
- mui.driver_unit = cep->usrdeviceunit;
- mui.updown = SOFT_ENA;
-
- if((ioctl(isdnfd, I4B_UPDOWN_IND, &mui)) < 0)
- {
- log(LL_ERR, "if_up: ioctl I4B_UPDOWN_IND failed: %s", strerror(errno));
- do_exit(1);
- }
- cep->down_retry_count = 0;
-
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_updown(cep, 1);
-#endif
-#ifdef I4B_EXTERNAL_MONITOR
- monitor_evnt_updown(cep, 1);
-#endif
-
-}
-
-/*--------------------------------------------------------------------------*
- * set an interface down
- *--------------------------------------------------------------------------*/
-void
-if_down(cfg_entry_t *cep)
-{
- msg_updown_ind_t mui;
-
- /* set interface up */
-
- DBGL(DL_MSG, (log(LL_DBG, "if_down: taking %s%d down", bdrivername(cep->usrdevicename), cep->usrdeviceunit)));
-
- mui.driver = cep->usrdevicename;
- mui.driver_unit = cep->usrdeviceunit;
- mui.updown = SOFT_DIS;
-
- if((ioctl(isdnfd, I4B_UPDOWN_IND, &mui)) < 0)
- {
- log(LL_ERR, "if_down: ioctl I4B_UPDOWN_IND failed: %s", strerror(errno));
- do_exit(1);
- }
- cep->went_down_time = time(NULL);
- cep->down_retry_count = 0;
-
-#ifdef USE_CURSES
- if(do_fullscreen)
- display_updown(cep, 0);
-#endif
-#ifdef I4B_EXTERNAL_MONITOR
- monitor_evnt_updown(cep, 0);
-#endif
-
-}
-
-/*--------------------------------------------------------------------------*
- * send a dial response to (an interface in) the kernel
- *--------------------------------------------------------------------------*/
-void
-dialresponse(cfg_entry_t *cep, int dstat)
-{
- msg_dialout_resp_t mdr;
-
- static char *stattab[] = {
- "normal condition",
- "temporary failure",
- "permanent failure",
- "dialout not allowed"
- };
-
- if(dstat < DSTAT_NONE || dstat > DSTAT_INONLY)
- {
- log(LL_ERR, "dialresponse: dstat out of range %d!", dstat);
- return;
- }
-
- mdr.driver = cep->usrdevicename;
- mdr.driver_unit = cep->usrdeviceunit;
- mdr.stat = dstat;
-
- if((ioctl(isdnfd, I4B_DIALOUT_RESP, &mdr)) < 0)
- {
- log(LL_ERR, "dialresponse: ioctl I4B_DIALOUT_RESP failed: %s", strerror(errno));
- do_exit(1);
- }
-
- DBGL(DL_DRVR, (log(LL_DBG, "dialresponse: sent [%s]", stattab[dstat])));
-}
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdnd/timer.c b/usr.sbin/i4b/isdnd/timer.c
deleted file mode 100644
index 5534efe70210..000000000000
--- a/usr.sbin/i4b/isdnd/timer.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - timer/timing support routines
- * ------------------------------------------
- *
- * $Id: timer.c,v 1.16 1998/12/05 18:03:43 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:13:10 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "isdnd.h"
-
-static int hr_callgate(void);
-static void handle_reserved(cfg_entry_t *cep, time_t now);
-static void handle_active(cfg_entry_t *cep, time_t now);
-static void recover_illegal(cfg_entry_t *cep);
-
-/*---------------------------------------------------------------------------*
- * recover from illegal state
- *---------------------------------------------------------------------------*/
-static void
-recover_illegal(cfg_entry_t *cep)
-{
- log(LL_ERR, "recover_illegal: ERROR, entry %s attempting disconnect!", cep->name);
- sendm_disconnect_req(cep, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- log(LL_ERR, "recover_illegal: ERROR, entry %s - reset state/cdid!", cep->name);
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
-}
-
-/*---------------------------------------------------------------------------*
- * start the timer
- *---------------------------------------------------------------------------*/
-void
-start_timer(cfg_entry_t *cep, int seconds)
-{
- cep->timerval = cep->timerremain = seconds;
-}
-
-/*---------------------------------------------------------------------------*
- * stop the timer
- *---------------------------------------------------------------------------*/
-void
-stop_timer(cfg_entry_t *cep)
-{
- cep->timerval = cep->timerremain = 0;
-}
-
-/*---------------------------------------------------------------------------*
- * callgate for handle_recovery()
- *---------------------------------------------------------------------------*/
-static int
-hr_callgate(void)
-{
- static int tv_first = 1;
- static struct timeval tv_last;
- struct timeval tv_now;
-
- /* there must be 1 sec minimum between calls to this section */
-
- if(tv_first)
- {
- gettimeofday(&tv_last, NULL);
- tv_first = 0;
- }
-
- gettimeofday(&tv_now, NULL);
-
- if((tv_now.tv_sec - tv_last.tv_sec) < 1)
- {
-
- DBGL(DL_TIME, (log(LL_DBG, "time < 1 - last %ld:%ld now %ld:%ld",
- tv_last.tv_sec, tv_last.tv_usec,
- tv_now.tv_sec, tv_now.tv_usec)));
- return(1);
- }
- else if((tv_now.tv_sec - tv_last.tv_sec) == 1)
- {
- if(((1000000 - tv_last.tv_usec) + tv_now.tv_usec) < 900000)
- {
- DBGL(DL_TIME, (log(LL_DBG, "time < 900000us - last %ld:%ld now %ld:%ld",
- tv_last.tv_sec, tv_last.tv_usec,
- tv_now.tv_sec, tv_now.tv_usec)));
- return(1);
- }
- }
-
- DBGL(DL_TIME, (log(LL_DBG, "time OK! - last %ld:%ld now %ld:%ld",
- tv_last.tv_sec, tv_last.tv_usec,
- tv_now.tv_sec, tv_now.tv_usec)));
-
- gettimeofday(&tv_last, NULL);
-
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * timeout, recovery and retry handling
- *---------------------------------------------------------------------------*/
-void
-handle_recovery(void)
-{
- cfg_entry_t *cep = NULL;
- int i;
- time_t now;
-
- if(hr_callgate()) /* last call to handle_recovery < 1 sec ? */
- return; /* yes, exit */
-
- now = time(NULL); /* get current time */
-
- /* walk thru all entries, look for work to do */
-
- for(i=0; i < nentries; i++)
- {
- cep = &cfg_entry_tab[i]; /* ptr to config entry */
-
- switch(cep->cdid)
- {
- case CDID_UNUSED: /* entry unused */
- continue;
- break;
-
- case CDID_RESERVED: /* entry reserved */
- handle_reserved(cep, now);
- break;
-
- default: /* entry in use */
- handle_active(cep, now);
- break;
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * timeout, recovery and retry handling for active entry
- *---------------------------------------------------------------------------*/
-static void
-handle_active(cfg_entry_t *cep, time_t now)
-{
- switch(cep->state)
- {
- case ST_ACCEPTED:
- if(cep->timerval && (--(cep->timerremain)) <= 0)
- {
- DBGL(DL_RCVRY, (log(LL_DBG, "handle_active: entry %s, TIMEOUT !!!", cep->name)));
- cep->timerval = cep->timerremain = 0;
- next_state(cep, EV_TIMO);
- }
- break;
-
- case ST_ALERT:
- if(cep->alert_time > 0)
- {
- cep->alert_time--;
- }
- else
- {
- log(LL_CHD, "%05d %s answering: incoming call from %s to %s",
- cep->cdid, cep->name,
- cep->real_phone_incoming,
- cep->local_phone_incoming);
- next_state(cep, EV_MCI);
- }
- break;
-
- case ST_ILL:
- recover_illegal(cep);
- break;
-
- default:
- /* check hangup flag: if active, close connection */
-
- if(cep->hangup)
- {
- DBGL(DL_RCVRY, (log(LL_DBG, "handle_active: entry %s, hangup request!", cep->name)));
- cep->hangup = 0;
- next_state(cep, EV_DRQ);
- }
-
- /*
- * if shorthold mode is rates based, check if
- * we entered a time with a new unit length
- */
-
- if(cep->unitlengthsrc == ULSRC_RATE)
- {
- int connecttime = (int)difftime(now, cep->connect_time);
-
- if((connecttime > 1) &&
- (connecttime % 60))
- {
- int newrate = get_current_rate(cep, 0);
-
- if(newrate != cep->unitlength)
- {
- DBGL(DL_MSG, (log(LL_DBG, "handle_active: rates unit length updated %d -> %d", cep->unitlength, newrate)));
-
- cep->unitlength = newrate;
-
- unitlen_chkupd(cep);
- }
- }
- }
- break;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * timeout, recovery and retry handling for reserved entry
- *---------------------------------------------------------------------------*/
-static void
-handle_reserved(cfg_entry_t *cep, time_t now)
-{
- time_t waittime;
-
- switch(cep->state)
- {
- case ST_DIALRTMRCHD: /* wait for dial retry time reached */
-
- if(cep->dialrandincr)
- waittime = cep->randomtime;
- else
- waittime = cep->recoverytime;
-
-
- if(now > (cep->last_dial_time + waittime))
- {
- DBGL(DL_RCVRY, (log(LL_DBG, "handle_reserved: entry %s, dial retry request!", cep->name)));
- cep->state = ST_DIALRETRY;
-
- if((cep->cdid = get_cdid()) == 0)
- {
- log(LL_ERR, "handle_reserved: dialretry get_cdid() returned 0!");
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- return;
- }
-
- if((setup_dialout(cep)) == GOOD)
- {
- sendm_connect_req(cep);
- }
- else
- {
- log(LL_ERR, "handle_reserved: dialretry setup_dialout returned ERROR!");
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- return;
- }
- }
- break;
-
-
- case ST_ACB_WAITDIAL: /* active callback wait for time between disconnect and dial */
-
- if(now > (cep->last_release_time + cep->callbackwait))
- {
- DBGL(DL_RCVRY, (log(LL_DBG, "handle_reserved: entry %s, callback dial!", cep->name)));
- cep->state = ST_ACB_DIAL;
-
- if((cep->cdid = get_cdid()) == 0)
- {
- log(LL_ERR, "handle_reserved: callback get_cdid() returned 0!");
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- return;
- }
-
- select_first_dialno(cep);
-
- if((setup_dialout(cep)) == GOOD)
- {
- sendm_connect_req(cep);
- }
- else
- {
- log(LL_ERR, "handle_reserved: callback setup_dialout returned ERROR!");
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- return;
- }
- }
- break;
-
- case ST_ACB_DIALFAIL: /* callback to remote failed */
-
- if(cep->dialrandincr)
- waittime = cep->randomtime + cep->recoverytime;
- else
- waittime = cep->recoverytime;
-
- if(now > (cep->last_release_time + waittime))
- {
- DBGL(DL_RCVRY, (log(LL_DBG, "handle_reserved: entry %s, callback dial retry request!", cep->name)));
- cep->state = ST_ACB_DIAL;
-
- if((cep->cdid = get_cdid()) == 0)
- {
- log(LL_ERR, "handle_reserved: callback dialretry get_cdid() returned 0!");
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- return;
- }
-
- if((setup_dialout(cep)) == GOOD)
- {
- sendm_connect_req(cep);
- }
- else
- {
- log(LL_ERR, "handle_reserved: callback dialretry setup_dialout returned ERROR!");
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- return;
- }
- }
- break;
-
- case ST_PCB_WAITCALL: /* wait for remote calling back */
-
- if(now > (cep->last_release_time + cep->calledbackwait))
- {
- cep->dial_count++;
-
- if(cep->dial_count < cep->dialretries)
- {
- /* inside normal retry cycle */
-
- DBGL(DL_RCVRY, (log(LL_DBG, "handle_reserved: entry %s, retry calledback dial #%d!",
- cep->name, cep->dial_count)));
- cep->state = ST_PCB_DIAL;
-
- if((cep->cdid = get_cdid()) == 0)
- {
- log(LL_ERR, "handle_reserved: calledback get_cdid() returned 0!");
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- return;
- }
- select_next_dialno(cep);
-
- if((setup_dialout(cep)) == GOOD)
- {
- sendm_connect_req(cep);
- }
- else
- {
- log(LL_ERR, "handle_reserved: calledback setup_dialout returned ERROR!");
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- return;
- }
- }
- else
- {
- /* retries exhausted */
-
- DBGL(DL_RCVRY, (log(LL_DBG, "handle_reserved: calledback dial retries exhausted")));
- dialresponse(cep, DSTAT_TFAIL);
- cep->cdid = CDID_UNUSED;
- cep->dial_count = 0;
- cep->state = ST_IDLE;
- }
- }
- break;
-
- case ST_DOWN: /* interface was taken down */
-
- if(now > (cep->went_down_time + cep->downtime))
- {
- DBGL(DL_RCVRY, (log(LL_DBG, "handle_reserved: taking %s%d up", bdrivername(cep->usrdevicename), cep->usrdeviceunit)));
- if_up(cep);
- cep->state = ST_IDLE;
- cep->cdid = CDID_UNUSED;
- }
- break;
-
- case ST_ILL: /* illegal state reached, recover ! */
-
- recover_illegal(cep);
- break;
- }
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnd/vararray.h b/usr.sbin/i4b/isdnd/vararray.h
deleted file mode 100644
index c71f816ef9ea..000000000000
--- a/usr.sbin/i4b/isdnd/vararray.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Martin Husemann <martin@rumolt.teuto.de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- * derived from this software withough specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * vararray.h: basic collection macros for variable sized (growing) arrays:
- * macro version of popular C++ template classes,
- * not as elegant in use as the template version,
- * but has maximum runtime performance and can give
- * pointers to array contents (i.e. for ioctl's).
- * Works in C as well as in C++.
- * CAVEAT: in C++ only useable for aggregateable objects,
- * it does use memcpy instead of copy constructors!
- */
-
-#ifndef VARARRAY_H
-#define VARARRAY_H
-/* declare a variable sized array, element type is t */
-#define VARA_DECL(t) struct { int used, allocated; t *data; }
-
-/* aggregate initializer for a variable array */
-#define VARA_INITIALIZER { 0, 0, NULL }
-
-/* free all allocated storage */
-#define VARA_FREE(a) { if ((a).data != NULL) free((a).data); \
- (a).allocated = 0; (a).used = 0; }
-
-/* number of elments currently in array*/
-#define VARA_NUM(a) ((a).used)
-
-/* number of elements already allocated in array */
-#define VARA_ALLOCATED(a) ((a).allocated)
-
-/* pointer to array data */
-#define VARA_PTR(a) ((a).data)
-
-/* empty the array */
-#define VARA_EMPTY(a) { (a).used = 0; }
-
-#ifdef __cplusplus
-#define VARA_NEW(t,c) new t[c]
-#define VARA_DELETE(p) delete [] p
-#else
-#define VARA_NEW(t,c) (t*)malloc(sizeof(t)*(c))
-#define VARA_DELETE(p) free(p)
-#endif
-
-/* add an element (not changing any data).
- * a is the array, i the index,
- * t the element type and n the initial allocation */
-#define VARA_ADD_AT(a,i,t,n) \
-{ \
- if ((i) >= (a).allocated) { \
- int new_alloc = (a).allocated ? (a).allocated*2 : (n); \
- t *new_data; \
- if (new_alloc <= (i)) new_alloc = (i)+1; \
- new_data = VARA_NEW(t, new_alloc); \
- if ((a).data) { \
- memcpy(new_data, (a).data, (a).used*sizeof(t)); \
- VARA_DELETE((a).data); \
- } \
- (a).data = new_data; \
- (a).allocated = new_alloc; \
- } \
- if ((i) >= (a).used) { \
- if (i > (a).used) \
- memset(&((a).data[(a).used]), 0, \
- sizeof(t)*((i)-(a).used+1)); \
- (a).used = (i)+1; \
- } \
-}
-
-/* return an l-value at index i */
-#define VARA_AT(a,i) ((a).data[(i)])
-
-/* iterate through the array */
-#define VARA_FOREACH(a,i) for ((i) = 0; (i) < (a).used; (i)++)
-
-/* check for a valid index */
-#define VARA_VALID(a,i) ((i) >= 0 && (i) < (a).used)
-
-/* remove one entry */
-#define VARA_REMOVEAT(a,i) \
-{ \
- if ((i) < ((a).used -1)) \
- memmove(&((a).data[(i)]), &((a).data[(i)+1]), sizeof((a).data[0])); \
- (a).used--; \
-}
-
-/* free all storage allocated for the array */
-#define VARA_DESTROY(a) \
-{ \
- if ((a).data) VARA_DELETE((a).data); \
- (a).allocated = 0; \
- (a).used = 0; \
- (a).data = NULL; \
-}
-
-#endif
-
diff --git a/usr.sbin/i4b/isdndebug/Makefile b/usr.sbin/i4b/isdndebug/Makefile
deleted file mode 100644
index cf5281871439..000000000000
--- a/usr.sbin/i4b/isdndebug/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-PROG = isdndebug
-SRCS = main.c
-MAN8 = isdndebug.8
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/i4b/isdndebug/isdndebug.8 b/usr.sbin/i4b/isdndebug/isdndebug.8
deleted file mode 100644
index f3903e38b4d3..000000000000
--- a/usr.sbin/i4b/isdndebug/isdndebug.8
+++ /dev/null
@@ -1,102 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdndebug.8,v 1.4 1998/12/05 18:03:47 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:13:34 1998]
-.\"
-.\" -hm writing manual pages
-.\" -hm getting uptodate
-.\"
-.\"
-.Dd July 9, 1998
-.Dt isdndebug 8
-.Sh NAME
-.Nm isdndebug
-.Nd control debugging handling inside isdn4bsd kernel
-.Sh SYNOPSIS
-.Nm
-.Op Fl e
-.Op Fl g
-.Op Fl h
-.Op Fl l Ar layer
-.Op Fl m
-.Op Fl r
-.Op Fl s Ar value
-.Op Fl u Ar unit
-.Op Fl z
-.Op Fl H
-.Sh DESCRIPTION
-.Nm isdndebug
-is part of the isdn4bsd package and is used to control debugging output
-of the isdn4bsd kernel part. Every layer of the isdn4bsd kernel uses a
-debugging mask which can be manipulated using this utility.
-.Pp
-A second usage of
-.Nm
-is to display and reset the HSCX error counters.
-.Pp
-The following options are available:
-.Bl -tag -width Ds
-.It Fl e
-Set debugging mask for the selected layer(s) to display errors only.
-.It Fl g
-Get the debugging mask for the selected layer(s).
-.It Fl h
-Display the the HSCX error counters.
-.It Fl l
-Specify the layer for which a command applies. Default is all layers.
-.It Fl m
-Set debugging mask for the selected layer(s) to display all possible
-debugging messages (maximum output).
-.It Fl r
-Set debugging mask for the selected layer(s) to the compiled in default
-(reset).
-.It Fl s
-Set debugging mask for the selected layer(s) to value. Value can be
-specified in any number base supported by
-.Xr sscanf 3 .
-.It Fl u
-Set the unit numbers for the -h and -H flags.
-.It Fl z
-Set debugging mask for the selected layer(s) to no output at all (zero).
-.It Fl H
-Reset the HSCX error counters to zero.
-.Pp
-.Sh FILES
-/dev/i4bctl
-
-.Sh EXAMPLES
-The command:
-.Bd -literal -offset indent
-isdndebug -g
-.Ed
-.Pp
-displays the current debugging level for all ISDN layers
-
-.Sh AUTHOR
-The
-.Nm
-utility and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/isdndebug/main.c b/usr.sbin/i4b/isdndebug/main.c
deleted file mode 100644
index 7fdbf7fe1bfe..000000000000
--- a/usr.sbin/i4b/isdndebug/main.c
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * main.c - i4b set debug options
- * ------------------------------
- *
- * $Id: main.c,v 1.13 1998/12/05 18:03:49 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:13:55 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-
-char *bin_str(unsigned long val, int length);
-
-static void usage ( void );
-void printl1(unsigned long val);
-void printl2(unsigned long val);
-void printl3(unsigned long val);
-void printl4(unsigned long val);
-
-static int isdnfd;
-
-#define I4BCTLDEVICE "/dev/i4bctl"
-
-int opt_get = 0;
-int opt_layer = -1;
-int opt_set = 0;
-int opt_setval;
-int opt_reset = 0;
-int opt_max = 0;
-int opt_err = 0;
-int opt_zero = 0;
-int opt_unit = 0;
-int opt_hscx = 0;
-int opt_rhscx = 0;
-
-/*---------------------------------------------------------------------------*
- * program entry
- *---------------------------------------------------------------------------*/
-int
-main(int argc, char **argv)
-{
- int c;
- ctl_debug_t cdbg;
- int ret;
-
- while ((c = getopt(argc, argv, "eghl:mrs:u:zH?")) != EOF)
- {
- switch(c)
- {
- case 'e':
- opt_err = 1;
- break;
-
- case 'g':
- opt_get = 1;
- break;
-
- case 'h':
- opt_hscx = 1;
- break;
-
- case 'r':
- opt_reset = 1;
- break;
-
- case 'm':
- opt_max = 1;
- break;
-
- case 'l':
- opt_layer = atoi(optarg);
- if(opt_layer < 1 || opt_layer > 4)
- usage();
- break;
-
- case 's':
- if((sscanf(optarg, "%i", &opt_setval)) != 1)
- usage();
- opt_set = 1;
- break;
-
- case 'u':
- opt_unit = atoi(optarg);
- if(opt_unit < 0 || opt_unit > 9)
- usage();
- break;
-
- case 'z':
- opt_zero = 1;
- break;
-
- case 'H':
- opt_rhscx = 1;
- break;
-
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if(opt_get == 0 && opt_set == 0 && opt_reset == 0 && opt_max == 0 &&
- opt_err == 0 && opt_zero == 0 && opt_hscx == 0 && opt_rhscx == 0)
- {
- usage();
- }
-
- if((opt_get + opt_set + opt_reset + opt_max + opt_err + opt_zero +
- opt_hscx + opt_rhscx) > 1)
- {
- usage();
- }
-
- if((isdnfd = open(I4BCTLDEVICE, O_RDWR)) < 0)
- {
- fprintf(stderr, "i4bctl: cannot open %s: %s\n", I4BCTLDEVICE, strerror(errno));
- exit(1);
- }
-
- if(opt_hscx)
- {
- hscxstat_t hst;
-
- hst.unit = opt_unit;
- hst.chan = 0;
-
- if((ret = ioctl(isdnfd, I4B_CTL_GET_HSCXSTAT, &hst)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CTL_GET_HSCXSTAT failed: %s", strerror(errno));
- exit(1);
- }
-
- printf("\nHSCX events: VFR RDO CRC RAB XDU RFO\n");
-
- printf("unit %d chan %d: %6d %6d %6d %6d %6d %6d\n",
- hst.unit, hst.chan,
- hst.vfr, hst.rdo, hst.crc, hst.rab, hst.xdu, hst.rfo);
-
- hst.unit = opt_unit;
- hst.chan = 1;
-
- if((ret = ioctl(isdnfd, I4B_CTL_GET_HSCXSTAT, &hst)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CTL_GET_HSCXSTAT failed: %s", strerror(errno));
- exit(1);
- }
-
- printf("unit %d chan %d: %6d %6d %6d %6d %6d %6d\n",
- hst.unit, hst.chan,
- hst.vfr, hst.rdo, hst.crc, hst.rab, hst.xdu, hst.rfo);
-
- exit(0);
- }
-
- if(opt_rhscx)
- {
- hscxstat_t hst;
-
- hst.unit = opt_unit;
- hst.chan = 0;
-
- if((ret = ioctl(isdnfd, I4B_CTL_CLR_HSCXSTAT, &hst)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CTL_CLR_HSCXSTAT failed: %s", strerror(errno));
- exit(1);
- }
-
- printf("HSCX event counters unit %d chan %d reset to zero!\n",
- hst.unit, hst.chan);
-
- hst.unit = opt_unit;
- hst.chan = 1;
-
- if((ret = ioctl(isdnfd, I4B_CTL_CLR_HSCXSTAT, &hst)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CTL_CLR_HSCXSTAT failed: %s", strerror(errno));
- exit(1);
- }
-
- printf("HSCX event counters unit %d chan %d reset to zero!\n",
- hst.unit, hst.chan);
-
- exit(0);
- }
-
- if((ret = ioctl(isdnfd, I4B_CTL_GET_DEBUG, &cdbg)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CTL_GET_DEBUG failed: %s", strerror(errno));
- exit(1);
- }
-
- if(opt_get)
- {
- switch(opt_layer)
- {
- case -1:
- printl1(cdbg.l1);
- printl2(cdbg.l2);
- printl3(cdbg.l3);
- printl4(cdbg.l4);
- break;
-
- case 1:
- printl1(cdbg.l1);
- break;
-
- case 2:
- printl2(cdbg.l2);
- break;
-
- case 3:
- printl3(cdbg.l3);
- break;
-
- case 4:
- printl4(cdbg.l4);
- break;
- }
- printf("\n");
- return(0);
- }
- else if(opt_set)
- {
- switch(opt_layer)
- {
- case -1:
- usage();
- break;
-
- case 1:
- cdbg.l1 = opt_setval;
- break;
-
- case 2:
- cdbg.l2 = opt_setval;
- break;
-
- case 3:
- cdbg.l3 = opt_setval;
- break;
-
- case 4:
- cdbg.l4 = opt_setval;
- break;
- }
- }
- else if(opt_reset)
- {
- switch(opt_layer)
- {
- case -1:
- cdbg.l1 = L1_DEBUG_DEFAULT;
- cdbg.l2 = L2_DEBUG_DEFAULT;
- cdbg.l3 = L3_DEBUG_DEFAULT;
- cdbg.l4 = L4_DEBUG_DEFAULT;
- break;
-
- case 1:
- cdbg.l1 = L1_DEBUG_DEFAULT;
- break;
-
- case 2:
- cdbg.l2 = L2_DEBUG_DEFAULT;
- break;
-
- case 3:
- cdbg.l3 = L3_DEBUG_DEFAULT;
- break;
-
- case 4:
- cdbg.l4 = L4_DEBUG_DEFAULT;
- break;
- }
- }
- else if(opt_max)
- {
- switch(opt_layer)
- {
- case -1:
- cdbg.l1 = L1_DEBUG_MAX;
- cdbg.l2 = L2_DEBUG_MAX;
- cdbg.l3 = L3_DEBUG_MAX;
- cdbg.l4 = L4_DEBUG_MAX;
- break;
-
- case 1:
- cdbg.l1 = L1_DEBUG_MAX;
- break;
-
- case 2:
- cdbg.l2 = L2_DEBUG_MAX;
- break;
-
- case 3:
- cdbg.l3 = L3_DEBUG_MAX;
- break;
-
- case 4:
- cdbg.l4 = L4_DEBUG_MAX;
- break;
- }
- }
- else if(opt_err)
- {
- switch(opt_layer)
- {
- case -1:
- cdbg.l1 = L1_DEBUG_ERR;
- cdbg.l2 = L2_DEBUG_ERR;
- cdbg.l3 = L3_DEBUG_ERR;
- cdbg.l4 = L4_DEBUG_ERR;
- break;
-
- case 1:
- cdbg.l1 = L1_DEBUG_ERR;
- break;
-
- case 2:
- cdbg.l2 = L2_DEBUG_ERR;
- break;
-
- case 3:
- cdbg.l3 = L3_DEBUG_ERR;
- break;
-
- case 4:
- cdbg.l4 = L4_DEBUG_ERR;
- break;
- }
- }
- else if(opt_zero)
- {
- switch(opt_layer)
- {
- case -1:
- cdbg.l1 = 0;
- cdbg.l2 = 0;
- cdbg.l3 = 0;
- cdbg.l4 = 0;
- break;
-
- case 1:
- cdbg.l1 = 0;
- break;
-
- case 2:
- cdbg.l2 = 0;
- break;
-
- case 3:
- cdbg.l3 = 0;
- break;
-
- case 4:
- cdbg.l4 = 0;
- break;
- }
- }
- else
- {
- exit(1);
- }
-
- if((ret = ioctl(isdnfd, I4B_CTL_SET_DEBUG, &cdbg)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CTL_SET_DEBUG failed: %s", strerror(errno));
- exit(1);
- }
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * return ptr to string of 1's and 0's for value
- *---------------------------------------------------------------------------*/
-char *
-bin_str(unsigned long val, int length)
-{
- static char buffer[80];
- int i = 0;
-
- if (length > 32)
- length = 32;
-
- val = val << (32 - length);
-
- while (length--)
- {
- if (val & 0x80000000)
- buffer[i++] = '1';
- else
- buffer[i++] = '0';
- if ((length % 4) == 0 && length)
- buffer[i++] = '.';
- val = val << 1;
- }
- return (buffer);
-}
-
-/*---------------------------------------------------------------------------*
- * print l1 info
- *---------------------------------------------------------------------------*/
-void
-printl1(unsigned long val)
-{
- printf("\nLayer 1: %s = 0x%lX\n", bin_str(val, 32), val);
- printf(" || |||| |||| ||||\n"),
- printf(" || |||| |||| |||+- general error messages\n");
- printf(" || |||| |||| ||+-- PH primitives exchanged\n");
- printf(" || |||| |||| |+--- B channel actions\n");
- printf(" || |||| |||| +---- HSCX error messages\n");
- printf(" || |||| |||+------ HSCX IRQ messages\n");
- printf(" || |||| ||+------- ISAC error messages\n");
- printf(" || |||| |+-------- ISAC messages\n");
- printf(" || |||| +--------- ISAC setup messages\n");
- printf(" || |||+----------- FSM general messages\n");
- printf(" || ||+------------ FSM error messages\n");
- printf(" || |+------------- timer general messages\n");
- printf(" || +-------------- timer error messages\n");
- printf(" |+---------------- HSCX data xfer errors msgs\n");
- printf(" +----------------- ISAC CICO messages\n");
- printf(" ++++-++++-++++-++++-++------------------ unassigned\n");
-}
-
-/*---------------------------------------------------------------------------*
- * print l2 info
- *---------------------------------------------------------------------------*/
-void
-printl2(unsigned long val)
-{
- printf("\nLayer 2: %s = 0x%lX\n", bin_str(val, 32), val);
- printf(" || |||| |||| ||||\n"),
- printf(" || |||| |||| |||+- general error messages\n");
- printf(" || |||| |||| ||+-- DL primitives exchanged\n");
- printf(" || |||| |||| |+--- U frame messages\n");
- printf(" || |||| |||| +---- U frame error messages\n");
- printf(" || |||| |||+------ S frame messages\n");
- printf(" || |||| ||+------- S frame error messages\n");
- printf(" || |||| |+-------- I frame messages\n");
- printf(" || |||| +--------- I frame error messages\n");
- printf(" || |||+----------- FSM general messages\n");
- printf(" || ||+------------ FSM error messages\n");
- printf(" || |+------------- timer general messages\n");
- printf(" || +-------------- timer error messages\n");
- printf(" |+---------------- TEI general messages\n");
- printf(" +----------------- TEI error messages\n");
- printf(" ++++-++++-++++-++++-++------------------ unassigned\n");
-}
-
-/*---------------------------------------------------------------------------*
- * print l3 info
- *---------------------------------------------------------------------------*/
-void
-printl3(unsigned long val)
-{
- printf("\nLayer 3: %s = 0x%lX\n", bin_str(val, 32), val);
- printf(" ||| |||| ||||\n"),
- printf(" ||| |||| |||+- general error messages\n");
- printf(" ||| |||| ||+-- general messages\n");
- printf(" ||| |||| |+--- FSM messages\n");
- printf(" ||| |||| +---- FSM error messages\n");
- printf(" ||| |||+------ timer messages\n");
- printf(" ||| ||+------- timer error messages\n");
- printf(" ||| |+-------- protocol messages\n");
- printf(" ||| +--------- protocol error messages\n");
- printf(" ||+----------- facility messages\n");
- printf(" |+------------ facility error messages\n");
- printf(" +------------- Q.931 messages exchanged\n");
- printf(" ++++-++++-++++-++++-++++-++------------- unassigned\n");
-}
-
-/*---------------------------------------------------------------------------*
- * print l4 info
- *---------------------------------------------------------------------------*/
-void
-printl4(unsigned long val)
-{
- printf("\nLayer 4: %s = 0x%lX\n", bin_str(val, 32), val);
- printf(" || ||||\n"),
- printf(" || |||+- general error messages\n");
- printf(" || ||+-- general messages\n");
- printf(" || |+--- B-ch timeout messages\n");
- printf(" || +---- network driver dial state\n");
- printf(" |+------ ipr driver debug messages\n");
- printf(" +------- rbch driver debug messages\n");
- printf(" ++++-++++-++++-++++-++++-++++-++-------- unassigned\n");
-}
-
-/*---------------------------------------------------------------------------*
- * usage display and exit
- *---------------------------------------------------------------------------*/
-static void
-usage(void)
-{
- fprintf(stderr, "\n");
- fprintf(stderr, "isdndebug - i4b set debug level, version %02d.%02d, compiled %s %s\n", VERSION, REL, __DATE__, __TIME__);
- fprintf(stderr, "usage: isdndebug -e -h -g -l <layer> -m -r -s <value> -u <unit> -z -H\n");
- fprintf(stderr, " -e set error only debugging output\n");
- fprintf(stderr, " -g get current debugging values\n");
- fprintf(stderr, " -h get HSCX event counters\n");
- fprintf(stderr, " -l layer specify layer (1...4)\n");
- fprintf(stderr, " -m set maximum debugging output\n");
- fprintf(stderr, " -r reset values(s) to compiled in default\n");
- fprintf(stderr, " -s value set new debugging value for layer\n");
- fprintf(stderr, " -u unit unit number for -h and -H commands\n");
- fprintf(stderr, " -z set zero (=no) debugging output\n");
- fprintf(stderr, " -H reset HSCX event counters to zero\n");
- fprintf(stderr, "\n");
- exit(1);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdndecode/Makefile b/usr.sbin/i4b/isdndecode/Makefile
deleted file mode 100644
index cad9143726a6..000000000000
--- a/usr.sbin/i4b/isdndecode/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-PROG = isdndecode
-SRCS = main.c layer1.c layer2.c layer3.c \
- layer3_subr.c facility.c pcause.c
-MAN8 = isdndecode.8
-
-.include <bsd.prog.mk>
-
diff --git a/usr.sbin/i4b/isdndecode/decode.h b/usr.sbin/i4b/isdndecode/decode.h
deleted file mode 100644
index 0eec0ab90dc9..000000000000
--- a/usr.sbin/i4b/isdndecode/decode.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * decode.h - isdndecode header file
- * ---------------------------------
- *
- * $Id: decode.h,v 1.4 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:10:13 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include "pcause.h"
-
-#define I4BTRC_DEVICE "/dev/i4btrc" /* trace device file */
-#define DECODE_FILE_NAME "isdndecode" /* default output filename */
-#define DECODE_FILE_NAME_BAK ".last" /* backup filename trailer */
-#define BIN_FILE_NAME "isdntracebin" /* default binary filename */
-
-#define BSIZE 4096 /* read buffer size */
-#define NCOLS 80 /* screen width */
-
-#define RxUDEF 0 /* analyze mode, default unit for receiver side */
-#define TxUDEF 1 /* analyze mode, default unit for transmitter side */
-
-void layer1(char *pbuf, unsigned char *buf);
-int layer2(char *pbuf, unsigned char *buf, int is_te, int printit);
-void layer3(char *pbuf, int n, int off, unsigned char *buf);
-int q932_facility(char *pbuf, unsigned char *buf);
-void sprintline(int, char *, int, int, int, const char *, ...);
-void extension(int, char *, int, unsigned char, unsigned char);
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdndecode/facility.c b/usr.sbin/i4b/isdndecode/facility.c
deleted file mode 100644
index 5735abb267f6..000000000000
--- a/usr.sbin/i4b/isdndecode/facility.c
+++ /dev/null
@@ -1,906 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * facility.c - decode Q.932 facilities
- * ------------------------------------
- *
- * $Id: facility.c,v 1.2 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:10:32 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "decode.h"
-#include "facility.h"
-
-static int do_component(int length, char *pbuf);
-static char *uni_str(int code);
-static char *opval_str(int val);
-static char *bid_str(int val);
-static void next_state(char *pbuf, int class, int form, int code, int val);
-
-static int byte_len;
-static unsigned char *byte_buf;
-static int state;
-
-/*---------------------------------------------------------------------------*
- * decode Q.931/Q.932 facility info element
- *---------------------------------------------------------------------------*/
-int
-q932_facility(char *pbuf, unsigned char *buf)
-{
- int len;
-
- sprintf((pbuf+strlen(pbuf)), "[facility (Q.932): ");
-
- buf++; /* length */
-
- len = *buf;
-
- buf++; /* protocol profile */
-
- sprintf((pbuf+strlen(pbuf)), "Protocol=");
-
- switch(*buf & 0x1f)
- {
- case FAC_PROTO_ROP:
- sprintf((pbuf+strlen(pbuf)), "Remote Operations Protocol\n");
- break;
-
- case FAC_PROTO_CMIP:
- sprintf((pbuf+strlen(pbuf)), "CMIP Protocol (Q.941), UNSUPPORTED!\n");
- return(len+2);
- break;
-
- case FAC_PROTO_ACSE:
- sprintf((pbuf+strlen(pbuf)), "ACSE Protocol (X.217/X.227), UNSUPPORTED!\n");
- return(len+2);
- break;
-
- default:
- sprintf((pbuf+strlen(pbuf)), "Unknown Protocol (val = 0x%x), UNSUPPORTED!\n", *buf & 0x1f);
- return(len+2);
- break;
- }
-
- /* next byte */
-
- buf++;
- len--;
-
- /* initialize variables for do_component */
-
- byte_len = 0;
- byte_buf = buf;
- state = ST_EXP_COMP_TYP;
-
- /* decode facility */
-
- do_component(len, pbuf);
-
- sprintf((pbuf+(strlen(pbuf)-1)), "]"); /* XXX replace last newline */
-
- return(len+3);
-}
-
-/*---------------------------------------------------------------------------*
- * handle a component recursively
- *---------------------------------------------------------------------------*/
-static int
-do_component(int length, char *pbuf)
-{
- int comp_tag_class; /* component tag class */
- int comp_tag_form; /* component form: constructor or primitive */
- int comp_tag_code; /* component code depending on class */
- int comp_length = 0; /* component length */
-
-#ifdef FAC_DEBUG
- sprintf((pbuf+strlen(pbuf)), "ENTER - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
-#endif
-
-again:
-
-#ifdef FAC_DEBUG
- sprintf((pbuf+strlen(pbuf)), "AGAIN - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
-#endif
-
- /*----------------------------------------*/
- /* first component element: component tag */
- /*----------------------------------------*/
-
- /* tag class bits */
-
- sprintf((pbuf+strlen(pbuf)), "\t0x%02x Tag: ", *byte_buf);
-
- comp_tag_class = (*byte_buf & 0xc0) >> 6;
-
- switch(comp_tag_class)
- {
- case FAC_TAGCLASS_UNI:
- sprintf((pbuf+strlen(pbuf)), "Universal");
- break;
- case FAC_TAGCLASS_APW:
- sprintf((pbuf+strlen(pbuf)), "Applic-wide");
- break;
- case FAC_TAGCLASS_COS:
- sprintf((pbuf+strlen(pbuf)), "Context-spec");
- break;
- case FAC_TAGCLASS_PRU:
- sprintf((pbuf+strlen(pbuf)), "Private");
- break;
- }
-
- /* tag form bit */
-
- comp_tag_form = (*byte_buf & 0x20) > 5;
-
- sprintf((pbuf+strlen(pbuf)), ", ");
-
- if(comp_tag_form == FAC_TAGFORM_CON)
- {
- sprintf((pbuf+strlen(pbuf)), "Constructor");
- }
- else
- {
- sprintf((pbuf+strlen(pbuf)), "Primitive");
- }
-
- /* tag code bits */
-
- comp_tag_code = *byte_buf & 0x1f;
-
- sprintf((pbuf+strlen(pbuf)), ", ");
-
- if(comp_tag_code == 0x1f)
- {
- comp_tag_code = 0;
-
- byte_buf++;
- byte_len++;
-
- while(*byte_buf & 0x80)
- {
- comp_tag_code += (*byte_buf & 0x7f);
- byte_buf++;
- byte_len++;
- }
- comp_tag_code += (*byte_buf & 0x7f);
- sprintf((pbuf+strlen(pbuf)), "%d (ext)\n", comp_tag_code);
- }
- else
- {
- comp_tag_code = (*byte_buf & 0x1f);
-
- if(comp_tag_class == FAC_TAGCLASS_UNI)
- {
- sprintf((pbuf+strlen(pbuf)), "%s (%d)\n", uni_str(comp_tag_code), comp_tag_code);
- }
- else
- {
- sprintf((pbuf+strlen(pbuf)), "code = %d\n", comp_tag_code);
- }
- }
-
- byte_buf++;
- byte_len++;
-
- /*--------------------------------------------*/
- /* second component element: component length */
- /*--------------------------------------------*/
-
- sprintf((pbuf+strlen(pbuf)), "\t0x%02x Len: ", *byte_buf);
-
- comp_length = 0;
-
- if(*byte_buf & 0x80)
- {
- int i = *byte_buf & 0x7f;
-
- byte_len += i;
-
- for(;i > 0;i++)
- {
- byte_buf++;
- comp_length += (*byte_buf * (i*256));
- }
- sprintf((pbuf+strlen(pbuf)), "%d (long form)\n", comp_length);
- }
- else
- {
- comp_length = *byte_buf & 0x7f;
- sprintf((pbuf+strlen(pbuf)), "%d (short form)\n", comp_length);
- }
-
- next_state(pbuf, comp_tag_class, comp_tag_form, comp_tag_code, -1);
-
- byte_len++;
- byte_buf++;
-
- if(comp_length)
- {
-
- /*---------------------------------------------*/
- /* third component element: component contents */
- /*---------------------------------------------*/
-
- if(comp_tag_form) /* == constructor */
- {
- do_component(comp_length, pbuf);
- }
- else
- {
- int val = 0;
- if(comp_tag_class == FAC_TAGCLASS_UNI)
- {
- switch(comp_tag_code)
- {
- case FAC_CODEUNI_INT:
- case FAC_CODEUNI_ENUM:
- case FAC_CODEUNI_BOOL:
- if(comp_length)
- {
- int i;
-
- sprintf((pbuf+strlen(pbuf)), "\t");
-
- for(i = comp_length-1; i >= 0; i--)
- {
- sprintf((pbuf+strlen(pbuf)), "0x%02x ", *byte_buf);
- val += (*byte_buf + (i*255));
- byte_buf++;
- byte_len++;
- if(i)
- sprintf((pbuf+strlen(pbuf)), "\n\t");
- }
- sprintf((pbuf+strlen(pbuf)), "Val: %d\n", val);
- }
- break;
- default:
- if(comp_length)
- {
- int i;
-
- sprintf((pbuf+strlen(pbuf)), "\t");
-
- for(i = comp_length-1; i >= 0; i--)
- {
- sprintf((pbuf+strlen(pbuf)), "0x%02x = %d", *byte_buf, *byte_buf);
- if(isprint(*byte_buf))
- sprintf((pbuf+strlen(pbuf)), " = '%c'", *byte_buf);
- byte_buf++;
- byte_len++;
- if(i)
- sprintf((pbuf+strlen(pbuf)), "\n\t");
- }
- }
- break;
- }
- }
-
- else /* comp_tag_class != FAC_TAGCLASS_UNI */
- {
- if(comp_length)
- {
- int i;
-
- sprintf((pbuf+strlen(pbuf)), "\t");
-
- for(i = comp_length-1; i >= 0; i--)
- {
- sprintf((pbuf+strlen(pbuf)), "0x%02x", *byte_buf);
- val += (*byte_buf + (i*255));
- byte_buf++;
- byte_len++;
- if(i)
- sprintf((pbuf+strlen(pbuf)), "\n\t");
- }
- sprintf((pbuf+strlen(pbuf)), "\n");
- }
- }
- next_state(pbuf, comp_tag_class, comp_tag_form, comp_tag_code, val);
- }
- }
-
-#ifdef FAC_DEBUG
- sprintf((pbuf+strlen(pbuf)), "PREGOTO - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
-#endif
- if(byte_len < length)
- goto again;
-#ifdef FAC_DEBUG
- sprintf((pbuf+strlen(pbuf)), "RETURN - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
-#endif
- return(byte_len);
-}
-
-/*---------------------------------------------------------------------------*
- * print universal id type
- *---------------------------------------------------------------------------*/
-static char *uni_str(int code)
-{
- static char *tbl[] = {
- "BOOLEAN",
- "INTEGER",
- "BIT STRING",
- "OCTET STRING",
- "NULL",
- "OBJECT IDENTIFIER",
- "OBJECT DESCRIPTOR",
- "EXTERNAL",
- "REAL",
- "ENUMERATED",
- "RESERVED11",
- "RESERVED12",
- "RESERVED13",
- "RESERVED14",
- "RESERVED15",
- "SEQUENCE",
- "SET",
- "NUMERIC STRING",
- "PRINTABLE STRING",
- "TELETEX STRING",
- "ISO646 STRING",
- "IA5 STRING",
- "GRAPHIC STRING",
- "GENERAL STRING"
- };
-
- if(code >= 1 && code <= FAC_CODEUNI_GNSTR)
- return(tbl[code-1]);
- else
- return("ERROR, Value out of Range!");
-}
-
-/*---------------------------------------------------------------------------*
- * print operation value
- *---------------------------------------------------------------------------*/
-static char *opval_str(int val)
-{
- static char buffer[80];
- char *r;
-
- switch(val)
- {
- case FAC_OPVAL_UUS:
- r = "uUs";
- break;
- case FAC_OPVAL_CUG:
- r = "cUGCall";
- break;
- case FAC_OPVAL_MCID:
- r = "mCIDRequest";
- break;
- case FAC_OPVAL_BTPY:
- r = "beginTPY";
- break;
- case FAC_OPVAL_ETPY:
- r = "endTPY";
- break;
- case FAC_OPVAL_ECT:
- r = "eCTRequest";
- break;
- case FAC_OPVAL_DIV_ACT:
- r = "activationDiversion";
- break;
- case FAC_OPVAL_DIV_DEACT:
- r = "deactivationDiversion";
- break;
- case FAC_OPVAL_DIV_ACTSN:
- r = "activationStatusNotificationDiv";
- break;
- case FAC_OPVAL_DIV_DEACTSN:
- r = "deactivationStatusNotificationDiv";
- break;
- case FAC_OPVAL_DIV_INTER:
- r = "interrogationDiversion";
- break;
- case FAC_OPVAL_DIV_INFO:
- r = "diversionInformation";
- break;
- case FAC_OPVAL_DIV_CALLDEF:
- r = "callDeflection";
- break;
- case FAC_OPVAL_DIV_CALLRER:
- r = "callRerouting";
- break;
- case FAC_OPVAL_DIV_LINF2:
- r = "divertingLegInformation2";
- break;
- case FAC_OPVAL_DIV_INVS:
- r = "invokeStatus";
- break;
- case FAC_OPVAL_DIV_INTER1:
- r = "interrogationDiversion1";
- break;
- case FAC_OPVAL_DIV_LINF1:
- r = "divertingLegInformation1";
- break;
- case FAC_OPVAL_DIV_LINF3:
- r = "divertingLegInformation3";
- break;
- case FAC_OPVAL_ER_CRCO:
- r = "explicitReservationCreationControl";
- break;
- case FAC_OPVAL_ER_MGMT:
- r = "explicitReservationManagement";
- break;
- case FAC_OPVAL_ER_CANC:
- r = "explicitReservationCancel";
- break;
- case FAC_OPVAL_MLPP_QUERY:
- r = "mLPP lfb Query";
- break;
- case FAC_OPVAL_MLPP_CALLR:
- r = "mLPP Call Request";
- break;
- case FAC_OPVAL_MLPP_CALLP:
- r = "mLPP Call Preemption";
- break;
- case FAC_OPVAL_AOC_REQ:
- r = "chargingRequest";
- break;
- case FAC_OPVAL_AOC_S_CUR:
- r = "aOCSCurrency";
- break;
- case FAC_OPVAL_AOC_S_SPC:
- r = "aOCSSpecialArrangement";
- break;
- case FAC_OPVAL_AOC_D_CUR:
- r = "aOCDCurrency";
- break;
- case FAC_OPVAL_AOC_D_UNIT:
- r = "aOCDChargingUnit";
- break;
- case FAC_OPVAL_AOC_E_CUR:
- r = "aOCECurrency";
- break;
- case FAC_OPVAL_AOC_E_UNIT:
- r = "aOCEChargingUnit";
- break;
- case FAC_OPVAL_AOC_IDOFCRG:
- r = "identificationOfCharge";
- break;
- case FAC_OPVAL_CONF_BEG:
- r = "beginConf";
- break;
- case FAC_OPVAL_CONF_ADD:
- r = "addConf";
- break;
- case FAC_OPVAL_CONF_SPLIT:
- r = "splitConf";
- break;
- case FAC_OPVAL_CONF_DROP:
- r = "dropConf";
- break;
- case FAC_OPVAL_CONF_ISOLATE:
- r = "isolateConf";
- break;
- case FAC_OPVAL_CONF_REATT:
- r = "reattachConf";
- break;
- case FAC_OPVAL_CONF_PDISC:
- r = "partyDISC";
- break;
- case FAC_OPVAL_CONF_FCONF:
- r = "floatConf";
- break;
- case FAC_OPVAL_CONF_END:
- r = "endConf";
- break;
- case FAC_OPVAL_CONF_IDCFE:
- r = "indentifyConferee";
- break;
- case FAC_OPVAL_REVC_REQ:
- r = "requestREV";
- break;
- default:
- sprintf(buffer, "unknown operation value %d!", val);
- r = buffer;
- }
- return(r);
-}
-
-/*---------------------------------------------------------------------------*
- * billing id string
- *---------------------------------------------------------------------------*/
-static char *bid_str(int val)
-{
- static char buffer[80];
- char *r;
-
- switch(val)
- {
- case 0:
- r = "normalCharging";
- break;
- case 1:
- r = "reverseCharging";
- break;
- case 2:
- r = "creditCardCharging";
- break;
- case 3:
- r = "callForwardingUnconditional";
- break;
- case 4:
- r = "callForwardingBusy";
- break;
- case 5:
- r = "callForwardingNoReply";
- break;
- case 6:
- r = "callDeflection";
- break;
- case 7:
- r = "callTransfer";
- break;
- default:
- sprintf(buffer, "unknown billing-id value %d!", val);
- r = buffer;
- }
- return(r);
-}
-
-/*---------------------------------------------------------------------------*
- * invoke component
- *---------------------------------------------------------------------------*/
-static void
-F_1_1(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_1, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t invokeComponent\n");
- state = ST_EXP_INV_ID;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return result
- *---------------------------------------------------------------------------*/
-static void
-F_1_2(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_2, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t returnResult\n");
- state = ST_EXP_RR_INV_ID;
- }
-}
-/*---------------------------------------------------------------------------*
- * return error
- *---------------------------------------------------------------------------*/
-static void
-F_1_3(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_3, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t returnError\n");
- state = ST_EXP_NIX;
- }
-}
-/*---------------------------------------------------------------------------*
- * reject
- *---------------------------------------------------------------------------*/
-static void
-F_1_4(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_4, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t reject\n");
- state = ST_EXP_NIX;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * invoke component: invoke id
- *---------------------------------------------------------------------------*/
-static void
-F_2(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_2, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t InvokeIdentifier = %d\n", val);
- state = ST_EXP_OP_VAL;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return result: invoke id
- *---------------------------------------------------------------------------*/
-static void
-F_RR2(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RR2, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t InvokeIdentifier = %d\n", val);
- state = ST_EXP_RR_OP_VAL;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * invoke component: operation value
- *---------------------------------------------------------------------------*/
-static void
-F_3(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_3, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t Operation Value = %s (%d)\n", opval_str(val), val);
- state = ST_EXP_INFO;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return result: operation value
- *---------------------------------------------------------------------------*/
-static void
-F_RR3(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RR3, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t Operation Value = %s (%d)\n", opval_str(val), val);
- state = ST_EXP_RR_RESULT;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return result: RESULT
- *---------------------------------------------------------------------------*/
-static void
-F_RRR(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RRR, val = %d\n", val);
-#endif
- state = ST_EXP_NIX;
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_4(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t specificChargingUnits\n");
- state = ST_EXP_RUL;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_4_1(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4_1, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t freeOfCharge\n");
- state = ST_EXP_NIX;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_4_2(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4_2, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t chargeNotAvailable\n");
- state = ST_EXP_NIX;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_5(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_5, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t recordedUnitsList [1]\n");
- state = ST_EXP_RU;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_6(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_6, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t RecordedUnits\n");
- state = ST_EXP_RNOU;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_7(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_7, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t NumberOfUnits = %d\n", val);
- state = ST_EXP_TOCI;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_8(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_8, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t typeOfChargingInfo = %s\n", val == 0 ? "subTotal" : "total");
- state = ST_EXP_DBID;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_9(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_9, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t AOCDBillingId = %s (%d)\n", bid_str(val), val);
- state = ST_EXP_NIX;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * state table
- *---------------------------------------------------------------------------*/
-static struct statetab {
- int currstate; /* input: current state we are in */
- int form; /* input: current tag form */
- int class; /* input: current tag class */
- int code; /* input: current tag code */
- void (*func)(char *,int); /* output: func to exec */
-} statetab[] = {
-
-/* current state tag form tag class tag code function */
-/* --------------------- ---------------------- ---------------------- ---------------------- ----------------*/
-
-/* invoke */
-
- {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 1, F_1_1 },
- {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 2, F_1_2 },
- {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 3, F_1_3 },
- {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 4, F_1_4 },
- {ST_EXP_INV_ID, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_2 },
- {ST_EXP_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_3 },
- {ST_EXP_INFO, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SEQ, F_4 },
- {ST_EXP_INFO, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_NULL, F_4_1 },
- {ST_EXP_INFO, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 1, F_4_2 },
- {ST_EXP_RUL, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 1, F_5 },
- {ST_EXP_RU, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SEQ, F_6 },
- {ST_EXP_RNOU, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_7 },
- {ST_EXP_TOCI, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 2, F_8 },
- {ST_EXP_DBID, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 3, F_9 },
-
-/* return result */
-
- {ST_EXP_RR_INV_ID, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RR2 },
- {ST_EXP_RR_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RR3 },
- {ST_EXP_RR_RESULT, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SET, F_RRR },
-
-/* end */
-
- {-1, -1, -1, -1, NULL }
-};
-
-/*---------------------------------------------------------------------------*
- * state decode for do_component
- *---------------------------------------------------------------------------*/
-static void
-next_state(char *pbuf, int class, int form, int code, int val)
-{
- int i;
-
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: class=%d, form=%d, code=%d, val=%d\n", class, form, code, val);
-#endif
-
- for(i=0; ; i++)
- {
- if((statetab[i].currstate > state) ||
- (statetab[i].currstate == -1))
- {
- break;
- }
-
- if((statetab[i].currstate == state) &&
- (statetab[i].form == form) &&
- (statetab[i].class == class) &&
- (statetab[i].code == code))
- {
- (*statetab[i].func)(pbuf, val);
- break;
- }
- }
-}
-
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdndecode/facility.h b/usr.sbin/i4b/isdndecode/facility.h
deleted file mode 100644
index 7080c22ccc27..000000000000
--- a/usr.sbin/i4b/isdndecode/facility.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * facility.h - Q.932 facility header file
- * ---------------------------------------
- *
- * $Id: facility.h,v 1.2 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:10:48 1998]
- *
- *---------------------------------------------------------------------------*/
-
-/* #define FAC_DEBUG */
-/* #define ST_DEBUG */
-
-/* protocols */
-#define FAC_PROTO_ROP 0x11
-#define FAC_PROTO_CMIP 0x12
-#define FAC_PROTO_ACSE 0x13
-
-/* tag classes */
-#define FAC_TAGCLASS_UNI 0x00
-#define FAC_TAGCLASS_APW 0x01
-#define FAC_TAGCLASS_COS 0x02
-#define FAC_TAGCLASS_PRU 0x03
-
-/* tag forms */
-#define FAC_TAGFORM_PRI 0x00
-#define FAC_TAGFORM_CON 0x01
-
-/* class UNIVERSAL values */
-#define FAC_CODEUNI_BOOL 1
-#define FAC_CODEUNI_INT 2
-#define FAC_CODEUNI_BITS 3
-#define FAC_CODEUNI_OCTS 4
-#define FAC_CODEUNI_NULL 5
-#define FAC_CODEUNI_OBJI 6
-#define FAC_CODEUNI_OBJD 7
-#define FAC_CODEUNI_EXT 8
-#define FAC_CODEUNI_REAL 9
-#define FAC_CODEUNI_ENUM 10
-#define FAC_CODEUNI_R11 11
-#define FAC_CODEUNI_R12 12
-#define FAC_CODEUNI_R13 13
-#define FAC_CODEUNI_R14 14
-#define FAC_CODEUNI_R15 15
-#define FAC_CODEUNI_SEQ 16
-#define FAC_CODEUNI_SET 17
-#define FAC_CODEUNI_NSTR 18
-#define FAC_CODEUNI_PSTR 19
-#define FAC_CODEUNI_TSTR 20
-#define FAC_CODEUNI_VSTR 21
-#define FAC_CODEUNI_ISTR 22
-#define FAC_CODEUNI_UTIME 23
-#define FAC_CODEUNI_GTIME 24
-#define FAC_CODEUNI_GSTR 25
-#define FAC_CODEUNI_VISTR 26
-#define FAC_CODEUNI_GNSTR 27
-
-/* operation values */
-#define FAC_OPVAL_UUS 1
-#define FAC_OPVAL_CUG 2
-#define FAC_OPVAL_MCID 3
-#define FAC_OPVAL_BTPY 4
-#define FAC_OPVAL_ETPY 5
-#define FAC_OPVAL_ECT 6
-
-#define FAC_OPVAL_DIV_ACT 7
-#define FAC_OPVAL_DIV_DEACT 8
-#define FAC_OPVAL_DIV_ACTSN 9
-#define FAC_OPVAL_DIV_DEACTSN 10
-#define FAC_OPVAL_DIV_INTER 11
-#define FAC_OPVAL_DIV_INFO 12
-#define FAC_OPVAL_DIV_CALLDEF 13
-#define FAC_OPVAL_DIV_CALLRER 14
-#define FAC_OPVAL_DIV_LINF2 15
-#define FAC_OPVAL_DIV_INVS 16
-#define FAC_OPVAL_DIV_INTER1 17
-#define FAC_OPVAL_DIV_LINF1 18
-#define FAC_OPVAL_DIV_LINF3 19
-
-#define FAC_OPVAL_ER_CRCO 20
-#define FAC_OPVAL_ER_MGMT 21
-#define FAC_OPVAL_ER_CANC 22
-
-#define FAC_OPVAL_MLPP_QUERY 24
-#define FAC_OPVAL_MLPP_CALLR 25
-#define FAC_OPVAL_MLPP_CALLP 26
-
-#define FAC_OPVAL_AOC_REQ 30
-#define FAC_OPVAL_AOC_S_CUR 31
-#define FAC_OPVAL_AOC_S_SPC 32
-#define FAC_OPVAL_AOC_D_CUR 33
-#define FAC_OPVAL_AOC_D_UNIT 34
-#define FAC_OPVAL_AOC_E_CUR 35
-#define FAC_OPVAL_AOC_E_UNIT 36
-#define FAC_OPVAL_AOC_IDOFCRG 37
-
-#define FAC_OPVAL_CONF_BEG 40
-#define FAC_OPVAL_CONF_ADD 41
-#define FAC_OPVAL_CONF_SPLIT 42
-#define FAC_OPVAL_CONF_DROP 43
-#define FAC_OPVAL_CONF_ISOLATE 44
-#define FAC_OPVAL_CONF_REATT 45
-#define FAC_OPVAL_CONF_PDISC 46
-#define FAC_OPVAL_CONF_FCONF 47
-#define FAC_OPVAL_CONF_END 48
-#define FAC_OPVAL_CONF_IDCFE 49
-
-#define FAC_OPVAL_REVC_REQ 60
-
-enum states {
- ST_EXP_COMP_TYP,
- ST_EXP_INV_ID,
- ST_EXP_OP_VAL,
- ST_EXP_INFO,
- ST_EXP_RUL,
- ST_EXP_RU,
- ST_EXP_RNOU,
- ST_EXP_TOCI,
- ST_EXP_DBID,
-
- ST_EXP_RR_INV_ID,
- ST_EXP_RR_OP_VAL,
- ST_EXP_RR_RESULT,
-
- ST_EXP_NIX
-};
-
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdndecode/isdndecode.8 b/usr.sbin/i4b/isdndecode/isdndecode.8
deleted file mode 100644
index 85946862b0c4..000000000000
--- a/usr.sbin/i4b/isdndecode/isdndecode.8
+++ /dev/null
@@ -1,190 +0,0 @@
-.\"
-.\" Copyright (c) 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdndecode.8,v 1.3 1998/12/18 17:09:38 hm Exp $
-.\"
-.\" last edit-date: [Fri Dec 18 18:11:31 1998]
-.\"
-.\" -hm writing manual page
-.\"
-.Dd September 17, 1998
-.Dt isdndecode 8
-.Sh NAME
-.Nm isdndecode
-.Nd isdn4bsd ISDN protocol decode utility
-.Sh SYNOPSIS
-.Nm isdndecode
-.Op Fl a
-.Op Fl b
-.Op Fl d
-.Op Fl f Ar filename
-.Op Fl h
-.Op Fl i
-.Op Fl l
-.Op Fl o
-.Op Fl p Ar filename
-.Op Fl u Ar number
-.Op Fl B
-.Op Fl P
-.Op Fl R Ar unit
-.Op Fl T Ar unit
-.Sh DESCRIPTION
-.Nm isdndecode
-is part of the isdn4bsd package and is used to provide the user with a
-detailed mnemonic display of the layers 1, 2 and 3 protocol activities on
-the D channel and hex dump of the B channel(s) activities.
-.Pp
-Together with two passive supported cards and an easy to build cable it can
-also be used to monitor the complete traffic on a S0 bus providing S0 bus
-analyzer features.
-.Pp
-The
-.Nm
-utility is only available for passive supported cards.
-.Pp
-The following options can be used:
-.Bl -tag -width Ds
-
-.It Fl a
-Run
-.Nm
-in analyzer mode by using two passive cards and a custom cable which can
-be build as described in the file
-.Em cable.txt
-in the isdn4bsd source distribution. One card acts as a receiver for the
-transmitting direction on the S0 bus while the other card acts as a receiver
-for the receiving direction on the S0 bus. Complete traffic monitoring is
-possible using this setup.
-
-.It Fl b
-switch B channel tracing on (default off).
-
-.It Fl d
-switch D channel tracing off (default on).
-
-.It Fl f
-Use
-.Ar filename
-as the name of a file into which to write tracing output (default filename is
-isdndecode<n> where n is the number of the unit to decode).
-
-.It Fl h
-switch display of header off (default on).
-
-.It Fl i
-print layer 1 (I.430) INFO signals to monitor layer 1 activity (default off).
-
-.It Fl l
-switch displaying of Layer 2 (Q.921) frames off (default on).
-
-.It Fl o
-switch off writing decode output to a file (default on).
-
-.It Fl p
-Use
-.Ar filename
-as the name of a file used for the -B and -P options (default filename
-is isdntracebin<n> where n is the number of the unit to decode).
-
-.It Fl u
-Use
-.Ar number
-as the unit number of the controller card to decode (default 0).
-
-.It Fl B
-Write undecoded binary decode data to a file for later or remote
-analyzing (default off).
-
-.It Fl P
-Read undecoded binary decode data from file instead from device (default off).
-
-.It Fl R
-Use
-.Ar unit
-as the receiving interface unit number in analyze mode.
-
-.It Fl T
-Use
-.Ar unit
-as the transmitting interface unit number in analyze mode.
-
-.Pp
-When the USR1 signal is sent to a
-.Nm
-process, the currently used logfiles are reopened, so that logfile
-rotation becomes possible.
-.Pp
-The decode output should be obvious. It is very handy to have the following
-standard texts available when tracing ISDN protocols:
-.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It Ar I.430
-ISDN BRI layer 1 protocol description.
-.It Ar Q.921
-ISDN D-channel layer 2 protocol description.
-.It Ar Q.931
-ISDN D-channel layer 3 protocol description.
-.El
-.Pp
-
-.Sh FILES
-.Bl -tag -width daddeldi -compact
-.It Pa /dev/i4btrc<n>
-The devicefile(s) used to get the decode messages for ISDN card unit <n>
-out of the kernel.
-.El
-
-.Sh EXAMPLES
-The command:
-.Bd -literal -offset indent
-isdndecode -f /var/tmp/isdn.decode
-.Ed
-.Pp
-will start D channel tracing on passive controller 0 with all except B
-channel tracing enabled and logs everything into the output file
-/tmp/isdn.decode.
-
-.Sh SEE ALSO
-.Xr isdnd 8
-
-.Sh BUGS
-Still one left.
-
-.Sh STANDARDS
-ITU Recommendations I.430, Q.920, Q.921, Q.930, Q.931
-.Pp
-ITU Recommendation Q.932 (03/93), Q.950 (03/93)
-.Pp
-ETSI Recommendation ETS 300 179 (10/92), ETS 300 180 (10/92)
-.Pp
-ETSI Recommendation ETS 300 181 (04/93), ETS 300 182 (04/93)
-.Pp
-ITU Recommendation X.208, X.209
-
-.Sh AUTHOR
-The
-.Nm
-utility and this manual page was written by Hellmuth Michaelis,
-he can be reached at hm@kts.org.
-
diff --git a/usr.sbin/i4b/isdndecode/layer1.c b/usr.sbin/i4b/isdndecode/layer1.c
deleted file mode 100644
index 8dee4b70ba6b..000000000000
--- a/usr.sbin/i4b/isdndecode/layer1.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * layer1.c - isdndecode, decode and print layer 1 information
- * -----------------------------------------------------------
- *
- * $Id: layer1.c,v 1.2 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:11:55 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "decode.h"
-
-/*---------------------------------------------------------------------------*
- * decode layer 1 information
- *---------------------------------------------------------------------------*/
-void
-layer1(char *buffer, unsigned char *buf)
-{
- switch(*buf)
- {
- case INFO0:
- strcpy(buffer,"L1 INFO0 (No Signal)\n");
- break;
-
- case INFO1_8:
- strcpy(buffer,"L1 INFO1 (Activation Request, Priority = 8)\n");
- break;
-
- case INFO1_10:
- strcpy(buffer,"L1 INFO1 (Activation Request, Priority = 10)\n");
- break;
-
- case INFO2:
- strcpy(buffer,"L1 INFO2 (Pending Activation)\n");
- break;
-
- case INFO3:
- strcpy(buffer,"L1 INFO3 (Synchronized)\n");
- break;
-
- case INFO4_8:
- strcpy(buffer,"L1 INFO4 (Activated, Priority = 8/9)\n");
- break;
-
- case INFO4_10:
- strcpy(buffer,"L1 INFO4 (Activated, Priority = 10/11)\n");
- break;
-
- default:
- sprintf(buffer,"L1 ERROR, invalid INFO value 0x%x!\n", *buf);
- break;
- }
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdndecode/layer2.c b/usr.sbin/i4b/isdndecode/layer2.c
deleted file mode 100644
index b7997dd7a965..000000000000
--- a/usr.sbin/i4b/isdndecode/layer2.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * layer2.c - decode and print layer 2 (Q.921) information
- * -------------------------------------------------------
- *
- * $Id: layer2.c,v 1.3 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:12:09 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "decode.h"
-
-/*---------------------------------------------------------------------------*
- * decode poll bit
- *---------------------------------------------------------------------------*/
-static void
-poll(int layer, char *buffer, int cnt, unsigned char value, unsigned char mask)
-{
- sprintline(layer, buffer, cnt, value, mask, "P/F, Poll = %s", (value & mask) ? "Immediate Response Required" : "No Immediate Response Required");
-}
-
-/*---------------------------------------------------------------------------*
- * decode final bit
- *---------------------------------------------------------------------------*/
-static void
-final(int layer, char *buffer, int cnt, unsigned char value, unsigned char mask)
-{
- sprintline(layer, buffer, cnt, value, mask, "P/F, Final = %s", (value & mask) ? "Result of Poll" : "No Result of Poll");
-}
-
-/*---------------------------------------------------------------------------*
- * decode protocol specified in Q.921
- *---------------------------------------------------------------------------*/
-int
-layer2(char *pbuf, unsigned char *buf, int dir, int printit)
-{
- int sap, tei, cmd;
- int cnt = 0;
- char locbuf[32000];
- char *lbufp = &locbuf[0];
- char buffer[80];
-
- *lbufp = '\0';
- *pbuf = '\0';
-
- /* address high */
-
- sap = (buf[0] >> 2) & 0x3f;
-
- if(sap == 0)
- strcpy(buffer, "Call Control");
- else if((sap >= 1) && (sap <= 15))
- strcpy(buffer, "Reserved");
- else if(sap == 16)
- strcpy(buffer, "X.25");
- else if((sap >= 17) && (sap <= 31))
- strcpy(buffer, "Reserved");
- else if(sap == 63)
- strcpy(buffer, "Layer 2 Management");
- else
- strcpy(buffer, "Not available for Q.921");
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[0], 0xfc, "SAPI = %d (%s)", sap, buffer);
-
- if(dir == FROM_TE)
- cmd = !(buf[0] & 0x02);
- else
- cmd = buf[0] & 0x02;
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[0], 0x02, "C/R = %s", cmd ? "Command" : "Response");
- extension(2, lbufp+strlen(lbufp), cnt, buf[0], 0x01);
- cnt++;
-
- /* address low */
-
- tei = buf[1] >> 1;
-
- if((tei >= 0) && (tei <= 63))
- strcpy(buffer, "Non-automatic TEI");
- else if((tei >= 64) && (tei <= 126))
- strcpy(buffer, "Automatic TEI");
- if(tei == 127)
- strcpy(buffer, "Group TEI");
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[1], 0xfe, "TEI = %d (%s)", tei, buffer);
- extension(2, lbufp+strlen(lbufp), cnt, buf[1], 0x01);
- cnt++;
-
- /* control 1 */
-
- if((buf[2] & 0x03) == 0x03)
- {
- /* U-frame */
-
- if((buf[2] & 0xef) == 0x6f)
- {
- /* SABME */
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xef, "U-Frame: SABME (Set Asynchonous Balanced Mode)");
- poll(2, lbufp+strlen(lbufp), cnt, buf[2], 0x10);
- cnt++;
- }
- else if((buf[2] & 0xef) == 0x0f)
- {
- /* DM */
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xef, "U-Frame: DM (Disconnected Mode)");
- final(2, lbufp+strlen(lbufp), cnt, buf[2], 0x10);
- cnt++;
- }
- else if((buf[2] & 0xef) == 0x03)
- {
- /* UI */
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xef, "U-Frame: UI (Unnumbered Information)");
- poll(2, lbufp+strlen(lbufp), cnt, buf[2], 0x10);
- cnt++;
-
- if(sap == 63 && (buf[3] == 0x0f)) /* TEI management */
- {
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[3], 0xff, "MEI (Management Entity Identifier)");
- cnt++;
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[4], 0xff, "Ri = 0x%04x (Reference number high)", (buf[4] << 8) | buf[5]);
- cnt++;
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[5], 0xff, "Ri (Reference Number low)");
- cnt++;
-
- switch(buf[6])
- {
- case 0x01:
- strcpy(buffer, "Identity Request");
- break;
- case 0x02:
- strcpy(buffer, "Identity Assigned");
- break;
- case 0x03:
- strcpy(buffer, "Identity denied");
- break;
- case 0x04:
- strcpy(buffer, "Identity Check Request");
- break;
- case 0x05:
- strcpy(buffer, "Identity Check Response");
- break;
- case 0x06:
- strcpy(buffer, "Identity Remove");
- break;
- case 0x07:
- strcpy(buffer, "Identity Verify");
- break;
- default:
- strcpy(buffer, "undefined");
- break;
- }
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[6], 0xff, "TEI %s (Message Type %d)", buffer, buf[6]);
- cnt++;
-
- switch(buf[6])
- {
- case 0x01:
- strcpy(buffer, "Any TEI value acceptable");
- break;
- case 0x02:
- strcpy(buffer, "");
- break;
- case 0x03:
- strcpy(buffer, "No TEI Value available");
- break;
- case 0x04:
- strcpy(buffer, "Check all TEI values");
- break;
- case 0x05:
- strcpy(buffer, "");
- break;
- case 0x06:
- strcpy(buffer, "Request for removal of all TEI values");
- break;
- case 0x07:
- strcpy(buffer, "");
- break;
- default:
- strcpy(buffer, "");
- break;
- }
- if(((buf[7] >> 1) & 0x7f) == 127)
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[7], 0xfe, "Ai = %d (Action Indicator = %s)", (buf[7] >> 1) & 0x7f, buffer);
- else
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[7], 0xfe, "Ai = %d (Action Indicator)", (buf[7] >> 1) & 0x7f);
- extension(2, lbufp+strlen(lbufp), cnt, buf[7], 0x01);
- cnt++;
- }
- }
- else if((buf[2] & 0xef) == 0x43)
- {
- /* DISC */
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xef, "U-Frame: DISC (Disconnect)");
- poll(2, lbufp+strlen(lbufp), cnt, buf[2], 0x10);
- cnt++;
- }
- else if((buf[2] & 0xef) == 0x63)
- {
- /* UA */
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xef, "U-Frame: UA (Unnumbered Acknowledge)");
- final(2, lbufp+strlen(lbufp), cnt, buf[2], 0x10);
- cnt++;
- }
- else if((buf[2] & 0xef) == 0x87)
- {
- /* FRMR */
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xef, "U-Frame: FRMR (Frame Reject)");
- final(2, lbufp+strlen(lbufp), cnt, buf[2], 0x10);
- cnt++;
- }
- else if((buf[2] & 0xef) == 0x9f)
- {
- /* XID */
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xef, "U-Frame: XID (Exchange Identification)");
- if(cmd)
- poll(2, lbufp+strlen(lbufp), cnt, buf[2], 0x10);
- else
- final(2, lbufp+strlen(lbufp), cnt, buf[2], 0x10);
- cnt++;
- }
-
- }
- else if((buf[2] & 0x03) == 0x01)
- {
- /* S-frame */
-
- if(buf[2] == 0x01)
- strcpy(buffer, "RR (Receiver Ready)");
- else if(buf[2] == 0x05)
- strcpy(buffer, "RNR (Receiver Not Ready)");
- else if(buf[2] == 0x09)
- strcpy(buffer, "REJ (Reject)");
- else
- strcpy(buffer, "Unknown");
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xff, "S-Frame: %s", buffer);
- cnt++;
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[3], 0xfe, "N(R) = %d (receive sequence number)", (buf[3] >> 1) & 0x7f);
- if(cmd)
- poll(2, lbufp+strlen(lbufp), cnt, buf[3], 0x01);
- else
- final(2, lbufp+strlen(lbufp), cnt, buf[3], 0x01);
- cnt++;
-
- }
- else if((buf[2] & 0x01) == 0x00)
- {
- /* I-frame */
-
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0xfe, "N(S) = %d (send sequence number)", (buf[2] >> 1) & 0x7f);
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[2], 0x01, "I-Frame: Information transfer");
- cnt++;
-
- sprintf(buffer, "N(R) = %d", (buf[3] >> 1) & 0x7f);
- sprintline(2, lbufp+strlen(lbufp), cnt, buf[3], 0xfe, "N(R) = %d (receive sequence number)", (buf[3] >> 1) & 0x7f);
- poll(2, lbufp+strlen(lbufp), cnt, buf[3], 0x01);
- cnt++;
-
- }
-
- sprintf((pbuf+strlen(pbuf)),"%s", &locbuf[0]);
- return (cnt);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdndecode/layer3.c b/usr.sbin/i4b/isdndecode/layer3.c
deleted file mode 100644
index 6376a139da58..000000000000
--- a/usr.sbin/i4b/isdndecode/layer3.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * layer3.c - decode and print layer 3 (Q.931) information
- * -------------------------------------------------------
- *
- * $Id: layer3.c,v 1.5 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:12:21 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "decode.h"
-
-char *mttab[] = {
-
-/* 0x00 */ /* call establishment group */
-
- "ESCAPE",
- "ALERTING",
- "CALL PROCEEDING",
- "PROGRESS",
- "undefined (0x04)",
- "SETUP",
- "undefined (0x06)",
- "CONNECT",
- "undefined (0x08)",
- "undefined (0x09)",
- "undefined (0x0a)",
- "undefined (0x0b)",
- "undefined (0x0c)",
- "SETUP ACKNOWLEDGE",
- "undefined (0x0e)",
- "CONNECT ACKNOWLEDGE",
-
-/* 0x10 */
- "undefined (0x10)",
- "undefined (0x11)",
- "undefined (0x12)",
- "undefined (0x13)",
- "undefined (0x14)",
- "undefined (0x15)",
- "undefined (0x16)",
- "undefined (0x17)",
- "undefined (0x18)",
- "undefined (0x19)",
- "undefined (0x1a)",
- "undefined (0x1b)",
- "undefined (0x1c)",
- "undefined (0x1d)",
- "undefined (0x1e)",
- "undefined (0x1f)",
-
-/* 0x20 */
-
- "USER INFORMATION", /* call information phase */
- "SUSPEND REJECT",
- "RESUME REJECT",
- "undefined (0x23)",
- "HOLD",
- "SUSPEND",
- "RESUME",
- "undefined (0x27)",
- "HOLD ACKNOWLEDGE",
- "undefined (0x29)",
- "undefined (0x2a)",
- "undefined (0x2b)",
- "undefined (0x2c)",
- "SUSPEND ACKNOWLEDGE",
- "RESUME ACKNOWLEDGE",
- "undefined (0x2f)",
-
-/* 0x30 */
-
- "HOLD REJECT",
- "RETRIEVE",
- "undefined (0x32)",
- "RETRIEVE ACKNOWLEDGE",
- "undefined (0x34)",
- "undefined (0x35)",
- "undefined (0x36)",
- "RETRIEVE REJECT",
- "undefined (0x38)",
- "undefined (0x39)",
- "undefined (0x3a)",
- "undefined (0x3b)",
- "undefined (0x3c)",
- "undefined (0x3d)",
- "undefined (0x3e)",
- "undefined (0x3f)",
-
-/* 0x40 */
-
- "DETACH", /* call clearing */
- "undefined (0x41)",
- "undefined (0x42)",
- "undefined (0x43)",
- "undefined (0x44)",
- "DISCONNECT",
- "RESTART",
- "undefined (0x47)",
- "DETACH ACKNOWLEDGE",
- "undefined (0x49)",
- "undefined (0x4a)",
- "undefined (0x4b)",
- "undefined (0x4c)",
- "RELEASE",
- "RESTART ACKNOWLEDGE",
- "undefined (0x4f)",
-
-/* 0x50 */
-
- "undefined (0x50)",
- "undefined (0x51)",
- "undefined (0x52)",
- "undefined (0x53)",
- "undefined (0x54)",
- "undefined (0x55)",
- "undefined (0x56)",
- "undefined (0x57)",
- "undefined (0x58)",
- "undefined (0x59)",
- "RELEASE COMPLETE",
- "undefined (0x5b)",
- "undefined (0x5c)",
- "undefined (0x5d)",
- "undefined (0x5e)",
- "undefined (0x5f)",
-
-/* 0x60 */
-
- "SEGMENT", /* misc messages */
- "undefined (0x61)",
- "FACILITY",
- "undefined (0x63)",
- "REGISTER",
- "undefined (0x65)",
- "undefined (0x66)",
- "undefined (0x67)",
- "CANCEL ACKNOWLEDGE",
- "undefined (0x69)",
- "FACILITY ACKNOWLEDGE",
- "undefined (0x6b)",
- "REGISTER ACKNOWLEDGE",
- "undefined (0x6d)",
- "NOTIFY",
- "undefined (0x6f)",
-
-/* 0x70 */
-
- "CANCEL REJECT",
- "undefined (0x71)",
- "FACILITY REJECT",
- "undefined (0x73)",
- "REGISTER REJECT",
- "STATUS ENQIRY",
- "undefined (0x76)",
- "undefined (0x77)",
- "undefined (0x78)",
- "CONGESTION CONTROL",
- "undefined (0x7a)",
- "INFORMATION",
- "undefined (0x7c)",
- "STATUS",
- "undefined (0x7e)",
- "undefined (0x7f)",
-};
-
-#define MTTAB_MAX 0x7f
-
-extern int f_null(char *pbuf, unsigned char *buf, int off);
-extern int f_bc(char *pbuf, unsigned char *buf, int off);
-extern int f_cause(char *pbuf, unsigned char *buf, int off);
-extern int f_cstat(char *pbuf, unsigned char *buf, int off);
-extern int f_chid(char *pbuf, unsigned char *buf, int off);
-extern int f_fac(char *pbuf, unsigned char *buf, int off);
-extern int f_progi(char *pbuf, unsigned char *buf, int off);
-extern int f_displ(char *pbuf, unsigned char *buf, int off);
-extern int f_date(char *pbuf, unsigned char *buf, int off);
-extern int f_cnu(char *pbuf, unsigned char *buf, int off);
-extern int f_cgpn(char *pbuf, unsigned char *buf, int off);
-extern int f_cdpn(char *pbuf, unsigned char *buf, int off);
-extern int f_hlc(char *pbuf, unsigned char *buf, int off);
-
-struct ie {
- unsigned char code; /* information element identifier code */
- char *name; /* ie name */
- int (*func) (char *pbuf, unsigned char *buf, int off); /* decode function */
-} ietab[] = {
- { 0x00, "segmented message", f_null },
- { 0x04, "bearer capability", f_bc },
- { 0x08, "cause", f_cause },
- { 0x0c, "connected address", f_null },
- { 0x0d, "extended facility", f_null },
- { 0x10, "call identity", f_null },
- { 0x14, "call state", f_cstat },
- { 0x18, "channel id", f_chid },
- { 0x19, "data link connection id", f_null },
- { 0x1c, "facility", f_fac },
- { 0x1e, "progress indicator", f_progi },
- { 0x20, "network specific facilities", f_null },
- { 0x24, "terminal capabilities", f_null },
- { 0x27, "notification indicator", f_null },
- { 0x28, "display", f_displ },
- { 0x29, "date/time", f_date },
- { 0x2c, "keypad", f_null },
- { 0x30, "keypad echo", f_null },
- { 0x32, "information request", f_null },
- { 0x34, "signal", f_null },
- { 0x36, "switchhook", f_null },
- { 0x38, "feature activation", f_null },
- { 0x39, "feature indication", f_null },
- { 0x3a, "service profile id", f_null },
- { 0x3b, "endpoint identifier", f_null },
- { 0x40, "information rate", f_null },
- { 0x41, "precedence level", f_null },
- { 0x42, "end-to-end transit delay", f_null },
- { 0x43, "transit delay detection", f_null },
- { 0x44, "packet layer binary parms", f_null },
- { 0x45, "packet layer window size", f_null },
- { 0x46, "packet size", f_null },
- { 0x47, "closed user group", f_null },
- { 0x48, "link layer core parameters", f_null },
- { 0x49, "link layer protocol parms", f_null },
- { 0x4a, "reverse charging information", f_null },
- { 0x4c, "connected number", f_cnu },
- { 0x4d, "connected subaddress", f_null },
- { 0x50, "X.213 priority", f_null },
- { 0x51, "report type", f_null },
- { 0x53, "link integrity verification", f_null },
- { 0x57, "PVC status", f_null },
- { 0x6c, "calling party number", f_cnu },
- { 0x6d, "calling party subaddress", f_null },
- { 0x70, "called party number", f_cnu },
- { 0x71, "called party subaddress", f_null },
- { 0x74, "redirecting number", f_null },
- { 0x78, "transit network selection", f_null },
- { 0x79, "restart indicator", f_null },
- { 0x7c, "low layer compatibility", f_null },
- { 0x7d, "high layer compatibility", f_hlc },
- { 0x7e, "user-user", f_null },
- { 0x7f, "escape for extension", f_null },
- { 0xff, "unknown information element", f_null }
-};
-
-/*---------------------------------------------------------------------------*
- * decode Q.931 protocol
- *---------------------------------------------------------------------------*/
-void
-layer3(char *pbuf, int n, int off, unsigned char *buf)
-{
- char buffer[256];
- int codeset = 0;
- int codelock = 0;
- int oldcodeset = 0;
-
- int pd;
- int len;
- int j;
- int i;
-
- if(n <= 0)
- return;
-
- *pbuf = '\0';
-
- i = 0;
-
- /* protocol discriminator */
-
- pd = buf[i];
-
- if(pd >= 0x00 && pd <= 0x07)
- sprintf(buffer, "User-User IE (0x%02x)",pd);
- else if(pd == 0x08)
- sprintf(buffer, "Q.931/I.451");
- else if(pd >= 0x10 && pd <= 0x3f)
- sprintf(buffer, "Other Layer 3 or X.25 (0x%02x)",pd);
- else if(pd >= 0x40 && pd <= 0x4f)
- sprintf(buffer, "National Use (0x%02x)",pd);
- else if(pd >= 0x50 && pd <= 0xfe)
- sprintf(buffer, "Other Layer 3 or X.25 (0x%02x)",pd);
- else
- sprintf(buffer, "Reserved (0x%02x)",pd);
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, pd, 0xff, "Protocol discriminator = %s", buffer);
- i++;
-
- /* call reference */
-
- len = buf[i] & 0x0f;
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xf0, "Call Reference");
-
- switch(len)
- {
- case 0:
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x0f, "Length of Call Reference = 0 (Dummy CR)");
- break;
- case 1:
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x0f, "Length of Call Reference = 1");
- i++;
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x80, "Call Reference sent %s origination side", (buf[i] & 0x80) ? "to" : "from");
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "Call Reference = %d = 0x%02x", (buf[i] & 0x7f), (buf[i] & 0x7f));
- break;
- case 2:
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x0f, "Length of Call Reference = 2");
- i++;
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x80, "Call Reference sent %s origination side", (buf[i] & 0x80) ? "to" : "from");
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "Call reference = %d = %02x", (buf[i] & 0x7f));
- i++;
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xff, "Call reference = %d = %02x", (buf[i]));
- break;
- }
- i++;
-
- /* message type */
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x80, "Message type extension = %d", buf[i] & 0x80 ? 1 : 0);
-
- if(buf[i] <= MTTAB_MAX)
- strcpy(buffer, mttab[buf[i]]);
- else
- sprintf(buffer, "unknown (0x%02x)", buf[i]);
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "Message type = %s", buffer);
- i++;
-
- /* information elements */
-
- for (; i < n;)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x80, "%s Information element", buf[i] & 0x80 ? "Single octet" : "Variable length");
-
- if(buf[i] & 0x80)
- {
- /* single octett info element type 1 */
-
- if((buf[i] & 0x70) == 0x00)
- {
- strcpy(buffer, "Reserved");
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x70, "Reserved");
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x0f, "Reserved, content of IE");
- }
- else if((buf[i] & 0x70) == 0x10)
- {
- strcpy(buffer, "Shift");
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x70, "Shift");
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x08, "%s shift", buf[i] & 0x08 ? "Non-locking" : "Locking");
-
- switch(buf[i] & 0x07)
- {
- case 0:
- strcpy(buffer, "Not applicable");
- break;
- case 1:
- case 2:
- case 3:
- sprintf(buffer, "Reserved (%d)", buf[i] & 0x07);
- break;
- case 4:
- strcpy(buffer, "Codeset 4 (ISO/IEC)");
- break;
- case 5:
- strcpy(buffer, "Codeset 5 (National use)");
- break;
- case 6:
- strcpy(buffer, "Codeset 6 (Local network specific)");
- break;
- case 7:
- strcpy(buffer, "Codeset 7 (User specific)");
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x07, "%s", buffer);
- break;
- }
- else if((buf[i] & 0x70) == 0x30)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x70, "Congestion Level");
- switch(buf[i] & 0x0f)
- {
- case 0x00:
- strcpy(buffer, "receiver ready");
- break;
- case 0x0f:
- strcpy(buffer, "receiver not ready");
- break;
- default:
- sprintf(buffer, "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x0f, "Congestion Level = ", buffer);
- break;
- }
- else if((buf[i] & 0x70) == 0x50)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x70, "Repeat Indicator");
- switch(buf[i] & 0x0f)
- {
- case 0x02:
- strcpy(buffer, "Prioritized list for selecting one possibility");
- break;
- default:
- sprintf(buffer, "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x0f, "Repeat indication = ", buffer);
- break;
- }
-
- /* single octett info element type 2 */
-
- else if((buf[i] & 0x7f) == 0x20)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "More data");
- }
- else if((buf[i] & 0x7f) == 0x21)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "Sending complete");
- }
- else
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xff, "UNKNOWN single octet IE = 0x%02x", buf[i]);
- }
- i++; /* next */
- }
- else
- {
- if(codeset == 0)
- {
- struct ie *iep = &ietab[0];
-
- for(;;)
- {
- if((iep->code == buf[i]) ||
- (iep->code == 0xff))
- break;
- iep++;
- }
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "IE = %s", iep->name);
- sprintline(3, pbuf+strlen(pbuf), off+i+1, buf[i+1], 0xff, "IE Length = %d", buf[i+1]);
-
- if(iep->func == f_null)
- {
- }
- else
- {
- i += (iep->func)(pbuf, &buf[i], off+i);
- goto next;
- }
- }
- else
- {
- sprintf((pbuf+strlen(pbuf)), "UNKNOWN CODESET=%d, IE=0x%02x", codeset, buf[i]);
- }
-
- i++; /* index -> length */
-
- len = buf[i];
-
- sprintf((pbuf+strlen(pbuf)), "LEN=0x%02x, DATA=", len);
-
- i++; /* index -> 1st param */
-
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf)),"0x%02x ", buf[j+i]);
- }
-
- sprintf((pbuf+strlen(pbuf)),"]");
-
- i += len;
-
-next:
-
- if(!codelock && (codeset != oldcodeset))
- codeset = oldcodeset;
- }
- }
-/* sprintf((pbuf+strlen(pbuf)),"\n"); */
-}
-
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdndecode/layer3_subr.c b/usr.sbin/i4b/isdndecode/layer3_subr.c
deleted file mode 100644
index e1480b6c6349..000000000000
--- a/usr.sbin/i4b/isdndecode/layer3_subr.c
+++ /dev/null
@@ -1,1045 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * layer3_subr.c - subroutines for IE decoding
- * -------------------------------------------
- *
- * $Id: layer3_subr.c,v 1.4 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:12:37 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "decode.h"
-
-/*---------------------------------------------------------------------------*
- * dummy function
- *---------------------------------------------------------------------------*/
-int
-f_null(char *pbuf, unsigned char *buf, int off)
-{
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-f_cstat(char *pbuf, unsigned char *buf, int off)
-{
- int i = 0;
- int len = 0;
- char buffer[256];
-
- i++;
- len = buf[i];
- i++;
- sprintf((pbuf+strlen(pbuf)), "Std=");
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- strcpy(buffer, "CCITT");
- break;
- case 1:
- strcpy(buffer, "ISO/IEC");
- break;
- case 2:
- strcpy(buffer, "National");
- break;
- case 3:
- strcpy(buffer, "Special");
- break;
- }
- sprintf((pbuf+strlen(pbuf)), ", State=");
-
- switch((buf[i] & 0x3f))
- {
- case 0:
- strcpy(buffer, "Null");
- break;
- case 1:
- strcpy(buffer, "Call initiated");
- break;
- case 2:
- strcpy(buffer, "Overlap sending");
- break;
- case 3:
- strcpy(buffer, "Outgoing call proceeding");
- break;
- case 4:
- strcpy(buffer, "Call delivered");
- break;
- case 6:
- strcpy(buffer, "Call present");
- break;
- case 7:
- strcpy(buffer, "Call received");
- break;
- case 8:
- strcpy(buffer, "Connect request");
- break;
- case 9:
- strcpy(buffer, "Incoming call proceeding");
- break;
- case 10:
- strcpy(buffer, "Active");
- break;
- case 11:
- strcpy(buffer, "Disconnect request");
- break;
- case 12:
- strcpy(buffer, "Disconnect indication");
- break;
- case 15:
- strcpy(buffer, "Suspend request");
- break;
- case 17:
- strcpy(buffer, "Resume request");
- break;
- case 19:
- strcpy(buffer, "Release request");
- break;
- case 22:
- strcpy(buffer, "Call abort");
- break;
- case 25:
- strcpy(buffer, "Overlap receiving");
- break;
- case 0x3d:
- strcpy(buffer, "Restart request");
- break;
- case 0x3e:
- strcpy(buffer, "Restart");
- break;
- default:
- strcpy(buffer, "ERROR: undefined/reserved");
- break;
- }
- sprintf((pbuf+strlen(pbuf)), "]");
- i++;
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-f_chid(char *pbuf, unsigned char *buf, int off)
-{
- int i = 0;
- int len = 0;
- char buffer[256];
-
- i++;
- len = buf[i];
- i++;
-
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x40, "Interface Id present = %s", buf[i] & 0x40 ? "Yes" : "No");
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x20, "Interface Type = %s", buf[i] & 0x20 ? "Other (PRI)" : "BRI");
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x10, "Spare");
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x08, "Channel = %s", buf[i] & 0x08 ? "exclusive" : "preferred");
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x04, "Channel is%s the D-Channel", buf[i] & 0x04 ? "" : " not");
-
- switch(buf[i] & 0x03)
- {
- case 0:
- strcpy(buffer, "no channel");
- break;
- case 1:
- strcpy(buffer, "B-1");
- break;
- case 2:
- strcpy(buffer, "B-2");
- break;
- case 3:
- strcpy(buffer, "any channel");
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x03, "Channel = %s", buffer);
-
- i++;
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-f_fac(char *pbuf, unsigned char *buf, int off)
-{
- return(q932_facility(pbuf, buf));
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-f_progi(char *pbuf, unsigned char *buf, int off)
-{
- int i = 0;
- int len = 0;
- char buffer[256];
-
- i++;
- len = buf[i];
- i++;
- sprintf((pbuf+strlen(pbuf)), "Std=");
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- strcpy(buffer, "CCITT");
- break;
- case 1:
- strcpy(buffer, "ISO/IEC");
- break;
- case 2:
- strcpy(buffer, "National");
- break;
- case 3:
- strcpy(buffer, "Local");
- break;
- }
- sprintf((pbuf+strlen(pbuf)), ", Loc=");
-
- switch((buf[i] & 0x0f))
- {
- case 0:
- strcpy(buffer, "User");
- break;
- case 1:
- strcpy(buffer, "Private network serving local user");
- break;
- case 2:
- strcpy(buffer, "Public network serving local user");
- break;
- case 3:
- strcpy(buffer, "Transit network");
- break;
- case 4:
- strcpy(buffer, "Public network serving remote user");
- break;
- case 5:
- strcpy(buffer, "Private network serving remote user");
- break;
- case 6:
- strcpy(buffer, "Network beyond interworking point");
- break;
- default:
- strcpy(buffer, "ERROR: undefined/reserved");
- break;
- }
-
- i++;
-
- sprintf((pbuf+strlen(pbuf)), "\n Description");
-
- switch((buf[i] & 0x7f))
- {
- case 1:
- strcpy(buffer, "Call is not end-to-end ISDN");
- break;
- case 2:
- strcpy(buffer, "Destination address is non-ISDN");
- break;
- case 3:
- strcpy(buffer, "Origination address is non-ISDN");
- break;
- case 4:
- strcpy(buffer, "Call has returned to the ISDN");
- break;
- case 5:
- strcpy(buffer, "Interworking occured, Service change");
- break;
- case 8:
- strcpy(buffer, "In-band info or appropriate pattern now available");
- break;
- default:
- strcpy(buffer, "ERROR: undefined/reserved");
- break;
- }
- sprintf((pbuf+strlen(pbuf)), "]");
- i++;
-
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-f_displ(char *pbuf, unsigned char *buf, int off)
-{
- int i = 0;
- int j = 0;
- int len = 0;
-
- i++;
- len = buf[i];
- i++;
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf)),"%c", buf[j+i]);
- }
- sprintf((pbuf+strlen(pbuf)),"]");
- i += j;
-
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-f_date(char *pbuf, unsigned char *buf, int off)
-{
- int i = 0;
- int j = 0;
- int len = 0;
-
- i++;
- len = buf[i];
- i++;
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xff, "Year = %02d", buf[i]);
- i++;
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xff, "Month = %02d", buf[i]);
- i++;
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xff, "Day = %02d", buf[i]);
- i++;
-
- j=3;
- if(j < len)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xff, "Hour = %02d", buf[i]);
- i++;
- j++;
- }
- if(j < len)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xff, "Minute = %02d", buf[i]);
- i++;
- j++;
- }
- if(j < len)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0xff, "Second = %02d", buf[i]);
- i++;
- j++;
- }
- i += len;
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print the cause
- *---------------------------------------------------------------------------*/
-int
-f_cause(char *pbuf, unsigned char *buf, int off)
-{
- int j;
- int len;
- int i = 0;
- int ls;
- char buffer[256];
-
- i++; /* index -> length */
-
- len = buf[i];
-
- i++; /* coding/location */
- len--;
-
- ls = buf[i];
-
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch((ls & 0x60) >> 5)
- {
- case 0:
- strcpy(buffer, "CCITT");
- break;
- case 1:
- strcpy(buffer, "ISO/IEC");
- break;
- case 2:
- strcpy(buffer, "National");
- break;
- case 3:
- strcpy(buffer, "Local");
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x60, "Coding Standard = %s", buffer);
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x10, "Spare");
-
- switch(ls & 0x0f)
- {
- case 0x00:
- strcpy(buffer, "user");
- break;
- case 0x01:
- strcpy(buffer, "private network serving local user");
- break;
- case 0x02:
- strcpy(buffer, "public network serving local user");
- break;
- case 0x03:
- strcpy(buffer, "transit network");
- break;
- case 0x04:
- strcpy(buffer, "public network serving remote user");
- break;
- case 0x05:
- strcpy(buffer, "private network serving remote user");
- break;
- case 0x07:
- strcpy(buffer, "international network");
- break;
- case 0x0a:
- strcpy(buffer, "network beyond interworking point");
- break;
- default:
- sprintf(buffer, "reserved (0x%02x)", ls & 0x0f);
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x0f, "Location = %s", buffer);
-
- i++;
- len--;
-
- if(!(ls & 0x80))
- {
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch(buf[i] & 0x7f)
- {
- case 0:
- strcpy(buffer, "Q.931");
- break;
- case 3:
- strcpy(buffer, "X.21");
- break;
- case 4:
- strcpy(buffer, "X.25");
- break;
- case 5:
- strcpy(buffer, "Q.1031/Q.1051");
- break;
- default:
- strcpy(buffer, "Reserved");
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "Recommendation = %s", buffer);
- i++;
- len--;
- }
-
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "Cause = %s", print_cause_q850(buf[i] & 0x7f));
-
- i++;
- len--;
-
- for(j = 0; j < len; j++)
- sprintline(3, (pbuf+strlen(pbuf)), off+i+j, buf[i+j], 0xff, "Diagnostics = %02d %s", buf[i+j]);
-
- i += (len+1);
-
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print the bearer capability
- *---------------------------------------------------------------------------*/
-int
-f_bc(char *pbuf, unsigned char *buf, int off)
-{
- int len;
- int i = 0;
- int mr = 0;
- char buffer[256];
-
- i++; /* index -> length */
-
- len = buf[i];
- i++;
-
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- strcpy(buffer, "CCITT");
- break;
- case 1:
- strcpy(buffer, "ISO/IEC");
- break;
- case 2:
- strcpy(buffer, "National");
- break;
- case 3:
- strcpy(buffer, "NSI Std");
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x60, "Coding standard = %s", buffer);
-
- switch(buf[i] & 0x1f)
- {
- case 0x00:
- strcpy(buffer, "speech");
- break;
- case 0x08:
- strcpy(buffer, "unrestricted digital information");
- break;
- case 0x09:
- strcpy(buffer, "restricted digital information");
- break;
- case 0x10:
- strcpy(buffer, "3.1 kHz audio");
- break;
- case 0x11:
- strcpy(buffer, "unrestricted digital information with tones");
- break;
- case 0x18:
- strcpy(buffer, "video");
- break;
- default:
- sprintf(buffer, "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x1f, "Capability = %s", buffer);
-
- i++;
- len--;
-
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- strcpy(buffer, "circuit");
- break;
- case 2:
- strcpy(buffer, "packet");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", ((buf[i] & 0x60) >> 5));
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x60, "Mode = %s", buffer);
-
- switch(buf[i] & 0x1f)
- {
- case 0x00:
- strcpy(buffer, "packet mode");
- break;
- case 0x10:
- strcpy(buffer, "64 kbit/s");
- break;
- case 0x11:
- strcpy(buffer, "2 x 64 kbit/s");
- break;
- case 0x13:
- strcpy(buffer, "384 kbit/s");
- break;
- case 0x15:
- strcpy(buffer, "1536 kbit/s");
- break;
- case 0x17:
- strcpy(buffer, "1920 kbit/s");
- break;
- case 0x18:
- strcpy(buffer, "Multirate");
- mr = 1;
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x1f, "Rate = %s", buffer);
-
- i++;
- len--;
-
- if(!len)
- goto exit;
-
- if(mr)
- {
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x60, "Rate multiplier = %d", buf[i] & 0x7f);
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- sprintf((pbuf+strlen(pbuf)), "\n layer1=");
-
- switch(buf[i] & 0x1f)
- {
- case 0x01:
- sprintf((pbuf+strlen(pbuf)), "V.110");
- break;
- case 0x02:
- sprintf((pbuf+strlen(pbuf)), "G.711 u-law");
- break;
- case 0x03:
- sprintf((pbuf+strlen(pbuf)), "G.711 A-law");
- break;
- case 0x04:
- sprintf((pbuf+strlen(pbuf)), "G.721");
- break;
- case 0x05:
- sprintf((pbuf+strlen(pbuf)), "H.221/H.242");
- break;
- case 0x07:
- sprintf((pbuf+strlen(pbuf)), "Non-Std");
- break;
- case 0x08:
- sprintf((pbuf+strlen(pbuf)), "V.120");
- break;
- case 0x09:
- sprintf((pbuf+strlen(pbuf)), "X.31");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
- i++;
- len--;
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n user rate=0x%02x ", buf[i] & 0x1f);
-
- if(buf[i] & 0x40)
- sprintf((pbuf+strlen(pbuf)), "(async,");
- else
- sprintf((pbuf+strlen(pbuf)), "(sync,");
-
- if(buf[i] & 0x20)
- sprintf((pbuf+strlen(pbuf)), "in-band neg. possible)");
- else
- sprintf((pbuf+strlen(pbuf)), "in-band neg not possible)");
-
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n clk/flow=0x%02x", buf[i] & 0x1f);
-
- sprintf((pbuf+strlen(pbuf)), "\n intermediate rate=");
-
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "not used");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "8 kbit/s");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "16 kbit/s");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "32 kbit/s");
- break;
- }
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n hdr/mfrm/etc.=0x%02x", buf[i]);
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n stop/data/parity=0x%02x", buf[i]);
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n modemtype=0x%02x", buf[i]);
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- switch(buf[i] & 0x7f)
- {
- case 0x42:
- sprintf((pbuf+strlen(pbuf)), "\n layer2=Q.921/I.441");
- break;
- case 0x46:
- sprintf((pbuf+strlen(pbuf)), "\n layer2=X.25 link");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "\n layer2=0x%02x",(buf[i] & 0x7f));
- break;
- }
- i++;
- len--;
-
- if(!len)
- goto exit;
-
- switch(buf[i] & 0x7f)
- {
- case 0x62:
- sprintf((pbuf+strlen(pbuf)), "\n layer3=Q.921/I.441");
- break;
- case 0x66:
- sprintf((pbuf+strlen(pbuf)), "\n layer3=X.25 packet");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "\n layer3=0x%02x",(buf[i] & 0x7f));
- break;
- }
- i++;
- len--;
-
-exit:
-
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print the ISDN (telephone) number
- *---------------------------------------------------------------------------*/
-int
-f_cnu(char *pbuf, unsigned char *buf, int off)
-{
- int j;
- int len;
- int i = 0;
- int tp;
- int ind = 0;
- char buffer[256];
-
- i++; /* index -> length */
- len = buf[i];
-
- i++; /* index -> type/plan */
- tp = buf[i];
-
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch((tp & 0x70) >> 4)
- {
- case 0:
- strcpy(buffer, "Unknown");
- break;
- case 1:
- strcpy(buffer, "International number");
- break;
- case 2:
- strcpy(buffer, "National number");
- break;
- case 3:
- strcpy(buffer, "Network specific number");
- break;
- case 4:
- strcpy(buffer, "Subscriber number");
- break;
- case 6:
- strcpy(buffer, "Abbreviated number");
- break;
- default:
- sprintf(buffer, "Reserved (%d), ", ((tp & 0x70) >> 4));
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x60, "Type = %s", buffer);
-
- switch(tp & 0x0f)
- {
- case 0:
- strcpy(buffer, "Unknown");
- break;
- case 1:
- strcpy(buffer, "ISDN (E.164)");
- break;
- case 3:
- strcpy(buffer, "Data (X.121)");
- break;
- case 4:
- strcpy(buffer, "Telex (F.69)");
- break;
- case 8:
- strcpy(buffer, "National");
- break;
- case 9:
- strcpy(buffer, "Private");
- break;
- default:
- sprintf(buffer, "Reserved (%d)", (tp & 0x0f));
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x0f, "Plan = %s", buffer);
-
- i++;
- len--;
-
- if(!(tp & 0x80))
- {
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- strcpy(buffer, "allowed");
- break;
- case 1:
- strcpy(buffer, "restricted");
- break;
- case 2:
- strcpy(buffer, "number not available");
- break;
- case 3:
- strcpy(buffer, "reserved");
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x60, "Presentation = %s", buffer);
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x1c, "Spare");
-
- switch(ind & 0x03)
- {
- case 0:
- strcpy(buffer, "user provided, not screened");
- break;
- case 1:
- strcpy(buffer, "user provided, verified & passed");
- break;
- case 2:
- strcpy(buffer, "user provided, verified & failed");
- break;
- case 3:
- strcpy(buffer, "network provided");
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x03, "Screening = %s", buffer);
- i++;
- len--;
- }
-
- for(j = 0; j < len; j++)
- {
- sprintline(3, (pbuf+strlen(pbuf)), off+i+j, buf[i+j], 0xff, "Number digit = %c", buf[i+j]);
- }
-
- i += j;
-
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print HL comatibility
- *---------------------------------------------------------------------------*/
-int
-f_hlc(char *pbuf, unsigned char *buf, int off)
-{
- int i = 0;
- int len = 0;
- char buffer[256];
-
- i++;
- len = buf[i];
-
- i++;
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch((buf[i] >> 5) & 0x03)
- {
- case 0: strcpy(buffer, "CCITT");
- break;
- case 1: strcpy(buffer, "ISO/IEC");
- break;
- case 2: strcpy(buffer, "National");
- break;
- case 3: strcpy(buffer, "Network");
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x60, "Coding standard = %s", buffer);
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x1c, "Interpretation = %s", ((buf[i] >> 2) & 0x07) == 0x04 ? "first" : "reserved");
-
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x03, "Presentation = %s", ((buf[i]) & 0x03) == 0x01 ? "High layer protocol profile" : "reserved");
-
- i++;
- len--;
-
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch(buf[i] & 0x7f)
- {
- case 0x01:
- strcpy(buffer, "Telephony");
- break;
- case 0x04:
- strcpy(buffer, "Fax Group 2/3 (F.182)");
- break;
- case 0x21:
- strcpy(buffer, "Fax Group 4 I (F.184)");
- break;
- case 0x24:
- strcpy(buffer, "Teletex (F.230) or Fax Group 4 II/III (F.184)");
- break;
- case 0x28:
- strcpy(buffer, "Teletex (F.220)");
- break;
- case 0x31:
- strcpy(buffer, "Teletex (F.200)");
- break;
- case 0x32:
- strcpy(buffer, "Videotex (F.300/T.102)");
- break;
- case 0x33:
- strcpy(buffer, "Videotex (F.300/T.101)");
- break;
- case 0x35:
- strcpy(buffer, "Telex (F.60)");
- break;
- case 0x38:
- strcpy(buffer, "MHS (X.400)");
- break;
- case 0x41:
- strcpy(buffer, "OSI (X.200)");
- break;
- case 0x5e:
- strcpy(buffer, "Maintenance");
- break;
- case 0x5f:
- strcpy(buffer, "Management");
- break;
- case 0x60:
- strcpy(buffer, "Audio visual (F.721)");
- break;
- default:
- sprintf(buffer, "Reserved (0x%02x)", buf[i] & 0x7f);
- break;
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "Characteristics = %s", buffer);
- i++;
- len--;
-
- if(buf[i-1] & 0x80)
- {
- return(i);
- }
-
- extension(3, pbuf+strlen(pbuf), off+i, buf[i], 0x80);
-
- switch(buf[i] & 0x7f)
- {
- case 0x01:
- strcpy(buffer, "Telephony");
- break;
- case 0x04:
- strcpy(buffer, "Fax Group 2/3 (F.182)");
- break;
- case 0x21:
- strcpy(buffer, "Fax Group 4 I (F.184)");
- break;
- case 0x24:
- strcpy(buffer, "Teletex (F.230) or Fax Group 4 II/III (F.184)");
- break;
- case 0x28:
- strcpy(buffer, "Teletex (F.220)");
- break;
- case 0x31:
- strcpy(buffer, "Teletex (F.200)");
- break;
- case 0x32:
- strcpy(buffer, "Videotex (F.300/T.102)");
- break;
- case 0x33:
- strcpy(buffer, "Videotex (F.300/T.101)");
- break;
- case 0x35:
- strcpy(buffer, "Telex (F.60)");
- break;
- case 0x38:
- strcpy(buffer, "MHS (X.400)");
- break;
- case 0x41:
- strcpy(buffer, "OSI (X.200)");
- break;
- case 0x5e:
- strcpy(buffer, "Maintenance");
- break;
- case 0x5f:
- strcpy(buffer, "Management");
- break;
- case 0x60:
- strcpy(buffer, "Audio visual (F.721)");
- break;
- default:
- sprintf(buffer, "Reserved (0x%02x)", buf[i] & 0x7f);
- break;
-
- }
- sprintline(3, (pbuf+strlen(pbuf)), off+i, buf[i], 0x7f, "Ext. characteristics = %s", buffer);
- i++;
- return(i);
-}
-
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdndecode/main.c b/usr.sbin/i4b/isdndecode/main.c
deleted file mode 100644
index a73d708d0bde..000000000000
--- a/usr.sbin/i4b/isdndecode/main.c
+++ /dev/null
@@ -1,774 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * main.c - isdndecode main program file
- * -------------------------------------
- *
- * $Id: main.c,v 1.6 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:12:52 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "decode.h"
-
-unsigned char buf[BSIZE];
-FILE *Fout = NULL;
-FILE *BP = NULL;
-int outflag = 1;
-int header = 1;
-int print_q921 = 1;
-int unit = 0;
-int dchan = 0;
-int bchan = 0;
-int traceon = 0;
-int analyze = 0;
-int Rx = RxUDEF;
-int Tx = TxUDEF;
-int f;
-int Bopt = 0;
-int Popt = 0;
-int bpopt = 0;
-int info = 0;
-
-static char outfilename[1024];
-static char BPfilename[1024];
-
-static void dumpbuf( int n, unsigned char *buf, i4b_trace_hdr_t *hdr);
-static int switch_driver( int value, int rx, int tx );
-static void usage( void );
-static void exit_hdl( void );
-static void reopenfiles( int );
-
-/*---------------------------------------------------------------------------*
- * main
- *---------------------------------------------------------------------------*/
-int
-main(int argc, char *argv[])
-{
- extern int optind;
- extern int opterr;
- extern char *optarg;
- char devicename[80];
- char headerbuf[256];
-
- int n;
- int c;
- char *b;
-
- int enable_trace = TRACE_D_RX | TRACE_D_TX;
- char *outfile = DECODE_FILE_NAME;
- char *binfile = BIN_FILE_NAME;
- int outfileset = 0;
- time_t tm;
-
- i4b_trace_hdr_t *ithp = NULL;
- int l;
-
- b = &buf[sizeof(i4b_trace_hdr_t)];
-
- while( (c = getopt(argc, argv, "abdf:hiln:op:u:BPR:T:?")) != EOF)
- {
- switch(c)
- {
- case 'a':
- analyze = 1;
- break;
-
- case 'b':
- enable_trace |= (TRACE_B_RX | TRACE_B_TX);
- break;
-
- case 'd':
- enable_trace &= (~(TRACE_D_TX | TRACE_D_RX));
- break;
-
- case 'o':
- outflag = 0;
- break;
-
- case 'f':
- outfile = optarg;
- outfileset = 1;
- break;
-
- case 'h':
- header = 0;
- break;
-
- case 'i':
- enable_trace |= TRACE_I;
- info = 1;
- break;
-
- case 'l':
- print_q921 = 0;
- break;
-
- case 'p':
- binfile = optarg;
- bpopt = 1;
- break;
-
- case 'u':
- unit = atoi(optarg);
- if(unit < 0 || unit >= MAX_CONTROLLERS)
- usage();
- break;
-
- case 'B':
- Bopt = 1;
- break;
-
- case 'P':
- Popt = 1;
- break;
-
- case 'R':
- Rx = atoi(optarg);
- if(Rx < 0 || Rx >= MAX_CONTROLLERS)
- usage();
- break;
-
- case 'T':
- Tx = atoi(optarg);
- if(Tx < 0 || Tx >= MAX_CONTROLLERS)
- usage();
- break;
-
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if(enable_trace == 0)
- usage();
-
- if(Bopt && Popt)
- usage();
-
- atexit(exit_hdl);
-
- if(Bopt)
- {
- if(bpopt)
- sprintf(BPfilename, "%s", binfile);
- else
- sprintf(BPfilename, "%s%d", BIN_FILE_NAME, unit);
-
- if((BP = fopen(BPfilename, "r")) != NULL)
- {
- char buffer[1024];
- fclose(BP);
- sprintf(buffer, "%s%s", BPfilename, DECODE_FILE_NAME_BAK);
- rename(BPfilename, buffer);
- }
- if((BP = fopen(BPfilename, "w")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error opening file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
-
- if((setvbuf(BP, (char *)NULL, _IONBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error setting file [%s] to unbuffered", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
-
- if(Popt)
- {
- if(bpopt)
- sprintf(BPfilename, "%s", binfile);
- else
- sprintf(BPfilename, "%s%d", BIN_FILE_NAME, unit);
-
- if((BP = fopen(BPfilename, "r")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error opening file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
- else
- {
- sprintf(devicename, "%s%d", I4BTRC_DEVICE, unit);
-
- if((f = open(devicename, O_RDWR)) < 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error opening trace device [%s]", devicename);
- perror(buffer);
- exit(1);
- }
- }
-
- if(outflag)
- {
- if(outfileset == 0)
- sprintf(outfilename, "%s%d", DECODE_FILE_NAME, unit);
- else
- strcpy(outfilename, outfile);
-
-
- if((Fout = fopen(outfilename, "r")) != NULL)
- {
- char buffer[1024];
- fclose(Fout);
- sprintf(buffer, "%s%s", outfilename, DECODE_FILE_NAME_BAK);
- rename(outfilename, buffer);
- }
-
- if((Fout = fopen(outfilename, "w")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error opening file [%s]", outfilename);
- perror(buffer);
- exit(1);
- }
-
- if((setvbuf(Fout, (char *)NULL, _IONBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error setting file [%s] to unbuffered", outfile);
- perror(buffer);
- exit(1);
- }
- }
-
- if((setvbuf(stdout, (char *)NULL, _IOLBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error setting stdout to line-buffered");
- perror(buffer);
- exit(1);
- }
-
- if(!Popt)
- {
- if((switch_driver(enable_trace, Rx, Tx)) == -1)
- exit(1);
- else
- traceon = 1;
- }
-
- signal(SIGHUP, SIG_IGN); /* ignore hangup signal */
- signal(SIGUSR1, reopenfiles); /* rotate logfile(s) */
-
- time(&tm);
-
- if(analyze)
- {
- sprintf(headerbuf, "\n==== isdnanalyze controller rx #%d - tx #%d ==== started %s",
- Rx, Tx, ctime(&tm));
- }
- else
- {
- sprintf(headerbuf, "\n=========== isdntrace controller #%d =========== started %s",
- unit, ctime(&tm));
- }
-
- printf("%s", headerbuf);
-
- if(outflag)
- fprintf(Fout, "%s", headerbuf);
-
- for (;;)
- {
- if(Popt == 0)
- {
- n = read(f, buf, BSIZE);
-
- if(Bopt)
- {
- if((fwrite(buf, 1, n, BP)) != n)
- {
- char buffer[80];
- sprintf(buffer, "Error writing file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
-
- n -= sizeof(i4b_trace_hdr_t);
- }
- else
- {
- if((fread(buf, 1, sizeof(i4b_trace_hdr_t), BP)) != sizeof(i4b_trace_hdr_t))
- {
- if(feof(BP))
- {
- printf("\nEnd of playback input file reached.\n");
- exit(0);
- }
- else
- {
- char buffer[80];
- sprintf(buffer, "Error reading hdr from file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
-
- ithp = (i4b_trace_hdr_t *)buf;
- l = ithp->length - sizeof(i4b_trace_hdr_t);
-
- if((n = fread(buf+sizeof(i4b_trace_hdr_t), 1, l , BP)) != l)
- {
- char buffer[80];
- sprintf(buffer, "Error reading data from file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
-
- }
-
- if(n > 0)
- {
- dumpbuf(n, b, (i4b_trace_hdr_t *)buf);
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * format header into static buffer, return buffer address
- *---------------------------------------------------------------------------*/
-char *
-fmt_hdr(i4b_trace_hdr_t *hdr, int frm_len)
-{
- struct tm *s;
- static char hbuf[256];
- int i = 0;
-
- s = localtime(&(hdr->time.tv_sec));
-
- if(hdr->type == TRC_CH_I) /* Layer 1 INFO's */
- {
- sprintf(hbuf,"\n-- %s - unit:%d ---------------- time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%06u ",
- ((hdr->dir) ? "NT->TE" : "TE->NT"),
- hdr->unit,
- s->tm_mday,
- s->tm_mon + 1,
- s->tm_hour,
- s->tm_min,
- s->tm_sec,
- (u_int32_t)hdr->time.tv_usec);
- }
- else
- {
- if(hdr->trunc > 0)
- {
- sprintf(hbuf,"\n-- %s - unit:%d - frame:%6.6u - time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%06u - length:%d (%d) ",
- ((hdr->dir) ? "NT->TE" : "TE->NT"),
- hdr->unit,
- hdr->count,
- s->tm_mday,
- s->tm_mon + 1,
- s->tm_hour,
- s->tm_min,
- s->tm_sec,
- (u_int32_t)hdr->time.tv_usec,
- frm_len,
- hdr->trunc);
- }
- else
- {
- sprintf(hbuf,"\n-- %s - unit:%d - frame:%6.6u - time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%06u - length:%d ",
- ((hdr->dir) ? "NT->TE" : "TE->NT"),
- hdr->unit,
- hdr->count,
- s->tm_mday,
- s->tm_mon + 1,
- s->tm_hour,
- s->tm_min,
- s->tm_sec,
- (u_int32_t)hdr->time.tv_usec,
- frm_len);
- }
- }
-
- for(i=strlen(hbuf); i <= NCOLS;)
- hbuf[i++] = '-';
-
- hbuf[i++] = '\n';
- hbuf[i] = '\0';
-
- return(hbuf);
-}
-
-/*---------------------------------------------------------------------------*
- * decode protocol and output to file(s)
- *---------------------------------------------------------------------------*/
-static void
-dumpbuf(int n, unsigned char *buf, i4b_trace_hdr_t *hdr)
-{
- static char l1buf[128];
- static unsigned char l2buf[32000];
- static unsigned char l3buf[32000];
- int cnt;
- int nsave = n;
- char *pbuf;
- int i, j;
-
- l1buf[0] = '\0';
- l2buf[0] = '\0';
- l3buf[0] = '\0';
-
- switch(hdr->type)
- {
- case TRC_CH_I: /* Layer 1 INFO's */
- layer1(l1buf, buf);
- break;
-
- case TRC_CH_D: /* D-channel data */
- cnt = layer2(l2buf, buf, hdr->dir, print_q921);
-
- n -= cnt;
- buf += cnt;
-
- if(n)
- layer3(l3buf, n, cnt, buf);
- break;
-
- default: /* B-channel data */
-
- pbuf = &l2buf[0];
-
- for (i = 0; i < n; i += 16)
- {
- sprintf((pbuf+strlen(pbuf)),"B%d:%.3x ", hdr->type, i);
-
- for (j = 0; j < 16; j++)
- if (i + j < n)
- sprintf((pbuf+strlen(pbuf)),"%02x ", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf))," ");
-
- sprintf((pbuf+strlen(pbuf))," ");
-
- for (j = 0; j < 16 && i + j < n; j++)
- if (isprint(buf[i + j]))
- sprintf((pbuf+strlen(pbuf)),"%c", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf)),".");
-
- sprintf((pbuf+strlen(pbuf)),"\n");
- }
- break;
- }
-
- if(header && ((l1buf[0] != '\0' || l2buf[0] != '\0') || (l3buf[0] != 0)))
- {
- char *p;
- p = fmt_hdr(hdr, nsave);
- printf("%s", p);
- if(outflag)
- fprintf(Fout, "%s", p);
- }
-
- if(l1buf[0] != '\0')
- {
- printf("%s", l1buf);
- if(outflag)
- fprintf(Fout, "%s", l1buf);
- }
-
- if(l2buf[0] != '\0')
- {
- printf("%s", l2buf);
- if(outflag)
- fprintf(Fout, "%s", l2buf);
- }
-
- if(l3buf[0] != '\0')
- {
- printf("%s", l3buf);
- if(outflag)
- fprintf(Fout, "%s", l3buf);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * exit handler function to be called at program exit
- *---------------------------------------------------------------------------*/
-void
-exit_hdl()
-{
- if(traceon)
- switch_driver(TRACE_OFF, Rx, Tx);
-}
-
-/*---------------------------------------------------------------------------*
- * switch driver debugging output on/off
- *---------------------------------------------------------------------------*/
-static int
-switch_driver(int value, int rx, int tx)
-{
- char buffer[80];
- int v = value;
-
- if(analyze == 0)
- {
- if(ioctl(f, I4B_TRC_SET, &v) < 0)
- {
- sprintf(buffer, "Error ioctl I4B_TRC_SET, val = %d", v);
- perror(buffer);
- return(-1);
- }
- }
- else
- {
- if(value == TRACE_OFF)
- {
- if(ioctl(f, I4B_TRC_RESETA, &v) < 0)
- {
- sprintf(buffer, "Error ioctl I4B_TRC_RESETA - ");
- perror(buffer);
- return(-1);
- }
- }
- else
- {
- i4b_trace_setupa_t tsa;
-
- tsa.rxunit = rx;
- tsa.rxflags = value;
- tsa.txunit = tx;
- tsa.txflags = value;
-
- if(ioctl(f, I4B_TRC_SETA, &tsa) < 0)
- {
- sprintf(buffer, "Error ioctl I4B_TRC_SETA, val = %d", v);
- perror(buffer);
- return(-1);
- }
- }
- }
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * reopen files to support rotating logfile(s) on SIGUSR1
- *
- * based on an idea from Ripley (ripley@nostromo.in-berlin.de)
- *
- * close file and reopen it for append. this will be a nop
- * if the previously opened file hasn't moved but will open
- * a new one otherwise, thus enabling a rotation...
- *
- *---------------------------------------------------------------------------*/
-static void
-reopenfiles(int dummy)
-{
- if(outflag)
- {
- fclose(Fout);
-
- if((Fout = fopen(outfilename, "a")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error re-opening file [%s]", outfilename);
- perror(buffer);
- exit(1);
- }
-
- if((setvbuf(Fout, (char *)NULL, _IONBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error re-setting file [%s] to unbuffered", outfilename);
- perror(buffer);
- exit(1);
- }
- }
-
- if(Bopt)
- {
-
- fclose(BP);
-
- if((BP = fopen(BPfilename, "a")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error re-opening file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
-
- if((setvbuf(BP, (char *)NULL, _IONBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error re-setting file [%s] to unbuffered", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * decode extension bit
- *---------------------------------------------------------------------------*/
-void
-extension(int layer, char *buffer, int cnt, unsigned char value, unsigned char mask)
-{
- sprintline(layer, buffer, cnt, value, mask, "Extension Bit = %c (%s)",
- (value & mask) ? '1' : '0',
- (value & mask) ? "no extension, final octet" : "with extension, octet follows");
-}
-
-/*---------------------------------------------------------------------------*
- * print bits as 0/1 available for mask
- *---------------------------------------------------------------------------*/
-static char *
-print_bits(unsigned char val, unsigned char mask)
-{
- static char buffer[10];
- int i = 0;
- int length = 8;
-
- while(length--)
- {
- if(mask & 0x80)
- {
- if(val & 0x80)
- buffer[i++] = '1';
- else
- buffer[i++] = '0';
- }
- else
- {
- buffer[i++] = '-';
- }
- val = val << 1;
- mask = mask << 1;
- }
- buffer[i] = '\0';
- return(buffer);
-}
-
-/*---------------------------------------------------------------------------*
- * print one decoded output line
- *---------------------------------------------------------------------------*/
-void
-sprintline(int layer, char *buffer, int oct_count, int oct_val,
- int oct_mask, const char *fmt, ...)
-{
- char lbuffer[256];
- static int lastcount = -1;
- char *ptr;
- va_list ap;
-
- va_start(ap, fmt);
-
- if(oct_count != lastcount)
- {
- lastcount = oct_count;
-
- sprintf(lbuffer, "L%d %2d %02X %s ",
- layer,
- oct_count,
- oct_val,
- print_bits(oct_val, oct_mask));
- }
- else
- {
- sprintf(lbuffer, " %s ",
- print_bits(oct_val, oct_mask));
- }
-
- vsprintf(lbuffer+strlen(lbuffer), fmt, ap);
-
- va_end(ap);
-
- sprintf(lbuffer+strlen(lbuffer), "\n");
-
- if((ptr = rindex(lbuffer, '(')) != NULL)
- {
- char *s = lbuffer;
- char *b = buffer;
- int len = strlen(lbuffer);
- int i;
-
- for(s = lbuffer; s < ptr; *b++ = *s++)
- ;
- for(i = 0;(i+len) <= NCOLS; *b++ = ' ', i++)
- ;
- for(; *s; *b++ = *s++)
- ;
- *b = '\0';
- }
- else
- {
- strcpy(buffer, lbuffer);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * usage intructions
- *---------------------------------------------------------------------------*/
-void
-usage(void)
-{
- fprintf(stderr,"\n");
- fprintf(stderr,"isdndecode - isdn4bsd package ISDN decoder for passive cards (%02d.%02d)\n", VERSION, REL);
- fprintf(stderr,"usage: isdntrace -a -b -d -f <file> -h -i -l -n <val> -o -p <file> -r -u <unit>\n");
- fprintf(stderr," -B -P -R <unit> -T <unit>\n");
- fprintf(stderr," -a analyzer mode ................................... (default off)\n");
- fprintf(stderr," -b switch B channel trace on ....................... (default off)\n");
- fprintf(stderr," -d switch D channel trace off ....................... (default on)\n");
- fprintf(stderr," -f <file> write output to file filename ............ (default %s0)\n", DECODE_FILE_NAME);
- fprintf(stderr," -h don't print header for each message ............. (default off)\n");
- fprintf(stderr," -i print I.430 (layer 1) INFO signals .............. (default off)\n");
- fprintf(stderr," -l don't decode low layer Q.921 messages ........... (default off)\n");
- fprintf(stderr," -o don't write output to a file .................... (default off)\n");
- fprintf(stderr," -p <file> specify filename for -B and -P ........ (default %s0)\n", BIN_FILE_NAME);
- fprintf(stderr," -u <unit> specify controller unit number ............... (default unit 0)\n");
- fprintf(stderr," -B write binary trace data to file filename ........ (default off)\n");
- fprintf(stderr," -P playback from binary trace data file ............ (default off)\n");
- fprintf(stderr," -R <unit> analyze Rx controller unit number (for -a) ... (default unit %d)\n", RxUDEF);
- fprintf(stderr," -T <unit> analyze Tx controller unit number (for -a) ... (default unit %d)\n", TxUDEF);
- fprintf(stderr,"\n");
- exit(1);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdndecode/pcause.c b/usr.sbin/i4b/isdndecode/pcause.c
deleted file mode 100644
index 9c5535e21e12..000000000000
--- a/usr.sbin/i4b/isdndecode/pcause.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * pcause.c - printing cause values
- * --------------------------------
- *
- * $Id: pcause.c,v 1.3 1998/12/23 10:03:55 hm Exp $
- *
- * last edit-date: [Wed Dec 23 10:59:54 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "decode.h"
-#include "pcause.h"
-
-char *
-print_cause_q850(unsigned char code)
-{
- static char error_message[120];
- char *e;
-
- switch(code)
- {
- case CAUSE_Q850_SHUTDN:
- e = "normal D-channel shutdown";
- break;
-
- case CAUSE_Q850_NUNALLC:
- e = "Unallocated (unassigned) number";
- break;
-
- case CAUSE_Q850_NRTTN:
- e = "No route to specified transit network";
- break;
-
- case CAUSE_Q850_NRTDST:
- e = "No route to destination";
- break;
-
- case CAUSE_Q850_SSINFTN:
- e = "Send special information tone";
- break;
-
- case CAUSE_Q850_MDIALTP:
- e = "Misdialled trunk prefix";
- break;
-
- case CAUSE_Q850_CHUNACC:
- e = "Channel unacceptable";
- break;
-
- case CAUSE_Q850_CALLAWD:
- e = "Call awarded and being delivered in an established channel";
- break;
-
- case CAUSE_Q850_PREEMPT:
- e = "Preemption";
- break;
-
- case CAUSE_Q850_PREECRR:
- e = "Preemption - circuit reserved for reuse";
- break;
-
- case CAUSE_Q850_NCCLR:
- e = "Normal call clearing";
- break;
-
- case CAUSE_Q850_USRBSY:
- e = "User busy";
- break;
-
- case CAUSE_Q850_NOUSRRSP:
- e = "No user responding";
- break;
-
- case CAUSE_Q850_NOANSWR:
- e = "No answer from user (user alerted)";
- break;
-
- case CAUSE_Q850_SUBSABS:
- e = "Subscriber absent";
- break;
-
- case CAUSE_Q850_CALLREJ:
- e = "Call rejected";
- break;
-
- case CAUSE_Q850_NUCHNG:
- e = "Number changed";
- break;
-
- case CAUSE_Q850_NONSELUC:
- e = "Non-selected user clearing";
- break;
-
- case CAUSE_Q850_DSTOOORDR:
- e = "Destination out of order";
- break;
-
- case CAUSE_Q850_INVNUFMT:
- e = "Invalid number format";
- break;
-
- case CAUSE_Q850_FACREJ:
- e = "Facility rejected";
- break;
-
- case CAUSE_Q850_STENQRSP:
- e = "Response to STATUS ENQUIRY";
- break;
-
- case CAUSE_Q850_NORMUNSP:
- e = "Normal, unspecified";
- break;
-
- case CAUSE_Q850_NOCAVAIL:
- e = "No circuit / channel available";
- break;
-
- case CAUSE_Q850_NETOOORDR:
- e = "Network out of order";
- break;
-
- case CAUSE_Q850_PFMCDOOSERV:
- e = "Permanent frame mode connection out of service";
- break;
-
- case CAUSE_Q850_PFMCOPER:
- e = "Permanent frame mode connection operational";
- break;
-
- case CAUSE_Q850_TMPFAIL:
- e = "Temporary failure";
- break;
-
- case CAUSE_Q850_SWEQCONG:
- e = "Switching equipment congestion";
- break;
-
- case CAUSE_Q850_ACCINFDIS:
- e = "Access information discarded";
- break;
-
- case CAUSE_Q850_REQCNOTAV:
- e = "Requested circuit/channel not available";
- break;
-
- case CAUSE_Q850_PRECALBLK:
- e = "Precedence call blocked";
- break;
-
- case CAUSE_Q850_RESUNAVAIL:
- e = "Resources unavailable, unspecified";
- break;
-
- case CAUSE_Q850_QOSUNAVAIL:
- e = "Quality of service unavailable";
- break;
-
- case CAUSE_Q850_REQSERVNS:
- e = "Requested facility not subscribed";
- break;
-
- case CAUSE_Q850_OCBARRCUG:
- e = "Outgoing calls barred within CUG";
- break;
-
- case CAUSE_Q850_ICBARRCUG:
- e = "Incoming calls barred within CUG";
- break;
-
- case CAUSE_Q850_BCAPNAUTH:
- e = "Bearer capability not authorized";
- break;
-
- case CAUSE_Q850_BCAPNAVAIL:
- e = "Bearer capability not presently available";
- break;
-
- case CAUSE_Q850_INCSTOACISC:
- e = "Inconsistenciy in designated outg. access info and subscriber class";
- break;
-
- case CAUSE_Q850_SOONOTAVAIL:
- e = "Service or option not available, unspecified";
- break;
-
- case CAUSE_Q850_BCAPNOTIMPL:
- e = "Bearer capability not implemented";
- break;
-
- case CAUSE_Q850_CHTYPNIMPL:
- e = "Channel type not implemented";
- break;
-
- case CAUSE_Q850_REQFACNIMPL:
- e = "Requested facility not implemented";
- break;
-
- case CAUSE_Q850_ORDINBCAVL:
- e = "Only restricted digital information bearer capability is available";
- break;
-
- case CAUSE_Q850_SOONOTIMPL:
- e = "Service or option not implemented, unspecified";
- break;
-
- case CAUSE_Q850_INVCLRFVAL:
- e = "Invalid call reference value";
- break;
-
- case CAUSE_Q850_IDCHDNOEX:
- e = "Identified channel does not exist";
- break;
-
- case CAUSE_Q850_SUSCAEXIN:
- e = "A suspended call exists, but this call identity does not";
- break;
-
- case CAUSE_Q850_CLIDINUSE:
- e = "Call identity in use";
- break;
-
- case CAUSE_Q850_NOCLSUSP:
- e = "No call suspended";
- break;
-
- case CAUSE_Q850_CLIDCLRD:
- e = "Call having the requested call identity has been cleared";
- break;
-
- case CAUSE_Q850_UNOTMEMCUG:
- e = "User not member of CUG";
- break;
-
- case CAUSE_Q850_INCDEST:
- e = "Incompatible destination";
- break;
-
- case CAUSE_Q850_NONEXCUG:
- e = "Non-existent CUG";
- break;
-
- case CAUSE_Q850_INVNTWSEL:
- e = "Invalid transit network selection";
- break;
-
- case CAUSE_Q850_INVMSG:
- e = "Invalid message, unspecified";
- break;
-
- case CAUSE_Q850_MIEMISS:
- e = "Mandatory information element is missing";
- break;
-
- case CAUSE_Q850_MSGTNI:
- e = "Message type non-existent or not implemented";
- break;
-
- case CAUSE_Q850_MSGNCMPT:
- e = "Msg incompatible with call state/message type non-existent/not implemented";
- break;
-
- case CAUSE_Q850_IENENI:
- e = "Information element/parameter non-existent or not implemented";
- break;
-
- case CAUSE_Q850_INVIEC:
- e = "Invalid information element contents";
- break;
-
- case CAUSE_Q850_MSGNCWCS:
- e = "Message not compatible with call state";
- break;
-
- case CAUSE_Q850_RECOTIMEXP:
- e = "Recovery on timer expiry";
- break;
-
- case CAUSE_Q850_PARMNENIPO:
- e = "Parameter non-existent or not implemented, passed on";
- break;
-
- case CAUSE_Q850_MSGUNRDPRM:
- e = "Message with unrecognized parameter, discarded";
- break;
-
- case CAUSE_Q850_PROTERR:
- e = "Protocol error, unspecified";
- break;
-
- case CAUSE_Q850_INTWRKU:
- e = "Interworking, unspecified";
- break;
-
- default:
- e = "ERROR, unknown cause value!";
- break;
- }
-
- sprintf(error_message, "%d: %s (Q.850)", code, e);
- return(error_message);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdndecode/pcause.h b/usr.sbin/i4b/isdndecode/pcause.h
deleted file mode 100644
index 6b6627bf358b..000000000000
--- a/usr.sbin/i4b/isdndecode/pcause.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * pcause.h - Q.850 causes definitions
- * -----------------------------------
- *
- * $Id: pcause.h,v 1.2 1998/12/18 17:09:38 hm Exp $
- *
- * last edit-date: [Fri Dec 18 18:13:23 1998]
- *
- *---------------------------------------------------------------------------*/
-
-char *print_cause_q850(unsigned char code);
-
-/* Q.850 causes */
-
-#define CAUSE_Q850_SHUTDN 0x00 /* normal D-channel shutdown */
-#define CAUSE_Q850_NUNALLC 0x01 /* Unallocated (unassigned) number */
-#define CAUSE_Q850_NRTTN 0x02 /* No route to specified transit network */
-#define CAUSE_Q850_NRTDST 0x03 /* No route to destination */
-#define CAUSE_Q850_SSINFTN 0x04 /* Send special information tone */
-#define CAUSE_Q850_MDIALTP 0x05 /* Misdialled trunk prefix */
-#define CAUSE_Q850_CHUNACC 0x06 /* Channel unacceptable */
-#define CAUSE_Q850_CALLAWD 0x07 /* Call awarded and being delivered in an established channel */
-#define CAUSE_Q850_PREEMPT 0x08 /* Preemption */
-#define CAUSE_Q850_PREECRR 0x09 /* Preemption - circuit reserved for reuse */
-#define CAUSE_Q850_NCCLR 0x10 /* Normal call clearing */
-#define CAUSE_Q850_USRBSY 0x11 /* User busy */
-#define CAUSE_Q850_NOUSRRSP 0x12 /* No user responding */
-#define CAUSE_Q850_NOANSWR 0x13 /* No answer from user (user alerted) */
-#define CAUSE_Q850_SUBSABS 0x14 /* Subscriber absent */
-#define CAUSE_Q850_CALLREJ 0x15 /* Call rejected */
-#define CAUSE_Q850_NUCHNG 0x16 /* Number changed */
-#define CAUSE_Q850_NONSELUC 0x1A /* Non-selected user clearing */
-#define CAUSE_Q850_DSTOOORDR 0x1B /* Destination out of order */
-#define CAUSE_Q850_INVNUFMT 0x1C /* Invalid number format */
-#define CAUSE_Q850_FACREJ 0x1D /* Facility rejected */
-#define CAUSE_Q850_STENQRSP 0x1E /* Response to STATUS ENQUIRY */
-#define CAUSE_Q850_NORMUNSP 0x1F /* Normal, unspecified */
-#define CAUSE_Q850_NOCAVAIL 0x22 /* No circuit / channel available */
-#define CAUSE_Q850_NETOOORDR 0x26 /* Network out of order */
-#define CAUSE_Q850_PFMCDOOSERV 0x27 /* Permanent frame mode connection out of service */
-#define CAUSE_Q850_PFMCOPER 0x28 /* Permanent frame mode connection operational */
-#define CAUSE_Q850_TMPFAIL 0x29 /* Temporary failure */
-#define CAUSE_Q850_SWEQCONG 0x2A /* Switching equipment congestion */
-#define CAUSE_Q850_ACCINFDIS 0x2B /* Access information discarded */
-#define CAUSE_Q850_REQCNOTAV 0x2C /* Requested circuit/channel not available */
-#define CAUSE_Q850_PRECALBLK 0x2E /* Precedence call blocked */
-#define CAUSE_Q850_RESUNAVAIL 0x2F /* Resources unavailable, unspecified */
-#define CAUSE_Q850_QOSUNAVAIL 0x31 /* Quality of service unavailable */
-#define CAUSE_Q850_REQSERVNS 0x32 /* Requested facility not subscribed */
-#define CAUSE_Q850_OCBARRCUG 0x35 /* Outgoing calls barred within CUG */
-#define CAUSE_Q850_ICBARRCUG 0x36 /* Incoming calls barred within CUG */
-#define CAUSE_Q850_BCAPNAUTH 0x39 /* Bearer capability not authorized */
-#define CAUSE_Q850_BCAPNAVAIL 0x3A /* Bearer capability not presently available */
-#define CAUSE_Q850_INCSTOACISC 0x3E /* Inconsistenciy in designated outgoing access information and subscriber class */
-#define CAUSE_Q850_SOONOTAVAIL 0x3F /* Service or option not available, unspecified */
-#define CAUSE_Q850_BCAPNOTIMPL 0x41 /* Bearer capability not implemented */
-#define CAUSE_Q850_CHTYPNIMPL 0x42 /* Channel type not implemented */
-#define CAUSE_Q850_REQFACNIMPL 0x45 /* Requested facility not implemented */
-#define CAUSE_Q850_ORDINBCAVL 0x46 /* Only restricted digital information bearer capability is available */
-#define CAUSE_Q850_SOONOTIMPL 0x4F /* Service or option not implemented, unspecified */
-#define CAUSE_Q850_INVCLRFVAL 0x51 /* Invalid call reference value */
-#define CAUSE_Q850_IDCHDNOEX 0x52 /* Identified channel does not exist */
-#define CAUSE_Q850_SUSCAEXIN 0x53 /* A suspended call exists, but this call identity does not */
-#define CAUSE_Q850_CLIDINUSE 0x54 /* Call identity in use */
-#define CAUSE_Q850_NOCLSUSP 0x55 /* No call suspended */
-#define CAUSE_Q850_CLIDCLRD 0x56 /* Call having the requested call identity has been cleared */
-#define CAUSE_Q850_UNOTMEMCUG 0x57 /* User not member of CUG */
-#define CAUSE_Q850_INCDEST 0x58 /* Incompatible destination */
-#define CAUSE_Q850_NONEXCUG 0x5A /* Non-existent CUG */
-#define CAUSE_Q850_INVNTWSEL 0x5B /* Invalid transit network selection */
-#define CAUSE_Q850_INVMSG 0x5F /* Invalid message, unspecified */
-#define CAUSE_Q850_MIEMISS 0x60 /* Mandatory information element is missing */
-#define CAUSE_Q850_MSGTNI 0x61 /* Message type non-existent or not implemented */
-#define CAUSE_Q850_MSGNCMPT 0x62 /* Message not compatible with call state or message type non-existent or not implemented */
-#define CAUSE_Q850_IENENI 0x63 /* Information element/parameter non-existent or not implemented */
-#define CAUSE_Q850_INVIEC 0x64 /* Invalid information element contents */
-#define CAUSE_Q850_MSGNCWCS 0x65 /* Message not compatible with call state */
-#define CAUSE_Q850_RECOTIMEXP 0x66 /* Recovery on timer expiry */
-#define CAUSE_Q850_PARMNENIPO 0x67 /* Parameter non-existent or not implemented, passed on */
-#define CAUSE_Q850_MSGUNRDPRM 0x6E /* Message with unrecognized parameter, discarded */
-#define CAUSE_Q850_PROTERR 0x6F /* Protocol error, unspecified */
-#define CAUSE_Q850_INTWRKU 0x7F /* Interworking, unspecified */
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdnmonitor/Makefile b/usr.sbin/i4b/isdnmonitor/Makefile
deleted file mode 100644
index 9d3811b7a74c..000000000000
--- a/usr.sbin/i4b/isdnmonitor/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG = isdnmonitor
-SRCS = main.c
-MAN8 = isdnmonitor.8
-
-# compile debug support
-COPTS += -DDEBUG
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/i4b/isdnmonitor/isdnmonitor.8 b/usr.sbin/i4b/isdnmonitor/isdnmonitor.8
deleted file mode 100644
index 9bcb7836fafe..000000000000
--- a/usr.sbin/i4b/isdnmonitor/isdnmonitor.8
+++ /dev/null
@@ -1,40 +0,0 @@
-.\" Copyright (c) 1998 Martin Husemann <martin@rumolt.teuto.de>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. The name of the author may not be used to endorse or promote products
-.\" derived from this software withough specific prior written permission
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $Id: isdnmonitor.8,v 1.2 1998/08/10 13:55:29 hm Exp $
-.\"
-.\" last edit-date: [Fri Jan 30 22:49:48 1998]
-.\"
-.\" -mh writing manual pages
-.\"
-.\"
-.Dd April 18, 1998
-.Dt isdnmonitor 8
-.Sh NAME
-.Nm isdnmonitor
-.Nd raw sample and test client for isdnd network monitoring
-.Sh DESCRIPTION
-The
-.Nm
-is not intended for real world use. It will be replaced
-by something with a better user interface as soon as the monitoring
-subsystem is functional.
diff --git a/usr.sbin/i4b/isdnmonitor/main.c b/usr.sbin/i4b/isdnmonitor/main.c
deleted file mode 100644
index 73ae8fe01f86..000000000000
--- a/usr.sbin/i4b/isdnmonitor/main.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * Copyright (c) 1998 Martin Husemann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * 4. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software and/or documentation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - network monitor client
- * -----------------------------------
- *
- * $Id: main.c,v 1.9 1998/10/27 10:54:23 hm Exp $
- *
- * last edit-date: [Tue Oct 27 11:53:12 1998]
- *
- * -mh created
- * -hm checking in
- * -hm porting to HPUX
- * -mh all events the fullscreen mode displays now as monitor event
- *
- *---------------------------------------------------------------------------*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <time.h>
-#include <errno.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <machine/i4b_ioctl.h>
-
-#ifdef __hpux
-#define AF_LOCAL AF_UNIX
-#endif
-
-#ifdef DEBUG
-#include <ctype.h>
-#endif
-
-#include "monitor.h"
-
-/*
- * Local function prototypes
- */
-static int connect_local(const char *sockpath);
-static int connect_remote(const char *host, int portno);
-static void usage();
-static void mloop();
-static void handle_input();
-static void print_menu();
-static void print_logevent(time_t tstamp, int prio, const char * what, const char * msg);
-static void print_charge(time_t tstamp, int channel, int units, int estimated);
-static void print_connect(time_t tstamp, int dir, int channel, const char * cfgname, const char * devname, const char * remphone, const char * locphone);
-static void print_disconnect(time_t tstamp, int channel);
-static void print_updown(time_t tstamp, int channel, int isup);
-static void handle_event(BYTE *msg, int len);
-#ifdef DEBUG
-static void dump_event(BYTE *msg, int len);
-#endif
-
-/*
- * Global variables
- */
-static int dumpall = 0;
-static int monsock = -1;
-static int state = 0;
-static int sub_state = 0;
-static int sub_state_count = 0;
-
-static int major = 0;
-static int minor = 0;
-static int nctrl = 0;
-static u_int32_t rights = 0;
-
-/*
- * Parse command line, startup monitor client
- */
-int main(int argc, char **argv)
-{
- char * sockpath = NULL;
- char * hostname = NULL;
- int portno = DEF_MONPORT;
- int i;
-
- while ((i = getopt(argc, argv, "dh:p:l:")) != EOF)
- {
- switch (i)
- {
- case 'd':
- dumpall = 1;
- break;
- case 'h':
- hostname = optarg;
- break;
- case 'l':
- sockpath = optarg;
- break;
- case 'p':
- if ((sscanf(optarg, "%i", &portno)) != 1)
- usage();
- break;
- default:
- usage();
- break;
- }
- }
-
- if (hostname && sockpath)
- {
- fprintf(stderr, "Error: can not use local socket path on remote machine\n"
- "conflicting options -h and -l!\n");
- return 1;
- }
-
- if (sockpath)
- {
- monsock = connect_local(sockpath);
- }
- else if (hostname)
- {
- monsock = connect_remote(hostname, portno);
- }
- else
- {
- usage();
- }
-
- if (monsock == -1)
- {
- fprintf(stderr, "Could not connect to i4b isdn daemon.\n");
- return 1;
- }
-
- signal(SIGPIPE, SIG_IGN);
- mloop();
-
- close(monsock);
-
- return 0;
-}
-
-/*
- * Display usage and exit
- */
-static void usage()
-{
- fprintf(stderr, "usage:\n"
- " isdnmonitor [-d] -h (host) -p (port)\n"
- "or\n"
- " isdnmonitor [-d] -l (path)\n"
- "where (host) is the hostname and (port) the port number of\n"
- "the isdnd to be monitored and (path) is the pathname of the\n"
- "local domain socket used to communicate with a daemon on the\n"
- "local machine.\n"
- "Options are:\n"
- " -d dump all incoming packets as hexdump\n"
- );
- exit(0);
-}
-
-/*
- * Connect via tcp/ip.
- * Return socket if successfull, -1 on error.
- */
-static int connect_remote(const char *host, int portno)
-{
- struct sockaddr_in sa;
- struct hostent *h;
- int remotesockfd;
-
- h = gethostbyname(host);
-
- if (!h)
- {
- fprintf(stderr, "could not resolve hostname '%s'\n", host);
- exit(1);
- }
-
- remotesockfd = socket(AF_INET, SOCK_STREAM, 0);
-
- if (remotesockfd == -1)
- {
- fprintf(stderr, "could not create remote monitor socket: %s\n", strerror(errno));
- exit(1);
- }
-
- memset(&sa, 0, sizeof sa);
-
-#ifdef BSD4_4
- sa.sin_len = sizeof sa;
-#endif
- sa.sin_family = AF_INET;
- sa.sin_port = htons(portno);
-
- memcpy(&sa.sin_addr.s_addr, h->h_addr_list[0], sizeof sa.sin_addr.s_addr);
-
- if (connect(remotesockfd, (struct sockaddr *)&sa, sizeof sa) == -1)
- {
- fprintf(stderr, "could not connect remote monitor: %s\n", strerror(errno));
- exit(1);
- }
-
- return remotesockfd;
-}
-
-/*
- * Connect local.
- * Return socket on success, -1 on failure.
- */
-static int connect_local(const char *sockpath)
-{
- int s;
- struct sockaddr_un sa;
-
- /* check path length */
- if (strlen(sockpath) >= sizeof sa.sun_path)
- {
- fprintf(stderr, "pathname to long for local socket: %s\n",
- sockpath);
- exit(1);
- }
-
- /* create and setup socket */
- s = socket(AF_LOCAL, SOCK_STREAM, 0);
-
- if (s == -1)
- {
- fprintf(stderr, "could not create local monitor socket:%s\n", strerror(errno));
- exit(1);
- }
-
- memset(&sa, 0, sizeof sa);
-
-#ifndef __hpux
- sa.sun_len = sizeof sa;
-#endif
-
- sa.sun_family = AF_LOCAL;
- strcpy(sa.sun_path, sockpath);
-
- if (connect(s, (struct sockaddr *)&sa, sizeof sa))
- {
- fprintf(stderr, "could not connect local monitor socket [%s]: %s\n", sockpath, strerror(errno));
- }
-
- return s;
-}
-
-/*
- * main event loop
- */
-static void mloop()
-{
- for (;;)
- {
- fd_set rd, wr, ex;
-
- FD_ZERO(&rd);
- FD_ZERO(&wr);
- FD_ZERO(&ex);
- FD_SET(fileno(stdin), &rd);
- FD_SET(monsock, &rd);
-
- select(monsock+1, &rd, &wr, &ex, NULL);
-
- if (FD_ISSET(fileno(stdin), &rd))
- {
- handle_input();
- }
-
- if (FD_ISSET(monsock, &rd))
- {
- BYTE buf[1024];
- u_long u;
- int bytes, ret;
-
- /* Network transfer may deliver two or more packets concatenated.
- * Peek at the header and read only one event at a time... */
-
- ioctl(monsock, FIONREAD, &u);
-
- if (u < I4B_MON_EVNT_HDR)
- continue; /* not enough data there yet */
-
- bytes = recv(monsock, buf, I4B_MON_EVNT_HDR, MSG_PEEK);
-
- if (bytes < I4B_MON_EVNT_HDR)
- continue; /* errh? something must be wrong... */
-
- bytes = I4B_GET_2B(buf, I4B_MON_EVNT_LEN);
-
- if (bytes >= sizeof buf)
- break;
-
- /* now we know the size, it fits, so lets read it! */
-
- ret = read(monsock, buf, bytes);
-
- if (ret == 0)
- {
- printf("remote isdnd has closed our connection\n");
- break;
- }
- else if (ret < 0)
- {
- printf("error reading from isdnd: %s", strerror(errno));
- break;
- }
-#ifdef DEBUG
- if (dumpall)
- dump_event(buf, ret);
-#endif
- handle_event(buf, ret);
- }
- }
-}
-
-#ifdef DEBUG
-/*
- * Dump a complete event packet.
- */
-static void dump_event(BYTE *msg, int len)
-{
- int i;
-
- printf("event dump:");
-
- for (i = 0; i < len; i++)
- {
- if (i % 8 == 0)
- printf("\n%02x: ", i);
- printf("%02x %c ", msg[i], isprint(msg[i]) ? msg[i] : '.');
- }
- printf("\n");
-}
-#endif
-
-static void print_logevent(time_t tstamp, int prio, const char * what, const char * msg)
-{
- char buf[256];
- strftime(buf, sizeof buf, I4B_TIME_FORMAT, localtime(&tstamp));
- printf("log: %s prio %d what=%s msg=%s\n",
- buf, prio, what, msg);
-}
-
-static void print_charge(time_t tstamp, int channel, int units, int estimated)
-{
- char buf[256];
- strftime(buf, sizeof buf, I4B_TIME_FORMAT, localtime(&tstamp));
- printf("%s: channel %d, charge = %d%s\n",
- buf, channel, units, estimated ? " (estimated)" : "");
-}
-
-/*
- * Print a connect event.
- * A real monitor would allocate state info for "channel" on this
- * event.
- */
-static void print_connect(
- time_t tstamp, /* server time of event */
- int outgoing, /* 0 = incoming, 1 = outgoing */
- int channel, /* channel no, used to identify this connection until disconnect */
- const char * cfgname, /* name of config entry/connection */
- const char * devname, /* device used (e.g. isp0) */
- const char * remphone, /* phone no of remote side */
- const char * locphone) /* local phone no */
-{
- char buf[256];
- strftime(buf, sizeof buf, I4B_TIME_FORMAT, localtime(&tstamp));
-
- if (outgoing)
- printf("%s: calling out to '%s' [from msn: '%s']",
- buf, remphone, locphone);
- else
- printf("%s: incoming call from '%s' [to msn: '%s']",
- buf, remphone, locphone);
- printf(", channel %d, config '%s' on device '%s'\n",
- channel, cfgname, devname);
-}
-
-/*
- * Print a disconnect event.
- * A real monitor could free the "per connection" state
- * for this channel now
- */
-static void print_disconnect(time_t tstamp, int channel)
-{
- char buf[256];
- strftime(buf, sizeof buf, I4B_TIME_FORMAT, localtime(&tstamp));
- printf("%s: channel %d disconnected\n",
- buf, channel);
-}
-
-/*
- * Print an up- or down event
- */
-static void print_updown(time_t tstamp, int channel, int isup)
-{
- char buf[256];
- strftime(buf, sizeof buf, I4B_TIME_FORMAT, localtime(&tstamp));
- printf("%s: channel %d is %s\n",
- buf, channel, isup ? "up" : "down");
-}
-
-/*
- * Dispatch one message received from the daemon.
- */
-static void handle_event(BYTE *msg, int len)
-{
- BYTE cmd[I4B_MON_ICLIENT_SIZE];
- int local;
- u_int32_t net;
- u_int32_t mask;
- u_int32_t who;
-
- switch (state)
- {
- case 0: /* initial data */
-
- major = I4B_GET_2B(msg, I4B_MON_IDATA_VERSMAJOR);
- minor = I4B_GET_2B(msg, I4B_MON_IDATA_VERSMINOR);
- nctrl = I4B_GET_2B(msg, I4B_MON_IDATA_NUMCTRL);
- rights = I4B_GET_4B(msg, I4B_MON_IDATA_CLACCESS);
-
- printf("remote protocol version is %02d.%02d, %d controller(s) found, our rights = %x\n",
- major, minor, nctrl, rights);
-
- if (nctrl > 0)
- {
- state = 1;
- sub_state = 0;
- }
- else
- {
- state = 2;
-
- /* show menu for the first time */
- print_menu();
- }
-
- /* set maximum event mask */
- I4B_PREP_CMD(cmd, I4B_MON_CCMD_SETMASK);
- I4B_PUT_2B(cmd, I4B_MON_ICLIENT_VERMAJOR, MPROT_VERSION);
- I4B_PUT_2B(cmd, I4B_MON_ICLIENT_VERMINOR, MPROT_REL);
- I4B_PUT_4B(cmd, I4B_MON_ICLIENT_EVENTS, ~0U);
-
- write(monsock, cmd, sizeof cmd);
-
- break;
-
- case 1: /* initial controller list */
- printf("controller %d: %s\n", sub_state++, msg+I4B_MON_ICTRL_NAME);
-
- if (sub_state >= nctrl)
- {
- state = 2; /* end of list reached */
- sub_state = 0;
-
- /* show menu for the first time */
- print_menu();
- }
- break;
-
- case 2: /* any event */
-
- switch (I4B_GET_2B(msg, I4B_MON_EVNT))
- {
- case I4B_MON_DRINI_CODE:
- state = 3; /* list of rights entries will follow */
- sub_state = 0;
- sub_state_count = I4B_GET_2B(msg, I4B_MON_DRINI_COUNT);
- printf("monitor rights:\n");
- break;
-
- case I4B_MON_DCINI_CODE:
- state = 4;
- sub_state = 0;
- sub_state_count = I4B_GET_2B(msg, I4B_MON_DCINI_COUNT);
- printf("monitor connections:\n");
- break;
-
- case I4B_MON_LOGEVNT_CODE:
- print_logevent(I4B_GET_4B(msg, I4B_MON_LOGEVNT_TSTAMP),
- I4B_GET_4B(msg, I4B_MON_LOGEVNT_PRIO),
- msg+I4B_MON_LOGEVNT_WHAT,
- msg+I4B_MON_LOGEVNT_MSG);
- break;
-
- case I4B_MON_CHRG_CODE:
- print_charge(I4B_GET_4B(msg, I4B_MON_CHRG_TSTAMP),
- I4B_GET_4B(msg, I4B_MON_CHRG_CHANNEL),
- I4B_GET_4B(msg, I4B_MON_CHRG_UNITS),
- I4B_GET_4B(msg, I4B_MON_CHRG_ESTIMATED));
- break;
-
- case I4B_MON_CONNECT_CODE:
- print_connect(
- I4B_GET_4B(msg, I4B_MON_CONNECT_TSTAMP),
- I4B_GET_4B(msg, I4B_MON_CONNECT_DIR),
- I4B_GET_4B(msg, I4B_MON_CONNECT_CHANNEL),
- msg+I4B_MON_CONNECT_CFGNAME,
- msg+I4B_MON_CONNECT_DEVNAME,
- msg+I4B_MON_CONNECT_REMPHONE,
- msg+I4B_MON_CONNECT_LOCPHONE);
- break;
-
- case I4B_MON_DISCONNECT_CODE:
- print_disconnect(
- I4B_GET_4B(msg, I4B_MON_DISCONNECT_TSTAMP),
- I4B_GET_4B(msg, I4B_MON_DISCONNECT_CHANNEL));
- break;
-
- case I4B_MON_UPDOWN_CODE:
- print_updown(
- I4B_GET_4B(msg, I4B_MON_UPDOWN_TSTAMP),
- I4B_GET_4B(msg, I4B_MON_UPDOWN_CHANNEL),
- I4B_GET_4B(msg, I4B_MON_UPDOWN_ISUP));
- break;
-
- default:
- printf("unknown event code: %d\n", I4B_GET_2B(msg, I4B_MON_EVNT));
- }
- break;
-
- case 3: /* one record in a list of monitor rights */
- rights = I4B_GET_4B(msg, I4B_MON_DR_RIGHTS);
- net = I4B_GET_4B(msg, I4B_MON_DR_NET);
- mask = I4B_GET_4B(msg, I4B_MON_DR_MASK);
- local = I4B_GET_1B(msg, I4B_MON_DR_LOCAL);
-
- if (local)
- {
- printf("\tlocal: rights = %x\n", rights);
- }
- else
- {
- printf("\tfrom: %d.%d.%d.%d, mask %d.%d.%d.%d, rights = %x\n",
- (net >> 24) & 0x00ff, (net >> 16) & 0x00ff, (net >> 8) & 0x00ff, net & 0x00ff,
- (mask >> 24) & 0x00ff, (mask >> 16) & 0x00ff, (mask >> 8) & 0x00ff, mask & 0x00ff,
- rights);
- }
-
- sub_state++;
-
- if (sub_state >= sub_state_count)
- {
- state = 2;
- print_menu();
- }
- break;
-
- case 4:
- who = I4B_GET_4B(msg, I4B_MON_DC_WHO);
- rights = I4B_GET_4B(msg, I4B_MON_DC_RIGHTS);
-
- printf("\tfrom: %d.%d.%d.%d, rights = %x\n",
- (who >> 24) & 0x00ff, (who >> 16) & 0x00ff, (who >> 8) & 0x00ff, who & 0x00ff,
- rights);
-
- sub_state++;
-
- if (sub_state >= sub_state_count)
- {
- state = 2;
- print_menu();
- }
- break;
-
- default:
- printf("unknown event from remote: local state = %d, evnt = %x, len = %d\n",
- state, I4B_GET_2B(msg, I4B_MON_EVNT), len);
- }
-}
-
-/*
- * Process input from user
- */
-static void handle_input()
-{
- char buf[1024];
- int channel;
-
- fgets(buf, sizeof buf, stdin);
-
- switch (atoi(buf))
- {
- case 1:
- {
- BYTE cmd[I4B_MON_DUMPRIGHTS_SIZE];
- I4B_PREP_CMD(cmd, I4B_MON_DUMPRIGHTS_CODE);
- write(monsock, cmd, I4B_MON_DUMPRIGHTS_SIZE);
- }
- break;
-
- case 2:
- {
- BYTE cmd[I4B_MON_DUMPMCONS_SIZE];
- I4B_PREP_CMD(cmd, I4B_MON_DUMPMCONS_CODE);
- write(monsock, cmd, I4B_MON_DUMPMCONS_SIZE);
- }
- break;
-
- case 3:
- {
- BYTE cmd[I4B_MON_CFGREREAD_SIZE];
- I4B_PREP_CMD(cmd, I4B_MON_CFGREREAD_CODE);
- write(monsock, cmd, I4B_MON_CFGREREAD_SIZE);
- }
- break;
-
- case 4:
- {
- BYTE cmd[I4B_MON_HANGUP_SIZE];
- I4B_PREP_CMD(cmd, I4B_MON_HANGUP_CODE);
- printf("Which channel do you wish to hangup? ");
- fgets(buf, sizeof buf, stdin);
- channel = atoi(buf);
- I4B_PUT_4B(cmd, I4B_MON_HANGUP_CHANNEL, channel);
- write(monsock, cmd, I4B_MON_HANGUP_SIZE);
- }
- break;
-
- case 9:
- close(monsock);
- exit(0);
- break;
-
- default:
- print_menu();
- break;
- }
-}
-
-/*
- * Display menu
- */
-static void print_menu()
-{
- printf("Menu: <1> display rights, <2> display monitor connections,\n");
- printf(" <3> reread config file, <4> hangup \n");
- printf(" <9> quit isdnmonitor\n");
-}
diff --git a/usr.sbin/i4b/isdnmonitor/monitor.h b/usr.sbin/i4b/isdnmonitor/monitor.h
deleted file mode 100644
index 0025449eb2bd..000000000000
--- a/usr.sbin/i4b/isdnmonitor/monitor.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 1998 Martin Husemann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * 4. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software and/or documentation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * i4b daemon - network monitor protocl definition
- * -----------------------------------------------
- *
- * $Id: monitor.h,v 1.4 1998/08/10 13:55:32 hm Exp $
- *
- * last edit-date: [Mon Aug 3 06:52:06 1998]
- *
- * -mh created
- * -hm checking in
- * -hm ported to HPUX 10.10
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef MONITOR_H
-#define MONITOR_H
-
-#define DEF_MONPORT 451 /* default monitor TCP port */
-
-#ifdef __hpux
-#define u_int8_t ubit8
-#define u_int32_t ubit32
-#endif
-#ifdef _WIN32
-#define u_int8_t BYTE
-#define u_in32_t DWORD
-#endif
-
-/*
- * The monitor client connects to the isdnd daemon process via a tcp/ip
- * connection from a remote machine or via a local (unix domain) socket.
- * The daemon accepts multiple connections and verifies access rights.
- * On connection establishment the daemon sends initial data telling
- * the client the current configuration: number and type of available
- * controllers, current connections, channel and interface states
- * and the clients access privileges. The client sends an event mask
- * telling the daemon which events it is interested in. If the client
- * has appropriate rights he may send commands to the daemon.
- *
- * All multi-byte values are in network byte order!
- */
-
-/* All data packets transfered are declared as arrays of BYTE */
-#define BYTE u_int8_t
-
-/* max stringlength used in this protocol */
-#define I4B_MAX_MON_STRING 256
-
-/* max command size from client to server */
-#define I4B_MAX_MON_CLIENT_CMD 16
-
-/* Version of the monitor protocol described here */
-#define MPROT_VERSION 0 /* major version no */
-#define MPROT_REL 1 /* release no */
-/*
- * We intend to keep different versions of monitor client and isdnd
- * interoperable as long as possible. We do not, however, even try
- * to do this during early alpha or beta release phases. If you run
- * developement versions at this stage, make sure all your clients
- * and servers run the same version!
- */
-
-/*
- * Client access rights
- */
-#define I4B_CA_COMMAND_FULL 1 /* may send any command */
-#define I4B_CA_COMMAND_RESTRICTED 2 /* may send 'harmless' commands */
-#define I4B_CA_EVNT_CHANSTATE 16 /* may watch b-channel states */
-#define I4B_CA_EVNT_CALLIN 32 /* may watch incoming calls */
-#define I4B_CA_EVNT_CALLOUT 64 /* may watch outgoing calls */
-#define I4B_CA_EVNT_I4B 128 /* may watch isdnd actions */
-
-/*
- * General layout of a command packet. All commands have this common
- * prefix. It is prepared by the macro I4B_PREP_CMD (s.b.)
- */
-#define I4B_MON_CMD 0 /* 2 byte: command code */
-#define I4B_MON_CMD_LEN 2 /* 2 byte: packet length */
-#define I4B_MON_CMD_HDR 4 /* size of header */
-
-/*
- * Currently events look the same as commands. We do not make
- * any guarantee this will remain the same, so a different set
- * of macros is used when describing events. Events are prepared
- * by I4B_PREP_EVNT (s.b.)
- */
-#define I4B_MON_EVNT 0 /* 2 byte: event code */
-#define I4B_MON_EVNT_LEN 2 /* 2 byte: packet length */
-#define I4B_MON_EVNT_HDR 4 /* size of header */
-
-/* Initial data send by daemon after connection is established */
-#define I4B_MON_IDATA_SIZE I4B_MON_EVNT_HDR+10
-#define I4B_MON_IDATA_CODE 0 /* event code */
-#define I4B_MON_IDATA_VERSMAJOR I4B_MON_EVNT_HDR+0 /* 2 byte: isdnd major version */
-#define I4B_MON_IDATA_VERSMINOR I4B_MON_EVNT_HDR+2 /* 2 byte: isdnd minor version */
-#define I4B_MON_IDATA_NUMCTRL I4B_MON_EVNT_HDR+4 /* 2 byte: number of controllers */
-#define I4B_MON_IDATA_CLACCESS I4B_MON_EVNT_HDR+6 /* 4 byte: client rights */
-
-/* followed by this for every controller */
-#define I4B_MON_ICTRL_SIZE I4B_MON_EVNT_HDR+I4B_MAX_MON_STRING+8
-#define I4B_MON_ICTRL_CODE 1 /* event code */
-#define I4B_MON_ICTRL_NAME I4B_MON_EVNT_HDR+0 /* string: name of controller */
-#define I4B_MON_ICTRL_BUSID I4B_MON_EVNT_HDR+I4B_MAX_MON_STRING+0 /* 2 byte: isdn bus id (reservered) */
-#define I4B_MON_ICTRL_FLAGS I4B_MON_EVNT_HDR+I4B_MAX_MON_STRING+2 /* 4 byte: controller flags (not yet defined) */
-#define I4B_MON_ICTRL_NCHAN I4B_MON_EVNT_HDR+I4B_MAX_MON_STRING+6 /* 2 byte: number of b channels on this controller */
-
-/* The client sets it's protocol version and event mask (usualy once after
- * connection establishement) */
-#define I4B_MON_CCMD_SETMASK 0x7e /* command code */
-#define I4B_MON_ICLIENT_SIZE I4B_MON_CMD_HDR+8
-#define I4B_MON_ICLIENT_VERMAJOR I4B_MON_CMD_HDR+0 /* 2 byte: protocol major version (always 0 for now) */
-#define I4B_MON_ICLIENT_VERMINOR I4B_MON_CMD_HDR+2 /* 2 byte: protocol minor version (always 0 for now) */
-#define I4B_MON_ICLIENT_EVENTS I4B_MON_CMD_HDR+4 /* 4 byte: client event mask */
-
-/* The client requests a list of monitor rights */
-#define I4B_MON_DUMPRIGHTS_CODE 1
-#define I4B_MON_DUMPRIGHTS_SIZE I4B_MON_CMD_HDR /* no parameters */
-
-/* in response to a I4B_MON_DUMPRIGHTS_CODE command, the daemon sends
- * this event: */
-#define I4B_MON_DRINI_CODE 2 /* event code */
-#define I4B_MON_DRINI_SIZE I4B_MON_EVNT_HDR+2 /* size of packet */
-#define I4B_MON_DRINI_COUNT I4B_MON_EVNT_HDR+0 /* 2 byte: number of records */
-
-/* followed by this for each record anounced above */
-#define I4B_MON_DR_CODE 3
-#define I4B_MON_DR_SIZE I4B_MON_EVNT_HDR+13
-#define I4B_MON_DR_RIGHTS I4B_MON_EVNT_HDR+0 /* 4 byte: rights mask */
-#define I4B_MON_DR_NET I4B_MON_EVNT_HDR+4 /* 4 byte: network address */
-#define I4B_MON_DR_MASK I4B_MON_EVNT_HDR+8 /* 4 byte: network mask */
-#define I4B_MON_DR_LOCAL I4B_MON_EVNT_HDR+12 /* 1 byte: non-zero if local socket */
-
-/* The client requests a list of monitor connections */
-#define I4B_MON_DUMPMCONS_CODE 2
-#define I4B_MON_DUMPMCONS_SIZE I4B_MON_CMD_HDR /* no parameters */
-
-/* in response to a I4B_MON_DUMPMCONS_CODE command, the daemon sends
- * this event: */
-#define I4B_MON_DCINI_CODE 4 /* event code */
-#define I4B_MON_DCINI_SIZE I4B_MON_EVNT_HDR+2 /* size of packet */
-#define I4B_MON_DCINI_COUNT I4B_MON_EVNT_HDR+0 /* 2 byte: number of records */
-
-/* followed by this for each record anounced above */
-#define I4B_MON_DC_CODE 5
-#define I4B_MON_DC_SIZE I4B_MON_EVNT_HDR+8
-#define I4B_MON_DC_RIGHTS I4B_MON_EVNT_HDR+0 /* 4 byte: rights mask */
-#define I4B_MON_DC_WHO I4B_MON_EVNT_HDR+4 /* 4 byte: network address */
-
-/* The client requests a config file rescan */
-#define I4B_MON_CFGREREAD_CODE 3
-#define I4B_MON_CFGREREAD_SIZE I4B_MON_CMD_HDR /* no parameters */
-
-/* The client requests to hangup a connection */
-#define I4B_MON_HANGUP_CODE 4
-#define I4B_MON_HANGUP_SIZE I4B_MON_CMD_HDR+4
-#define I4B_MON_HANGUP_CHANNEL I4B_MON_CMD_HDR+0 /* channel to drop */
-
-/* The daemon sends a logfile event */
-#define I4B_MON_LOGEVNT_CODE 6
-#define I4B_MON_LOGEVNT_SIZE I4B_MON_EVNT_HDR+8+2*I4B_MAX_MON_STRING
-#define I4B_MON_LOGEVNT_TSTAMP I4B_MON_EVNT_HDR+0 /* 4 byte: timestamp */
-#define I4B_MON_LOGEVNT_PRIO I4B_MON_EVNT_HDR+4 /* 4 byte: syslog priority */
-#define I4B_MON_LOGEVNT_WHAT I4B_MON_EVNT_HDR+8 /* followed by 2 strings: 'what' and 'message' */
-#define I4B_MON_LOGEVNT_MSG I4B_MON_EVNT_HDR+8+I4B_MAX_MON_STRING
-
-/* The daemon sends a charge event */
-#define I4B_MON_CHRG_CODE 7
-#define I4B_MON_CHRG_SIZE I4B_MON_EVNT_HDR+16
-#define I4B_MON_CHRG_TSTAMP I4B_MON_EVNT_HDR+0 /* 4 byte: timestamp */
-#define I4B_MON_CHRG_CHANNEL I4B_MON_EVNT_HDR+4 /* 4 byte: channel charged */
-#define I4B_MON_CHRG_UNITS I4B_MON_EVNT_HDR+8 /* 4 byte: new charge value */
-#define I4B_MON_CHRG_ESTIMATED I4B_MON_EVNT_HDR+12 /* 4 byte: 0 = charge by network, 1 = calculated estimate */
-
-/* The daemon sends a connect event */
-#define I4B_MON_CONNECT_CODE 8
-#define I4B_MON_CONNECT_SIZE I4B_MON_EVNT_HDR+12+4*I4B_MAX_MON_STRING
-#define I4B_MON_CONNECT_TSTAMP I4B_MON_EVNT_HDR+0 /* 4 byte: time stamp */
-#define I4B_MON_CONNECT_DIR I4B_MON_EVNT_HDR+4 /* 4 byte: direction (0 = incoming, 1 = outgoing) */
-#define I4B_MON_CONNECT_CHANNEL I4B_MON_EVNT_HDR+8 /* 4 byte: channel connected */
-#define I4B_MON_CONNECT_CFGNAME I4B_MON_EVNT_HDR+12 /* name of config entry */
-#define I4B_MON_CONNECT_DEVNAME I4B_MON_EVNT_HDR+12+I4B_MAX_MON_STRING /* name of device used for connection */
-#define I4B_MON_CONNECT_REMPHONE I4B_MON_EVNT_HDR+12+2*I4B_MAX_MON_STRING /* remote phone no. */
-#define I4B_MON_CONNECT_LOCPHONE I4B_MON_EVNT_HDR+12+3*I4B_MAX_MON_STRING /* local phone no. */
-
-/* The daemon sends a disconnect event */
-#define I4B_MON_DISCONNECT_CODE 9
-#define I4B_MON_DISCONNECT_SIZE I4B_MON_EVNT_HDR+8
-#define I4B_MON_DISCONNECT_TSTAMP I4B_MON_EVNT_HDR+0 /* 4 byte: time stamp */
-#define I4B_MON_DISCONNECT_CHANNEL I4B_MON_EVNT_HDR+4 /* 4 byte: channel disconnected */
-
-/* The daemon sends an up/down event */
-#define I4B_MON_UPDOWN_CODE 10
-#define I4B_MON_UPDOWN_SIZE I4B_MON_EVNT_HDR+12
-#define I4B_MON_UPDOWN_TSTAMP I4B_MON_EVNT_HDR+0 /* 4 byte: time stamp */
-#define I4B_MON_UPDOWN_CHANNEL I4B_MON_EVNT_HDR+4 /* 4 byte: channel disconnected */
-#define I4B_MON_UPDOWN_ISUP I4B_MON_EVNT_HDR+8 /* 4 byte: interface is up */
-
-/* macros for setup/decoding of protocol packets */
-
-/* clear a record */
-#define I4B_CLEAR(r) memset(&(r), 0, sizeof(r));
-
-/* prepare a record as event or command */
-#define I4B_PREP_EVNT(r, e) { \
- I4B_CLEAR(r); \
- I4B_PUT_2B(r, I4B_MON_EVNT, e); \
- I4B_PUT_2B(r, I4B_MON_EVNT_LEN, sizeof(r)); \
-}
-#define I4B_PREP_CMD(r, c) { \
- I4B_CLEAR(r); \
- I4B_PUT_2B(r, I4B_MON_CMD, c); \
- I4B_PUT_2B(r, I4B_MON_CMD_LEN, sizeof(r)); \
-}
-
-/* put 1, 2 or 4 bytes in network byte order into a record at offset off */
-#define I4B_PUT_1B(r, off, val) { ((BYTE*)(r))[off] = (val) & 0x00ff; }
-#define I4B_PUT_2B(r, off, val) { I4B_PUT_1B(r, off, val >> 8); I4B_PUT_1B(r, off+1, val); }
-#define I4B_PUT_4B(r, off, val) { I4B_PUT_1B(r, off, val >> 24); I4B_PUT_1B(r, off+1, val >> 16); I4B_PUT_1B(r, off+2, val >> 8); I4B_PUT_1B(r, off+3, val); }
-
-/* get 1, 2 or 4 bytes in network byte order from a record at offset off */
-#define I4B_GET_1B(r, off) (((BYTE*)(r))[off])
-#define I4B_GET_2B(r, off) ((((BYTE*)(r))[off]) << 8) | (((BYTE*)(r))[off+1])
-#define I4B_GET_4B(r, off) ((((BYTE*)(r))[off]) << 24) | ((((BYTE*)(r))[off+1]) << 16) | ((((BYTE*)(r))[off+2]) << 8) | (((BYTE*)(r))[off+3])
-
-/* put a string into recor r at offset off, make sure it's not to long
- * and proper terminate it */
-#define I4B_PUT_STR(r, off, str) { \
- strncpy(r+off, str, I4B_MAX_MON_STRING); \
- r[off+I4B_MAX_MON_STRING-1] = (BYTE)0; }
-
-#endif /* MONITOR_H */
-
diff --git a/usr.sbin/i4b/isdntel/Makefile b/usr.sbin/i4b/isdntel/Makefile
deleted file mode 100644
index 752857173715..000000000000
--- a/usr.sbin/i4b/isdntel/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $Id$
-
-PROG = isdntel
-SRCS = main.c display.c files.c alias.c
-DPADD = ${LIBNCURSES} ${LIBMYTINFO}
-LDADD = -lncurses -lmytinfo
-MAN8 = isdntel.8
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/i4b/isdntel/alias.c b/usr.sbin/i4b/isdntel/alias.c
deleted file mode 100644
index fa02ea962cd4..000000000000
--- a/usr.sbin/i4b/isdntel/alias.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * isdntel - isdn4bsd telephone answering machine support
- * ======================================================
- *
- * $Id: alias.c,v 1.5 1998/12/05 18:03:51 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:15:02 1998]
- *
- *----------------------------------------------------------------------------*/
-
-#include "defs.h"
-#include "alias.h"
-
-static struct alias *firsta = NULL;
-
-#define MAXBUFSZ 256
-
-/*---------------------------------------------------------------------------*
- * read in and init aliases
- *---------------------------------------------------------------------------*/
-void
-init_alias(char *filename)
-{
- FILE *fp;
- char buffer[MAXBUFSZ + 1];
- char number[MAXBUFSZ + 1];
- char name[MAXBUFSZ + 1];
- char *s, *d;
- struct alias *newa = NULL;
- struct alias *lasta = NULL;
-
- if((fp = fopen(filename, "r")) == NULL)
- fatal("cannot open aliasfile %s!", filename);
-
- while((fgets(buffer, MAXBUFSZ, fp)) != NULL)
- {
- if(buffer[0] == '#' || buffer[0] == ' ' ||
- buffer[0] == '\t' || buffer[0] == '\n')
- {
- continue;
- }
-
- s = buffer;
- d = number;
-
- while(*s && (isdigit(*s)))
- *d++ = *s++;
-
- *d = '\0';
-
- while(*s && (isspace(*s)))
- s++;
-
- d = name;
-
- while(*s && (isprint(*s)))
- *d++ = *s++;
-
- *d = '\0';
-
- if((strlen(number) > 1) && (strlen(name) > 1))
- {
- if((newa = (struct alias *) malloc(sizeof(struct alias))) == NULL)
- fatal("malloc failed for struct alias");
- if((newa->number = (char *) malloc(strlen(number)+1)) == NULL)
- fatal("malloc failed for number alias");
- if((newa->name = (char *) malloc(strlen(name)+1)) == NULL)
- fatal("malloc failed for name alias");
- strcpy(newa->name, name);
- strcpy(newa->number, number);
- newa->next = NULL;
-
- if(firsta == NULL)
- {
- firsta = newa;
- }
- else
- {
- lasta->next = newa;
- }
- lasta = newa;
- }
- }
- fclose(fp);
-}
-
-/*---------------------------------------------------------------------------*
- * read in and init aliases
- *---------------------------------------------------------------------------*/
-char *
-get_alias(char *number)
-{
- struct alias *ca = NULL;
-
- if(firsta == NULL)
- return(NULL);
-
- ca = firsta;
-
- for(;;)
- {
- if(strlen(number) == strlen(ca->number))
- {
- if(!(strcmp(number, ca->number)))
- return(ca->name);
- }
- if(ca->next == NULL)
- break;
- ca = ca->next;
- }
- return(NULL);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntel/alias.h b/usr.sbin/i4b/isdntel/alias.h
deleted file mode 100644
index 98b91daf8feb..000000000000
--- a/usr.sbin/i4b/isdntel/alias.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * isdn4bsd common alias file handling header
- * ==========================================
- *
- * $Id: alias.h,v 1.3 1998/12/05 18:03:52 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:15:13 1998]
- *
- *----------------------------------------------------------------------------*/
-
-#ifndef _ALIAS_H_
-#define _ALIAS_H_
-
-#define ALIASFILE "/etc/isdn/isdntel.alias"
-
-struct alias {
- char *number; /* telephone number string */
- char *name; /* name string */
- struct alias *next; /* ptr to next alias */
-};
-
-#endif /* _ALIAS_H_ */
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntel/defs.h b/usr.sbin/i4b/isdntel/defs.h
deleted file mode 100644
index e9233c370355..000000000000
--- a/usr.sbin/i4b/isdntel/defs.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * isdntel - isdn4bsd telephone answering support
- * ==============================================
- *
- * $Id: defs.h,v 1.6 1998/12/05 18:03:53 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:15:26 1998]
- *
- *----------------------------------------------------------------------------*/
-
-#include <ncurses.h>
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/time.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
-#include <dirent.h>
-#else
-#include <sys/dir.h>
-#endif
-#include <sys/param.h>
-
-#define VERSION "1" /* version number */
-#define REL "11" /* release number */
-
-#define GOOD 0
-#define ERROR (-1)
-#define WARNING (-2)
-
-#define SPOOLDIR "/var/isdn"
-#define PLAYCMD "cat %s | alaw2ulaw >/dev/audio"
-
-/* reread timeout in seconds */
-
-#define REREADTIMEOUT 60
-
-/* window dimensions */
-
-#define START_O 3 /* main window start */
-
-#define DAT_POS 0
-#define TIM_POS (DAT_POS+10)
-#define DST_POS (TIM_POS+8)
-#define SRC_POS (DST_POS+17)
-#define ALI_POS (SRC_POS+17)
-#define SEC_POS (ALI_POS+21)
-#define LAST_POS (SEC_POS+5)
-
-/* fullscreen mode menu window */
-
-#define WMITEMS 5 /* no of items */
-#define WMENU_LEN 18 /* window width */
-#define WMENU_HGT (WMITEMS+4) /* window height */
-#define WMENU_TITLE "Command"
-#define WMENU_POSLN 8 /* window position: lines */
-#define WMENU_POSCO 20 /* window position: columns */
-
-#define CR 0x0d
-#define LF 0x0a
-#define TAB 0x09
-#define CNTRL_D 0x04
-#define CNTRL_L 0x0c
-
-struct onefile {
- char *fname; /* filename */
- char *date;
- char *time;
- char *srcnumber;
- char *dstnumber;
- char *seconds;
- char *alias;
- int len;
- struct onefile *next; /* ptr to next entry */
- struct onefile *prev; /* prt to previous entry */
-};
-
-#ifdef MAIN
-
-int curses_ready = 0; /* flag, curses display is initialized */
-
-struct onefile *cur_file = NULL;/* the CURRENT filename */
-struct onefile *first = NULL; /* init dir-list head-ptr */
-struct onefile *last = NULL; /* init dir-list tail-ptr */
-
-WINDOW *main_w; /* curses main window pointer */
-
-int nofiles = 0;
-int cur_pos = 0;
-
-char *spooldir = SPOOLDIR;
-char *playstring = PLAYCMD;
-
-#else
-
-extern int curses_ready;
-
-extern struct onefile *cur_file;
-extern struct onefile *first;
-extern struct onefile *last;
-
-extern WINDOW *main_w;
-
-extern int nofiles;
-extern int cur_pos;
-
-extern char *spooldir;
-extern char *playstring;
-
-#endif
-
-extern void init_alias( char *filename );
-extern void init_files( int inipos );
-extern void init_screen ( void );
-extern void do_menu ( void );
-extern int fill_list( void );
-extern char *get_alias( char *number );
-extern int main ( int argc, char **argv );
-extern void do_quit ( int exitval );
-extern void fatal ( char *fmt, ... );
-extern void error ( char *fmt, ... );
-extern void play ( struct onefile * );
-extern void delete ( struct onefile * );
-extern void reread( void );
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntel/display.c b/usr.sbin/i4b/isdntel/display.c
deleted file mode 100644
index 1cc0034f01cf..000000000000
--- a/usr.sbin/i4b/isdntel/display.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * isdntel - isdn4bsd telephone answering machine support
- * ======================================================
- *
- * $Id: display.c,v 1.4 1998/12/05 18:03:55 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:15:40 1998]
- *
- *----------------------------------------------------------------------------*/
-
-#include "defs.h"
-
-static char *helpstr = "Enter Control-D to exit program or RETURN for command window";
-
-/*---------------------------------------------------------------------------*
- * init curses fullscreen display
- *---------------------------------------------------------------------------*/
-void
-init_screen(void)
-{
- char buffer[512];
-
- initscr(); /* curses init */
-
- if((COLS < 80) || (LINES < 24))
- fatal(0, "ERROR, minimal screensize must be 80x24, is %dx%d, terminating!", COLS, LINES);
-
-
- if((main_w = newwin(LINES-START_O-2, COLS, START_O, 0)) == NULL)
- fatal("ERROR, curses init main window, terminating!");
-
- raw(); /* raw input */
- noecho(); /* do not echo input */
- keypad(stdscr, TRUE); /* use special keys */
- keypad(main_w, TRUE); /* use special keys */
- scrollok(main_w, TRUE);
-
- sprintf(buffer, " isdntel %s.%s ", VERSION, REL);
-
- move(0, 0);
- standout();
- hline(ACS_HLINE, 5);
- move(0, 5);
- addstr(buffer);
- move(0, 5 + strlen(buffer));
- hline(ACS_HLINE, 256);
- standend();
-
- move(1, 0);
- addstr("Date Time Called Party Calling Party Alias Length");
- /* 31.12.96 16:45:12 1234567890123456 1234567890123456 12345678901234567890 123456 */
-
- move(2, 0);
- hline(ACS_HLINE, 256);
-
- move(LINES-2, 0);
- hline(ACS_HLINE, 256);
-
- mvaddstr(LINES-1, (COLS / 2) - (strlen(helpstr) / 2), helpstr);
-
- refresh();
-
- wrefresh(main_w);
-
- curses_ready = 1;
-}
-
-/*---------------------------------------------------------------------------*
- * curses menu for fullscreen command mode
- *---------------------------------------------------------------------------*/
-void
-do_menu(void)
-{
- static char *menu[WMITEMS] =
- {
- "Play File",
-#define PLAY 0
- "Delete File",
-#define DELETE 1
- "Re-Read Spool",
-#define REREAD 2
- "Refresh Screen",
-#define REFRESH 3
- "Exit Program",
-#define EXIT 4
- };
-
- WINDOW *menu_w;
- int c;
- int mpos;
-
- /* create a new window in the lower screen area */
-
- if((menu_w = newwin(WMENU_HGT, WMENU_LEN, WMENU_POSLN, WMENU_POSCO )) == NULL)
- return;
-
- keypad(menu_w, TRUE); /* use special keys */
-
- /* draw border around the window */
-
- box(menu_w, 0, 0);
-
- /* add a title */
-
- wstandout(menu_w);
- mvwaddstr(menu_w, 0, (WMENU_LEN / 2) - (strlen(WMENU_TITLE) / 2), WMENU_TITLE);
- wstandend(menu_w);
-
- /* fill the window with the menu options */
-
- for(mpos=0; mpos <= (WMITEMS-1); mpos++)
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
-
- /* highlight the first menu option */
-
- mpos = 0;
- wstandout(menu_w);
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
- wstandend(menu_w);
-
- /* input loop */
-
- for(;;)
- {
- wrefresh(menu_w);
-
- c = wgetch(menu_w);
-
- switch(c)
- {
- case TAB:
- case KEY_DOWN: /* down-move cursor */
- case ' ':
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
- mpos++;
- if(mpos >= WMITEMS)
- mpos = 0;
- wstandout(menu_w);
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
- wstandend(menu_w);
- break;
-
- case KEY_UP: /* up-move cursor */
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
- if(mpos)
- mpos--;
- else
- mpos = WMITEMS-1;
- wstandout(menu_w);
- mvwaddstr(menu_w, mpos + 2, 2, menu[mpos]);
- wstandend(menu_w);
- break;
-
- case 'R':
- case 'r':
- wrefresh(curscr);
- goto mexit;
-
- case 'E':
- case 'e':
- case 'Q':
- case 'q':
- case 'X':
- case 'x':
- do_quit(0);
- goto mexit;
- break;
-
- case 'P':
- case 'p':
- play(cur_file);
- goto mexit;
- break;
-
- case 'D':
- case 'd':
- delete(cur_file);
- goto mexit;
- break;
-
- case CR:
- case LF: /* exec highlighted option */
-#ifdef KEY_ENTER
- case KEY_ENTER:
-#endif
- switch(mpos)
- {
- case PLAY:
- play(cur_file);
- goto mexit;
- break;
- case DELETE:
- delete(cur_file);
- goto mexit;
- break;
- case REREAD:
- reread();
- goto mexit;
- break;
- case REFRESH:
- wrefresh(curscr);
- break;
- case EXIT:
- do_quit(0);
- break;
- }
- goto mexit;
- break;
-
- default:
- goto mexit;
- break;
- }
- }
-
-mexit:
- /* delete the menu window */
-
- delwin(menu_w);
-
- /* re-display the original lower window contents */
-
- touchwin(main_w);
- wrefresh(main_w);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntel/files.c b/usr.sbin/i4b/isdntel/files.c
deleted file mode 100644
index ea153f5ee006..000000000000
--- a/usr.sbin/i4b/isdntel/files.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * isdntel - isdn4bsd telephone answering machine support
- * ======================================================
- *
- * $Id: files.c,v 1.6 1998/12/05 18:03:56 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:15:57 1998]
- *
- *----------------------------------------------------------------------------*/
-
-#include "defs.h"
-
-/*---------------------------------------------------------------------------*
- * create a doubly linked list in sorted order, return pointer to new
- * first element of list
- *---------------------------------------------------------------------------*/
-struct onefile *store
- (register struct onefile *new, /* new entry to store into list */
- register struct onefile *top) /* current first entry in list */
-{
- register struct onefile *old, *p;
-
- if (last == NULL) /* enter very first element ? */
- {
- new->next = NULL;
- new->prev = NULL;
- last = new; /* init last */
- return (new); /* return new first */
- }
- p = top; /* p = old first element */
- old = NULL;
- while (p)
- {
- if ((strcmp(p->fname, new->fname)) < 0) /* current less new ? */
- {
- old = p;
- p = p->next;
- }
- else
- { /* current >= new */
-
- if (p->prev)
- {
- p->prev->next = new;
- new->next = p;
- new->prev = p->prev;
- p->prev = new;
- return (top);
- }
- new->next = p;
- new->prev = NULL;
- p->prev = new;
- return (new);
- }
- }
- old->next = new;
- new->next = NULL;
- new->prev = old;
- last = new;
- return (first);
-}
-
-/*---------------------------------------------------------------------------*
- * read current directory and build up a doubly linked sorted list
- *---------------------------------------------------------------------------*/
-int
-fill_list(void)
-{
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
- register struct dirent *dp;
-#else
- register struct direct *dp;
-#endif
- register struct onefile *new_entry;
- register DIR *dirp;
- int flcnt = 0;
- char tmp[80];
- char *s, *d;
-
- if ((dirp = opendir(spooldir)) == NULL)
- fatal("cannot open spooldirectory %s!\n", spooldir);
-
- for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
- {
- if(!isdigit(*(dp->d_name)))
- continue;
-
- if ((new_entry = (struct onefile *) malloc(sizeof(struct onefile))) == NULL)
- {
- fatal("files.c, fill_list(): structure onefile malloc failed");
- }
-
- /* alloc filename memory and copy name into it */
-
- if ((new_entry->fname = (char *) malloc(strlen(dp->d_name) + 1)) == NULL)
- {
- fatal("files.c, fill_list(): malloc filename string memory failed");
- }
-
- strcpy(new_entry->fname, dp->d_name);
-
- /* fill in remaining fields from filename */
-
- tmp[0] = dp->d_name[4]; /* day msb */
- tmp[1] = dp->d_name[5]; /* day lsb */
- tmp[2] = '.';
- tmp[3] = dp->d_name[2]; /* month msb */
- tmp[4] = dp->d_name[3]; /* month lsb */
- tmp[5] = '.';
- tmp[6] = dp->d_name[0]; /* year msb */
- tmp[7] = dp->d_name[1]; /* year lsb */
- tmp[8] = '\0';
-
- if((new_entry->date = (char *) malloc(strlen(tmp) + 1)) == NULL)
- {
- fatal("files.c, fill_list(): malloc date string memory failed");
- }
-
- strcpy(new_entry->date, tmp);
-
- tmp[0] = dp->d_name[6]; /* hour msb */
- tmp[1] = dp->d_name[7]; /* hour lsb */
- tmp[2] = ':';
- tmp[3] = dp->d_name[8]; /* minute msb */
- tmp[4] = dp->d_name[9]; /* minute lsb */
- tmp[5] = ':';
- tmp[6] = dp->d_name[10]; /* second msb */
- tmp[7] = dp->d_name[11]; /* second lsb */
- tmp[8] = '\0';
-
- if((new_entry->time = (char *) malloc(strlen(tmp) + 1)) == NULL)
- {
- fatal("files.c, fill_list(): malloc time string memory failed");
- }
-
- strcpy(new_entry->time, tmp);
-
- /* destination number */
-
- s = &dp->d_name[13];
- d = &tmp[0];
-
- while(*s && (*s != '-'))
- *d++ = *s++;
-
- *d = '\0';
-
- if((new_entry->dstnumber = (char *) malloc(strlen(tmp) + 1)) == NULL)
- {
- fatal("files.c, fill_list(): malloc dstnumber string memory failed");
- }
-
- strcpy(new_entry->dstnumber, tmp);
-
- /* source number */
-
- s++;
- d = &tmp[0];
-
- while(*s && (*s != '-'))
- *d++ = *s++;
-
- *d = '\0';
-
- if((new_entry->srcnumber = (char *) malloc(strlen(tmp) + 1)) == NULL)
- {
- fatal("files.c, fill_list(): malloc srcnumber string memory failed");
- }
-
- strcpy(new_entry->srcnumber, tmp);
-
- /* length in seconds */
-
- s++;
- d = &tmp[0];
-
- while(*s && (*s != '-'))
- *d++ = *s++;
-
- *d = '\0';
-
- if((new_entry->seconds = (char *) malloc(strlen(tmp) + 1)) == NULL)
- {
- fatal("files.c, fill_list(): malloc seconds string memory failed");
- }
-
- strcpy(new_entry->seconds, tmp);
-
- /* search for alias and add if found */
-
- new_entry->alias = get_alias(new_entry->srcnumber);
-
- /* sort entry into linked list */
-
- first = store(new_entry, first);
-
- flcnt++; /* increment file count */
- }
- closedir(dirp); /* close current dir */
- return(flcnt); /* ok return */
-}
-
-/*---------------------------------------------------------------------------*
- * free the current malloc'ed list
- *---------------------------------------------------------------------------*/
-void
-free_list(void)
-{
- register struct onefile *dir;
- register struct onefile *tmp;
-
- dir = first; /* start of linked list */
-
- while (dir) /* free all */
- {
- tmp = dir->next; /* save ptr to next entry */
- free(dir->fname); /* free filename space */
- free(dir->date);
- free(dir->time);
- free(dir->srcnumber);
- free(dir->dstnumber);
- free(dir->seconds);
- free(dir); /* free struct space */
- dir = tmp; /* ptr = ptr to next entry */
- }
- first = NULL; /* first ptr = NULL */
- last = NULL; /* last ptr = NULL */
-}
-
-/*---------------------------------------------------------------------------*
- * delete a file
- *---------------------------------------------------------------------------*/
-void
-delete(struct onefile *this)
-{
- char buffer[MAXPATHLEN+1];
-
- if(this == NULL)
- return;
-
- sprintf(buffer, "%s", this->fname);
-
- unlink(buffer);
-
- free_list();
-
- wclear(main_w);
-
- init_files(cur_pos);
-}
-
-/*---------------------------------------------------------------------------*
- * reread the spool directory
- *---------------------------------------------------------------------------*/
-void
-reread(void)
-{
- free_list();
-
- wclear(main_w);
-
- init_files(cur_pos);
-}
-
-/*---------------------------------------------------------------------------*
- * play a file
- *---------------------------------------------------------------------------*/
-void
-play(struct onefile *this)
-{
- char buffer[MAXPATHLEN+1];
-
- if(this == NULL)
- return;
-
- sprintf(buffer, playstring, this->fname);
-
- system(buffer);
-}
-
-/*---------------------------------- EOF -------------------------------------*/
diff --git a/usr.sbin/i4b/isdntel/isdntel.8 b/usr.sbin/i4b/isdntel/isdntel.8
deleted file mode 100644
index d87c848a8bc0..000000000000
--- a/usr.sbin/i4b/isdntel/isdntel.8
+++ /dev/null
@@ -1,94 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" last edit-date: [Sat Dec 5 18:16:19 1998]
-.\"
-.\" $Id: isdntel.8,v 1.6 1998/12/05 18:03:58 hm Exp $
-.\"
-.Dd July 11, 1998
-.Dt isdntel 8
-.Sh NAME
-.Nm isdntel
-.Nd isdn4bsd telephone answering management utility
-.Sh SYNOPSIS
-.Nm isdntel
-.Op Fl a Ar aliasfile
-.Op Fl d Ar spooldir
-.Op Fl p Ar playcommand
-.Op Fl t Ar timeout
-.Sh DESCRIPTION
-.Nm
-is used to provide an "answering machine" functionality for incoming
-telephone voice messages.
-.Pp
-The following options are supported:
-.Bl -tag -width Ds
-.It Fl a
-Use
-.Ar aliasfile
-as the pathname for an aliasfile containing aliases for phone numbers. The
-default path is
-.Em /etc/isdn/isdntel.alias .
-The format of an alias entry is the number string followed by one or more
-spaces or tabs. The rest of the line is taken as the alias string. Comments
-are introduced by a leading blank, tab or "#" character.
-.It Fl d
-Use
-.Ar spooldir
-as the directory where the incoming voice messages are stored by the
-"answ" script called by
-.Xr isdnd 8 .
-This defaults to the directory
-.Em /var/isdn .
-The format of a voice message filename is:
-.Pp
-.Dl YYMMDDhhmmss-dest_number-source_number-length_in_secs
-.It Fl p
-Use
-.Ar playcommand
-as the command string to execute for playing a voice message to some audio
-output facility. The characters
-.Em %s
-are replaced by the currently selected filename. The default string is
-.Em cat %s | alaw2ulaw >/dev/audio
-.It Fl t
-The value for
-.Ar timeout
-specifies the time in seconds the program rereads the spool directory
-when there is no keyboard activity.
-.El
-.Pp
-The screen output should be obvious. If in doubt, consult the source.
-.Sh SEE ALSO
-.Xr isdnd 8
-.Xr isdnd.rc 5
-.Xr i4btel 4
-
-.Sh BUGS
-Still two or more left.
-
-.Sh AUTHOR
-The
-.Nm
-utility and this manual page were written by Hellmuth Michaelis (hm@kts.org)
diff --git a/usr.sbin/i4b/isdntel/main.c b/usr.sbin/i4b/isdntel/main.c
deleted file mode 100644
index fd6a3b2ccf56..000000000000
--- a/usr.sbin/i4b/isdntel/main.c
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * isdntel - isdn4bsd telephone answering machine support
- * ======================================================
- *
- * $Id: main.c,v 1.6 1998/12/05 18:03:59 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:16:33 1998]
- *
- *----------------------------------------------------------------------------*/
-
-#define MAIN
-#include "defs.h"
-#include "alias.h"
-
-static void usage( void );
-
-static int top_dis = 0;
-static int bot_dis = 0;
-static int cur_pos_scr = 0;
-
-static void makecurrent(int cur_pos, struct onefile *cur_file, int cold);
-
-/*---------------------------------------------------------------------------*
- * program entry
- *---------------------------------------------------------------------------*/
-int
-main(int argc, char **argv)
-{
- int i;
- int kchar;
-
- char *spooldir = SPOOLDIR;
- char *playstring = PLAYCMD;
- char *aliasfile = ALIASFILE;
- int rrtimeout = REREADTIMEOUT;
-
- extern char *optarg;
-
- while ((i = getopt(argc, argv, "a:d:p:t:?")) != EOF)
- {
- switch (i)
- {
- case 'a':
- aliasfile = optarg;
- break;
-
- case 'd':
- spooldir = optarg;
- break;
-
- case 'p':
- playstring = optarg;
- break;
-
- case 't':
- if(isdigit(*optarg))
- {
- rrtimeout = strtoul(optarg, NULL, 10);
- }
- else
- {
- usage();
- }
- break;
-
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if(rrtimeout < 10)
- rrtimeout = 10;
-
- if((chdir(spooldir)) != 0)
- fatal("cannot change directory to spooldir %s!", spooldir);
-
- init_alias(aliasfile);
-
- init_screen();
-
- init_files(0);
-
- /* go into loop */
-
- for (;;)
- {
- fd_set set;
- struct timeval timeout;
-
- FD_ZERO(&set);
- FD_SET(STDIN_FILENO, &set);
- timeout.tv_sec = rrtimeout;
- timeout.tv_usec = 0;
-
- /* if no char is available within timeout, reread spool */
-
- if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
- {
- reread();
- continue;
- }
-
- kchar = wgetch(main_w); /* get char */
-
- switch (kchar)
- {
- case CR:
- case LF:
-#ifdef KEY_ENTER
- case KEY_ENTER:
-#endif
- do_menu();
- break;
-
- case KEY_UP: /* up-move cursor */
- if(cur_file && cur_file->prev)
- {
- cur_file = cur_file->prev;
- cur_pos--;
- }
- break;
-
-
- case TAB:
- case KEY_DOWN: /* down-move cursor */
- if(cur_file && cur_file->next)
- {
- cur_file = cur_file->next;
- cur_pos++;
- }
- break;
-
- case KEY_HOME: /* move cursor to first dir */
- break;
-
- case KEY_LL: /* move cursor to last file */
- break;
-
- case CNTRL_D:
- do_quit(0);
- break;
-
- case CNTRL_L: /* refresh */
- touchwin(curscr);
- wrefresh(curscr);
- break;
-
- }
- makecurrent(cur_pos, cur_file, 0);
- }
-
- do_quit(0);
-
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * handle horizontal selection bar movement
- *---------------------------------------------------------------------------*/
-static void
-makecurrent(int cur_pos, struct onefile *cur_file, int cold)
-{
- static int lastpos;
- static struct onefile *lastfile;
- char buffer[256];
-
- /* un-higlight current horizontal bar */
-
- if(!cold && lastfile && cur_file)
- {
- sprintf(buffer, "%s %s %-16s %-16s %-20s %-6s%*s",
- lastfile->date, lastfile->time,
- lastfile->dstnumber, lastfile->srcnumber,
- lastfile->alias == NULL ? "-/-" : lastfile->alias,
- lastfile->seconds,
- COLS - LAST_POS - 2, "");
-
- wattroff(main_w, A_REVERSE);
- mvwprintw(main_w, lastpos, 0, "%s", buffer);
- wattroff(main_w, A_REVERSE);
- }
-
- if(cur_file == NULL)
- {
- lastpos = cur_pos_scr;
- lastfile = cur_file;
- return;
- }
-
- /* have to scroll up or down ? */
-
- if(cur_pos >= bot_dis)
- {
- /* scroll up */
-
- wscrl(main_w, 1);
-
- bot_dis++;
- top_dis++;
- cur_pos_scr = LINES-START_O-3;
- }
- else if(cur_pos < top_dis)
- {
- /* scroll down */
-
- wscrl(main_w, -1);
-
- bot_dis--;
- top_dis--;
- cur_pos_scr = 0;
- }
- else
- {
- cur_pos_scr = cur_pos - top_dis;
- }
-
- sprintf(buffer, "%s %s %-16s %-16s %-20s %-6s%*s",
- cur_file->date, cur_file->time,
- cur_file->dstnumber, cur_file->srcnumber,
- cur_file->alias == NULL ? "-/-" : cur_file->alias,
- cur_file->seconds,
- COLS - LAST_POS - 2, "");
-
- wattron(main_w, A_REVERSE);
- mvwprintw(main_w, cur_pos_scr, 0, "%s", buffer);
- wattroff(main_w, A_REVERSE);
-
- lastpos = cur_pos_scr;
- lastfile = cur_file;
-
- wrefresh(main_w);
-}
-
-/*---------------------------------------------------------------------------*
- * exit program
- *---------------------------------------------------------------------------*/
-void
-do_quit(int exitval)
-{
- move(LINES-1, 0);
- clrtoeol();
- refresh();
- endwin();
- exit(exitval);
-}
-
-/*---------------------------------------------------------------------------*
- * usage display and exit
- *---------------------------------------------------------------------------*/
-static void
-usage(void)
-{
- fprintf(stderr, "\n");
- fprintf(stderr, "isdntel - isdn telephone answering management support utility (version %s.%s)\n", VERSION, REL);
- fprintf(stderr, " usage: isdntel -a <filename> -d <directory> -p <command> -t <timeout>\n");
- fprintf(stderr, " -a <filename> use filename as alias file\n");
- fprintf(stderr, " -d <directory> use directory as spool directory\n");
- fprintf(stderr, " -p <command> specify commandline for play command\n");
- fprintf(stderr, " -t <timeout> spool directory reread timeout in seconds\n");
- fprintf(stderr, "\n");
- exit(1);
-}
-
-/*---------------------------------------------------------------------------*
- * fatal error exit
- *---------------------------------------------------------------------------*/
-void
-fatal(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
-
- if(curses_ready)
- {
- move(LINES-1, 0);
- clrtoeol();
- refresh();
- endwin();
- }
-
- fprintf(stderr, "\nFatal error: ");
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n\n");
-
- va_end(ap);
-
- exit(1);
-}
-
-/*---------------------------------------------------------------------------*
- * error printing
- *---------------------------------------------------------------------------*/
-void
-error(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
-
- if(curses_ready)
- {
- wprintw(main_w, "ERROR: ");
- vwprintw(main_w, fmt, ap);
- wprintw(main_w, "\n");
- wrefresh(main_w);
- }
- else
- {
- fprintf(stderr, "ERROR: ");
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- }
-
- va_end(ap);
-}
-
-/*---------------------------------------------------------------------------*
- * read files and fill display
- *---------------------------------------------------------------------------*/
-void
-init_files(int inipos)
-{
- int i;
-
- nofiles = fill_list();
-
- top_dis = 0;
- bot_dis = 0;
-
- cur_file = first;
-
- cur_pos = 0;
- cur_pos_scr = 0;
-
- if(nofiles == 0)
- return;
-
- for(i=0; (i < nofiles) && (i < (LINES-START_O-2)); i++)
- {
- mvwprintw(main_w, i, 0, "%s %s", cur_file->date, cur_file->time);
- mvwprintw(main_w, i, DST_POS, "%s", cur_file->dstnumber);
- mvwprintw(main_w, i, SRC_POS, "%s", cur_file->srcnumber);
- mvwprintw(main_w, i, ALI_POS,"%s", cur_file->alias == NULL ? "-/-" : cur_file->alias);
- mvwprintw(main_w, i, SEC_POS,"%s", cur_file->seconds);
-
- bot_dis++;
-
- if((cur_file = cur_file->next) == NULL)
- break;
- }
-
- cur_file = first;
-
- if(inipos)
- {
- for(i=0; i < inipos; i++)
- {
- if(cur_file->next != NULL)
- cur_file = cur_file->next;
- else
- break;
- }
- }
- makecurrent(cur_pos, cur_file, 1);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntelctl/Makefile b/usr.sbin/i4b/isdntelctl/Makefile
deleted file mode 100644
index b38f2063671c..000000000000
--- a/usr.sbin/i4b/isdntelctl/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-PROG = isdntelctl
-SRCS = main.c
-MAN8 = isdntelctl.8
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/i4b/isdntelctl/isdntelctl.8 b/usr.sbin/i4b/isdntelctl/isdntelctl.8
deleted file mode 100644
index 2bd45d270b5c..000000000000
--- a/usr.sbin/i4b/isdntelctl/isdntelctl.8
+++ /dev/null
@@ -1,78 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdntelctl.8,v 1.4 1998/12/14 10:31:55 hm Exp $
-.\"
-.\" last edit-date: [Mon Dec 14 11:34:51 1998]
-.\"
-.Dd December 14, 1998
-.Dt isdntelctl 8
-.Sh NAME
-.Nm isdntelctl
-.Nd control isdn4bsd telephone sound format conversion
-.Sh SYNOPSIS
-.Nm
-.Op Fl c
-.Op Fl g
-.Op Fl u Ar unit
-.Op Fl A
-.Op Fl U
-.Sh DESCRIPTION
-.Nm isdntelctl
-is part of the isdn4bsd package and is used to configure the sound format
-conversion facilities of the /dev/i4btel interfaces.
-.Pp
-The following options are available:
-.Bl -tag -width Ds
-.It Fl c
-Clear the telephone input queue.
-.It Fl g
-Get the sound format currently in use.
-.It Fl u
-Set the /dev/i4btel unit number. The default value is zero to access
-device /dev/i4btel0.
-.It Fl A
-Set sound format to A-Law.
-.It Fl U
-Set sound format to u-Law.
-.Pp
-.Sh FILES
-/dev/i4btel<n>
-
-.Sh STANDARDS
-A-Law and u-Law are specified in ITU Recommendation G.711.
-
-.Sh EXAMPLES
-The command:
-.Bd -literal -offset indent
-isdntelctl -g
-.Ed
-.Pp
-displays the currently used sound format for device /dev/i4btel0.
-
-.Sh AUTHOR
-The
-.Nm
-utility and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/isdntelctl/main.c b/usr.sbin/i4b/isdntelctl/main.c
deleted file mode 100644
index 4309b2497cea..000000000000
--- a/usr.sbin/i4b/isdntelctl/main.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * isdntelctl - i4b set telephone interface options
- * ------------------------------------------------
- *
- * $Id: main.c,v 1.4 1998/12/14 10:31:57 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:17:17 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <machine/i4b_tel_ioctl.h>
-
-static void usage ( void );
-
-#define I4BTELDEVICE "/dev/i4btel"
-
-int opt_get = 0;
-int opt_unit = 0;
-int opt_U = 0;
-int opt_A = 0;
-int opt_C = 0;
-
-/*---------------------------------------------------------------------------*
- * program entry
- *---------------------------------------------------------------------------*/
-int
-main(int argc, char **argv)
-{
- int c;
- int ret;
- int telfd;
- char namebuffer[128];
-
- while ((c = getopt(argc, argv, "cgu:AU?")) != EOF)
- {
- switch(c)
- {
- case 'c':
- opt_C = 1;
- break;
-
- case 'g':
- opt_get = 1;
- break;
-
- case 'u':
- opt_unit = atoi(optarg);
- if(opt_unit < 0 || opt_unit > 9)
- usage();
- break;
-
- case 'A':
- opt_A = 1;
- break;
-
- case 'U':
- opt_U = 1;
- break;
-
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if(opt_get == 0 && opt_U == 0 && opt_A && opt_C == 0)
- {
- opt_get = 1;
- }
-
- if((opt_get + opt_U + opt_A + opt_C) > 1)
- {
- usage();
- }
-
- sprintf(namebuffer,"%s%d", I4BTELDEVICE, opt_unit);
-
- if((telfd = open(namebuffer, O_RDWR)) < 0)
- {
- fprintf(stderr, "isdntelctl: cannot open %s: %s\n", namebuffer, strerror(errno));
- exit(1);
- }
-
- if(opt_get)
- {
- int format;
-
- if((ret = ioctl(telfd, I4B_TEL_GETAUDIOFMT, &format)) < 0)
- {
- fprintf(stderr, "ioctl I4B_TEL_GETAUDIOFMT failed: %s", strerror(errno));
- exit(1);
- }
-
- if(format == CVT_NONE)
- {
- printf("device %s uses A-Law sound format\n", namebuffer);
- }
- else if(format == CVT_ALAW2ULAW)
- {
- printf("device %s uses u-Law sound format\n", namebuffer);
- }
- else
- {
- printf("ERROR, device %s uses unknown format %d!\n", namebuffer, format);
- }
- exit(0);
- }
-
- if(opt_A)
- {
- int format = CVT_NONE;
-
- if((ret = ioctl(telfd, I4B_TEL_SETAUDIOFMT, &format)) < 0)
- {
- fprintf(stderr, "ioctl I4B_TEL_SETAUDIOFMT failed: %s", strerror(errno));
- exit(1);
- }
- exit(0);
- }
-
- if(opt_U)
- {
- int format = CVT_ALAW2ULAW;
-
- if((ret = ioctl(telfd, I4B_TEL_SETAUDIOFMT, &format)) < 0)
- {
- fprintf(stderr, "ioctl I4B_TEL_SETAUDIOFMT failed: %s", strerror(errno));
- exit(1);
- }
- exit(0);
- }
- if(opt_C)
- {
- int dummy;
- if((ret = ioctl(telfd, I4B_TEL_EMPTYINPUTQUEUE, &dummy)) < 0)
- {
- fprintf(stderr, "ioctl I4B_TEL_EMPTYINPUTQUEUE failed: %s", strerror(errno));
- exit(1);
- }
- exit(0);
- }
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * usage display and exit
- *---------------------------------------------------------------------------*/
-static void
-usage(void)
-{
- fprintf(stderr, "\n");
- fprintf(stderr, "isdntelctl - i4b telephone i/f control, compiled %s %s\n",__DATE__, __TIME__);
- fprintf(stderr, "usage: isdndebug -e -h -g -l <layer> -m -r -s <value> -u <unit> -z -H\n");
- fprintf(stderr, " -g get current settings\n");
- fprintf(stderr, " -u unit specify unit number\n");
- fprintf(stderr, " -A set interface to A-Law coding\n");
- fprintf(stderr, " -U set interface to u-Law coding\n");
- fprintf(stderr, " -c clear input queue\n");
- fprintf(stderr, "\n");
- exit(1);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntest/Makefile b/usr.sbin/i4b/isdntest/Makefile
deleted file mode 100644
index c1240ccb8e7e..000000000000
--- a/usr.sbin/i4b/isdntest/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG = isdntest
-SRCS = main.c
-MAN8 = isdntest.8
-
-install:
- @echo isdntest is not installed automatically
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/i4b/isdntest/isdntest.8 b/usr.sbin/i4b/isdntest/isdntest.8
deleted file mode 100644
index 7e0352317247..000000000000
--- a/usr.sbin/i4b/isdntest/isdntest.8
+++ /dev/null
@@ -1,103 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdntest.8,v 1.6 1998/12/16 13:39:47 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:17:35 1998]
-.\"
-.Dd July 9, 1998
-.Dt isdntest 8
-.Sh NAME
-.Nm isdntest
-.Nd isdn4bsd debugging and verification tool
-.Sh SYNOPSIS
-.Nm
-.Op Fl c Ar unit
-.Op Fl h
-.Op Fl i Ar number
-.Op Fl o Ar number
-.Op Fl w
-.Sh DESCRIPTION
-.Nm isdntest
-is part of the isdn4bsd package and may be used as a stimulation tool
-for debugging the isdn4bsd kernel functionality.
-.Pp
-NOTE:
-.Nm Isdntest
-must be run
-.Em instead
-of the
-.Xr isdnd 8
-daemon and can not be used while the daemon runs.
-.Pp
-The following options are available:
-.Bl -tag -width Ds
-.It Fl c
-Use controller unit number for test.
-.It Fl h
-Use HDLC as the B channel layer 1 protocol instead of no protocol.
-.It Fl i
-Use number to verify the incoming number.
-.It Fl o
-Use number as the outgoing number to dial.
-.It Fl w
-Wait for keyboard input for terminating the call.
-.El
-.Pp
-The
-.Nm
-utility is currently of not much use for end users, it is primarily a debugging
-tool for development and is part of the release in the hope, that someone
-enhances it as a real self test and setup-verification tool!
-.Pp
-.Nm Isdntest
-does almost no error checking and error recovery, so unexpected
-hangs or crashes may occur.
-
-.Sh EXAMPLES
-For the following example, it is assumed that a machine with isdn4bsd
-installed is connected to an S0 bus and that one of the valid MSN's (MSN = Multiple Subscriber Number
-= telephone number) on this bus is
-.Em 42 .
-The
-.Xr isdnd 8
-.Em must
-not currently running on that machine! Executing:
-.Bd -literal -offset indent
-isdntest -i 42 -o 42
-.Ed
-.Pp
-will setup an outgoing call from that machine to itself, connect to itself
-and disconnect after 5 seconds.
-.Nm Isdntest
-has to be finished by the user by entering Control-C.
-.Pp
-.Sh FILES
-/dev/i4b
-
-.Sh AUTHOR
-The
-.Nm
-utility and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/isdntest/main.c b/usr.sbin/i4b/isdntest/main.c
deleted file mode 100644
index 8e75be274ceb..000000000000
--- a/usr.sbin/i4b/isdntest/main.c
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * main.c - i4b selftest utility
- * -----------------------------
- *
- * $Id: main.c,v 1.9 1998/12/05 18:04:06 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:18:17 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-static void kbdrdhdl ( void );
-static void isdnrdhdl (int isdnfd );
-
-void handle_connect_ind(unsigned char *ptr);
-void handle_disconnect(unsigned char *ptr);
-void handle_connect_active_ind(unsigned char *ptr);
-
-int connect_response(int isdnfd, unsigned int cdid, int response);
-int disconnect_request(int isdnfd, unsigned int cdid);
-unsigned int get_cdid(int isdnfd);
-int connect_request(int isdnfd, unsigned int cdid);
-int do_test(void);
-static void cleanup(void);
-static void usage(void);
-void setup_wrfix(int len, unsigned char *buf);
-int check_rd(int len, unsigned char *wbuf, unsigned char *rdbuf);
-
-static int isdnfd;
-char outgoingnumber[32];
-char incomingnumber[32];
-int debug_level = 0;
-
-#define I4BDEVICE "/dev/i4b"
-#define DATADEV0 "/dev/i4brbch0"
-#define DATAUNIT0 0
-#define DATADEV1 "/dev/i4brbch1"
-#define DATAUNIT1 1
-
-unsigned int out_cdid = CDID_UNUSED;
-unsigned int in_cdid = CDID_UNUSED;
-
-int waitchar = 0;
-int usehdlc = 0;
-int controller = 0;
-int dotest = 0;
-
-/*---------------------------------------------------------------------------*
- * program entry
- *---------------------------------------------------------------------------*/
-int
-main(int argc, char **argv)
-{
- int i;
- int c;
- fd_set set;
- int ret;
- char *ptr;
-
- incomingnumber[0] = '\0';
- outgoingnumber[0] = '\0';
-
- while ((c = getopt(argc, argv, "c:d:hi:o:t:w?")) != EOF)
- {
- switch(c)
- {
- case 'c':
- if(isdigit(*optarg))
- {
- controller = strtoul(optarg, NULL, 10);
- }
- else
- {
- fprintf(stderr, "Error: option -c requires a numeric argument!\n");
- usage();
- }
- break;
-
- case 'd':
- if(isdigit(*optarg))
- {
- debug_level = strtoul(optarg, NULL, 10);
- }
- else
- {
- fprintf(stderr, "Error: option -d requires a numeric argument!\n");
- usage();
- }
- break;
-
- case 'o':
- i = 0;
- ptr = optarg;
-
- while(*ptr)
- {
- if(isdigit(*ptr))
- {
- outgoingnumber[i++] = *ptr++;
- }
- else
- {
- fprintf(stderr, "Error: option -o requires a numeric argument!\n");
- usage();
- }
- }
- outgoingnumber[i] = '\0';
- break;
-
- case 'i':
- i = 0;
- ptr = optarg;
-
- while(*ptr)
- {
- if(isdigit(*ptr))
- {
- incomingnumber[i++] = *ptr++;
- }
- else
- {
- fprintf(stderr, "Error: option -i requires a numeric argument!\n");
- usage();
- }
- }
- incomingnumber[i] = '\0';
- break;
-
- case 'w':
- waitchar = 1;
- break;
-
- case 'h':
- usehdlc = 1;
- break;
-
- case 't':
- if(isdigit(*optarg))
- {
- dotest = strtoul(optarg, NULL, 10);
- }
- else
- {
- fprintf(stderr, "Error: option -t requires a numeric argument!\n");
- usage();
- }
- break;
-
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if((strlen(incomingnumber) == 0) || (strlen(outgoingnumber) == 0))
- usage();
-
- fprintf(stderr, "isdntest: accepting calls from telephone number [%s] \n", incomingnumber);
- fprintf(stderr, "isdntest: calling out telephone number [%s] \n", outgoingnumber);
-
- if((atexit(cleanup)) != 0)
- {
- fprintf(stderr, "isdntest: atexit error: %s\n", strerror(errno));
- exit(1);
- }
-
- /* open isdn device */
-
- if((isdnfd = open(I4BDEVICE, O_RDWR)) < 0)
- {
- fprintf(stderr, "\nisdntest: cannot open %s: %s\n", I4BDEVICE, strerror(errno));
- fprintf(stderr, " isdnd is probably running, to use isdntest,\n");
- fprintf(stderr, " terminate isdnd and then run isdntest again!\n");
- exit(1);
- }
-
- if((out_cdid = get_cdid(isdnfd)) == 0)
- {
- fprintf(stderr, "isdntest: error getting cdid: %s\n", strerror(errno));
- exit(1);
- }
-
- if((connect_request(isdnfd, out_cdid)) == -1)
- {
- fprintf(stderr, "isdntest: error, outgoing call failed!\n");
- exit(1);
- }
-
- for(;;)
- {
- FD_ZERO(&set);
-
- FD_SET(0, &set);
-
- FD_SET(isdnfd, &set);
-
- ret = select(isdnfd + 1, &set, NULL, NULL, NULL);
-
- if(ret > 0)
- {
- if(FD_ISSET(isdnfd, &set))
- isdnrdhdl(isdnfd);
-
- if(FD_ISSET(0, &set))
- kbdrdhdl();
- }
- else
- {
- fprintf(stderr, "isdntest: select error: %s\n", strerror(errno));
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * data from keyboard available
- *---------------------------------------------------------------------------*/
-static void
-kbdrdhdl(void)
-{
- cleanup();
- exit(2);
-}
-
-/*---------------------------------------------------------------------------*
- * data from /dev/isdn available, read and process them
- *---------------------------------------------------------------------------*/
-static void
-isdnrdhdl(int isdnfd)
-{
- static unsigned char buf[1024];
- int len;
-
- if((len = read(isdnfd, buf, 1024 - 1)) > 0)
- {
- switch (buf[0])
- {
- case MSG_CONNECT_IND:
- handle_connect_ind(&buf[0]);
- break;
-
- case MSG_CONNECT_ACTIVE_IND:
- handle_connect_active_ind(&buf[0]);
- break;
-
- case MSG_DISCONNECT_IND:
- handle_disconnect(&buf[0]);
- break;
-
- default:
- if(debug_level)
- fprintf(stderr, "isdntest: unknown message 0x%x = %c\n", buf[0], buf[0]);
- break;
- }
- }
- else
- {
- fprintf(stderr, "isdntest: read error, errno = %d, length = %d", errno, len);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * usage display and exit
- *---------------------------------------------------------------------------*/
-static void
-usage(void)
-{
- fprintf(stderr, "\n");
- fprintf(stderr, "isdntest - i4b selftest, compiled %s %s\n",__DATE__, __TIME__);
- fprintf(stderr, "usage: isdntest -c <ctrl> -h -i <telno> -o <telno>\n");
- fprintf(stderr, " -c <ctrl> specify controller to use\n");
- fprintf(stderr, " -h use HDLC as Bchannel protocol\n");
- fprintf(stderr, " -i <telno> incoming telephone number\n");
- fprintf(stderr, " -o <telno> outgoing telephone number\n");
- fprintf(stderr, " -w wait for keyboard entry to disconnect\n");
- fprintf(stderr, " -t num send test pattern num times\n");
- fprintf(stderr, "\n");
- exit(1);
-}
-
-/*---------------------------------------------------------------------------*
- * initiate an outgoing connection
- *---------------------------------------------------------------------------*/
-int
-connect_request(int isdnfd, unsigned int cdid)
-{
- msg_connect_req_t mcr;
- int ret;
-
- bzero(&mcr, sizeof(msg_connect_req_t));
-
- mcr.controller = controller;
- mcr.channel = CHAN_ANY; /* any channel */
- mcr.cdid = cdid; /* cdid from get_cdid() */
-
- if(usehdlc)
- mcr.bprot = BPROT_RHDLC;/* b channel protocol */
- else
- mcr.bprot = BPROT_NONE; /* b channel protocol */
-
- mcr.driver = BDRV_RBCH; /* raw b channel driver */
- mcr.driver_unit = DATAUNIT0; /* raw b channel driver unit */
-
- strcpy(mcr.dst_telno, outgoingnumber);
- strcpy(mcr.src_telno, incomingnumber);
-
- if((ret = ioctl(isdnfd, I4B_CONNECT_REQ, &mcr)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CONNECT_REQ failed: %s", strerror(errno));
- return(-1);
- }
- fprintf(stderr, "isdntest: calling out to telephone number [%s] \n", outgoingnumber);
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * handle setup indicator
- *---------------------------------------------------------------------------*/
-void
-handle_connect_ind(unsigned char *ptr)
-{
- msg_connect_ind_t *msi = (msg_connect_ind_t *)ptr;
-
- fprintf(stderr, "isdntest: incoming SETUP: from %s to %s\n",
- msi->src_telno,
- msi->dst_telno);
-
- fprintf(stderr, " channel %d, controller %d, bprot %d, cdid %d\n",
- msi->channel,
- msi->controller,
- msi->bprot,
- msi->header.cdid);
-
- in_cdid = msi->header.cdid;
-
- if(strcmp(msi->dst_telno, outgoingnumber))
- {
- msg_connect_resp_t msr;
- int ret;
-
- fprintf(stderr, "isdntest: ignoring incoming SETUP: my number [%s] != outgoing [%s]\n",
- msi->dst_telno, outgoingnumber);
-
- msr.cdid = in_cdid;
- msr.response = SETUP_RESP_DNTCRE;
-
- if((ret = ioctl(isdnfd, I4B_CONNECT_RESP, &msr)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CONNECT_RESP ignore failed: %s", strerror(errno));
- exit(1);
- }
-
- }
- else
- {
- msg_connect_resp_t msr;
- int ret;
-
- fprintf(stderr, "isdntest: accepting call, sending CONNECT_RESPONSE .....\n");
-
- msr.cdid = in_cdid;
- msr.response = SETUP_RESP_ACCEPT;
-
- if(usehdlc)
- msr.bprot = BPROT_RHDLC;
- else
- msr.bprot = BPROT_NONE;
-
- msr.driver = BDRV_RBCH;
- msr.driver_unit = DATAUNIT1;
-
- if((ret = ioctl(isdnfd, I4B_CONNECT_RESP, &msr)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CONNECT_RESP accept failed: %s", strerror(errno));
- exit(1);
- }
- }
-}
-
-#define SLEEPTIME 5
-
-/*---------------------------------------------------------------------------*
- * handle connection active
- *---------------------------------------------------------------------------*/
-void
-handle_connect_active_ind(unsigned char *ptr)
-{
- msg_connect_active_ind_t *msi = (msg_connect_active_ind_t *)ptr;
- int i;
-
- fprintf(stderr, "isdntest: connection active, cdid %d\n", msi->header.cdid);
-
- if(out_cdid == msi->header.cdid)
- {
- if(waitchar)
- {
- fprintf(stderr, "isdntest: press any key to disconnect ...%c%c%c\n", 0x07, 0x07, 0x07);
- getchar();
- }
- else
- {
- if(dotest)
- {
- do_test();
- }
- else
- {
- fprintf(stderr, "isdntest: %d secs delay until disconnect:", SLEEPTIME);
-
- for(i=0; i < SLEEPTIME;i++)
- {
- fprintf(stderr, " .");
- sleep(1);
- }
- fprintf(stderr, "\n");
- }
- cleanup();
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * handle disconnect indication
- *---------------------------------------------------------------------------*/
-void
-handle_disconnect(unsigned char *ptr)
-{
- msg_disconnect_ind_t *mdi = (msg_disconnect_ind_t *)ptr;
-
- if(mdi->header.cdid == out_cdid)
- {
- fprintf(stderr, "isdntest: incoming disconnect indication, cdid %d (out_cdid), cause %d\n",
- mdi->header.cdid, mdi->cause);
-
- out_cdid = CDID_UNUSED;
- }
- else if(mdi->header.cdid == in_cdid)
- {
- fprintf(stderr, "isdntest: incoming disconnect indication, cdid %d (in_cdid), cause %d\n",
- mdi->header.cdid, mdi->cause);
- in_cdid = CDID_UNUSED;
- }
- else
- {
- fprintf(stderr, "isdntest: incoming disconnect indication, cdid %d (???), cause %d\n",
- mdi->header.cdid, mdi->cause);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * hang up
- *---------------------------------------------------------------------------*/
-int
-disconnect_request(int isdnfd, unsigned int cdid)
-{
- msg_discon_req_t mdr;
- int ret;
-
- mdr.cdid = cdid;
- mdr.cause = (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL;
-
- if((ret = ioctl(isdnfd, I4B_DISCONNECT_REQ, &mdr)) < 0)
- {
- fprintf(stderr, "ioctl I4B_DISCONNECT_REQ failed: %s", strerror(errno));
- return(-1);
- }
- fprintf(stderr, "isdntest: sending disconnect request\n");
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * get cdid from kernel
- *---------------------------------------------------------------------------*/
-unsigned int
-get_cdid(int isdnfd)
-{
- msg_cdid_req_t mcr;
- int ret;
-
- mcr.cdid = 0;
-
- if((ret = ioctl(isdnfd, I4B_CDID_REQ, &mcr)) < 0)
- {
- fprintf(stderr, "ioctl I4B_CDID_REQ failed: %s", strerror(errno));
- return(0);
- }
- fprintf(stderr, "isdntest: got cdid %d from kernel\n", mcr.cdid);
- return(mcr.cdid);
-}
-
-/*---------------------------------------------------------------------------*
- * make shure all cdid's are inactive before leaving
- *---------------------------------------------------------------------------*/
-void cleanup(void)
-{
- int len;
- char buf[1024];
-
- if(out_cdid != CDID_UNUSED)
- {
- fprintf(stderr, "isdntest: cleanup, send disconnect req for out_cdid %d, in_cdid %d\n", out_cdid, in_cdid);
- disconnect_request(isdnfd, out_cdid);
- }
-
- while((out_cdid != CDID_UNUSED) || (in_cdid != CDID_UNUSED))
- {
- fprintf(stderr, "isdntest: cleanup, out_cdid %d, in_cdid %d\n", out_cdid, in_cdid);
-
- if((len = read(isdnfd, buf, 1024 - 1)) > 0)
- {
- switch (buf[0])
- {
- case MSG_CONNECT_IND:
- handle_connect_ind(&buf[0]);
- break;
-
- case MSG_CONNECT_ACTIVE_IND:
- handle_connect_active_ind(&buf[0]);
- break;
-
- case MSG_DISCONNECT_IND:
- handle_disconnect(&buf[0]);
- break;
-
- default:
- fprintf(stderr, "isdntest: unknown message 0x%x = %c\n", buf[0], buf[0]);
- break;
- }
- }
- else
- {
- fprintf(stderr, "isdntest: read error, errno = %d, length = %d", errno, len);
- }
- }
- fprintf(stderr, "isdntest: exit cleanup, out_cdid %d, in_cdid %d\n", out_cdid, in_cdid);
-}
-
-/*---------------------------------------------------------------------------*
- * test the b-channels
- *---------------------------------------------------------------------------*/
-int do_test(void)
-{
-
-#define FPH 0x3c
-#define FPL 0x66
-
- int fd0, fd1;
- unsigned char wrbuf[2048];
- unsigned char rdbuf[2048];
- int sz;
- fd_set set;
- struct timeval timeout;
- int ret;
- int frame;
- int errcnt;
- int frm_len;
- int bytecnt = 0;
- time_t start_time;
- time_t cur_time;
- time_t run_time;
-
- if((fd0 = open(DATADEV0, O_RDWR)) == -1)
- {
- fprintf(stderr, "open of %s failed: %s", DATADEV0, strerror(errno));
- return(-1);
- }
-
- if((fd1 = open(DATADEV1, O_RDWR)) == -1)
- {
- fprintf(stderr, "open of %s failed: %s", DATADEV1, strerror(errno));
- return(-1);
- }
-
- printf("\n");
- frame = 0;
- errcnt = 0;
-
- frm_len = 2;
-
- start_time = time(NULL);
-
- printf(" frame size errors totalbytes bps elapsedtime\n");
-
- for(;dotest > 0; dotest--)
- {
- setup_wrfix(frm_len, &wrbuf[0]);
-
- frame++;
-
- bytecnt += frm_len;
-
- printf("%6d %4d", frame, frm_len);
- fflush(stdout);
-
- if((sz = write(fd0, wrbuf, frm_len)) != frm_len)
- {
- fprintf(stderr, "write (%d of %d bytes) to %s failed: %s\n", sz, frm_len, DATADEV0, strerror(errno));
- }
-
- timeout.tv_sec = 2;
- timeout.tv_usec = 0;
-
- FD_ZERO(&set);
-
- FD_SET(0, &set);
- FD_SET(fd1, &set);
-
- ret = select(fd1+1, &set, NULL, NULL, &timeout);
-
- if(ret > 0)
- {
- if(FD_ISSET(fd1, &set))
- {
- if((sz = read(fd1, rdbuf, 2048)) != frm_len)
- {
- fprintf(stderr, "read (%d bytes) from %s failed: %s\n", sz, DATADEV1, strerror(errno));
- }
-
- cur_time = time(NULL);
- run_time = difftime(cur_time, start_time);
-
- if(run_time == 0)
- run_time = 1;
-
- printf(" %6d %10d %4d %2.2d:%2.2d:%2.2d \r",
- errcnt, bytecnt,
- (int)((int)bytecnt/(int)run_time),
- (int)run_time/3600, (int)run_time/60, (int)run_time%60);
- fflush(stdout);
-
- errcnt += check_rd(frm_len, &wrbuf[0], &rdbuf[0]);
-
-#ifdef NOTDEF
- for(i=0; i<sz; i++)
- {
- printf("0x%02x ", (unsigned char)rdbuf[i]);
- }
- printf("\n");
-#endif
- }
-
- if(FD_ISSET(0, &set))
- {
- return(0);
- printf("\n\n");
- }
- }
- else
- {
- fprintf(stderr, "isdntest, do_test: select error: %s\n", strerror(errno));
- }
-
- frm_len = frm_len*2;
- if(frm_len > 2048)
- frm_len = 2;
-
- }
- printf("\n\n");
- return(0);
-}
-
-void
-setup_wrfix(int len, unsigned char *buf)
-{
- register int i;
-
- for(i=0; i<len;)
- {
- *buf = FPH;
- buf++;
- *buf = FPL;
- buf++;
- i+=2;
- }
-}
-
-int
-check_rd(int len, unsigned char *wbuf, unsigned char *rbuf)
-{
- register int i;
- int ret = 0;
-
- for(i=0; i<len; i++)
- {
- if(*wbuf != *rbuf)
- {
- fprintf(stderr, "\nERROR, byte %d, written 0x%02x, read 0x%02x\n", i, *wbuf, *rbuf);
- ret++;
- }
- wbuf++;
- rbuf++;
- }
- return(ret);
-}
-
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/1tr6.c b/usr.sbin/i4b/isdntrace/1tr6.c
deleted file mode 100644
index 1c8c1846cd39..000000000000
--- a/usr.sbin/i4b/isdntrace/1tr6.c
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * 1tr6.c - print 1TR6 protocol traces
- * -----------------------------------
- *
- * $Id: 1tr6.c,v 1.4 1998/12/05 18:04:08 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:18:38 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "trace.h"
-
-static int p_1tr6address(char *pbuf, unsigned char buf[]);
-static int p_1tr6cause(char *pbuf, unsigned char buf[]);
-
-/*---------------------------------------------------------------------------*
- * decode the (german) national specific 1TR6 protocol
- *---------------------------------------------------------------------------*/
-void
-decode_1tr6(char *pbuf, int n, int off, unsigned char *buf, int raw)
-{
- int codeset = 0;
- int oldcodeset = 0;
- int codelock = 0;
-
- int pd;
- int len;
- int j;
- int i;
-
- if(n <= 0)
- return;
-
- *pbuf = '\0';
-
- if(raw)
- {
- for (i = 0; i < n; i += 16)
- {
- sprintf((pbuf+strlen(pbuf)),"Dump:%.3d ", i+off);
- for (j = 0; j < 16; j++)
- if (i + j < n)
- sprintf((pbuf+strlen(pbuf)),"%02x ", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf))," ");
- sprintf((pbuf+strlen(pbuf))," ");
- for (j = 0; j < 16 && i + j < n; j++)
- if (isprint(buf[i + j]))
- sprintf((pbuf+strlen(pbuf)),"%c", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf)),".");
- sprintf((pbuf+strlen(pbuf)),"\n");
- }
- }
-
- sprintf((pbuf+strlen(pbuf)), "1TR6: ");
-
- /* protocol discriminator */
-
- i = 0;
-
- pd = buf[i];
-
- switch(pd)
- {
- case 0x40:
- sprintf((pbuf+strlen(pbuf)), "pd=N0, ");
- break;
- case 0x41:
- sprintf((pbuf+strlen(pbuf)), "pd=N1, ");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "pd=UNDEF (0x%02x), ",pd);
- break;
- }
-
- /* call reference */
-
- i++;
-
- len = buf[i] & 0x0f;
-
- switch(len)
- {
- case 1:
- sprintf((pbuf+strlen(pbuf)), "cr=0x%02x %s, ", (buf[i+1] & 0x7f), (buf[i+1] & 0x80) ? "(from destination)" : "(from origination)");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "cr: LEN=%d %s 0x%02x 0x%02x, ", len, (buf[i+1] & 0x80) ? "org" : "dst", (buf[i+1] & 0x7f), (buf[i+2] & 0x7f));
- break;
- }
-
- i += (len+1);
-
- /* message type */
-
- sprintf((pbuf+strlen(pbuf)), "message=");
-
- if(pd == 0x40) /* protocol discriminator N0 */
- {
- switch(buf[i])
- {
- case 0x61:
- sprintf((pbuf+strlen(pbuf)), "REGISTER INDICATION: ");
- break;
- case 0x62:
- sprintf((pbuf+strlen(pbuf)), "CANCEL INDICATION: ");
- break;
- case 0x63:
- sprintf((pbuf+strlen(pbuf)), "FACILITY STATUS: ");
- break;
- case 0x64:
- sprintf((pbuf+strlen(pbuf)), "STATUS ACKNOWLEDGE: ");
- break;
- case 0x65:
- sprintf((pbuf+strlen(pbuf)), "STATUS REJECT: ");
- break;
- case 0x66:
- sprintf((pbuf+strlen(pbuf)), "FACILITY INFORMATION: ");
- break;
- case 0x67:
- sprintf((pbuf+strlen(pbuf)), "INFORMATION ACKNOWLEDGE: ");
- break;
- case 0x68:
- sprintf((pbuf+strlen(pbuf)), "INFORMATION REJECT: ");
- break;
- case 0x75:
- sprintf((pbuf+strlen(pbuf)), "CLOSE: ");
- break;
- case 0x77:
- sprintf((pbuf+strlen(pbuf)), "CLOSE ACKNOWLEDGE: ");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "ERROR: PD=0x40 MSG=0x%02x, ", buf[i]);
- break;
- }
- }
- else if(pd == 0x41)
- {
- switch(buf[i])
- {
- case 0x00:
- sprintf((pbuf+strlen(pbuf)), "ESCAPE: ");
- break;
- case 0x01:
- sprintf((pbuf+strlen(pbuf)), "ALERT: ");
- break;
- case 0x02:
- sprintf((pbuf+strlen(pbuf)), "CALL SENT: ");
- break;
- case 0x07:
- sprintf((pbuf+strlen(pbuf)), "CONNECT: ");
- break;
- case 0x0f:
- sprintf((pbuf+strlen(pbuf)), "CONNECT ACKNOWLEDGE: ");
- break;
- case 0x05:
- sprintf((pbuf+strlen(pbuf)), "SETUP: ");
- break;
- case 0x0d:
- sprintf((pbuf+strlen(pbuf)), "SETUP ACKNOWLEDGE: ");
- break;
-
- case 0x26:
- sprintf((pbuf+strlen(pbuf)), "RESUME: ");
- break;
- case 0x2e:
- sprintf((pbuf+strlen(pbuf)), "RESUME ACKNOWLEDGE: ");
- break;
- case 0x22:
- sprintf((pbuf+strlen(pbuf)), "RESUME REJECT: ");
- break;
- case 0x25:
- sprintf((pbuf+strlen(pbuf)), "SUSPEND: ");
- break;
- case 0x2d:
- sprintf((pbuf+strlen(pbuf)), "SUSPEND ACKNOWLEDGE: ");
- break;
- case 0x21:
- sprintf((pbuf+strlen(pbuf)), "SUSPEND REJECT: ");
- break;
- case 0x20:
- sprintf((pbuf+strlen(pbuf)), "USER INFORMATION: ");
- break;
-
- case 0x40:
- sprintf((pbuf+strlen(pbuf)), "DETACH");
- break;
- case 0x45:
- sprintf((pbuf+strlen(pbuf)), "DISCONNECT: ");
- break;
- case 0x4d:
- sprintf((pbuf+strlen(pbuf)), "RELEASE: ");
- break;
- case 0x5a:
- sprintf((pbuf+strlen(pbuf)), "RELEASE ACKNOWLEDGE");
- break;
-
- case 0x6e:
- sprintf((pbuf+strlen(pbuf)), "CANCEL ACKNOWLEDGE: ");
- break;
- case 0x67:
- sprintf((pbuf+strlen(pbuf)), "CANCEL REJECT: ");
- break;
- case 0x69:
- sprintf((pbuf+strlen(pbuf)), "CONGESTION CONTROL: ");
- break;
- case 0x60:
- sprintf((pbuf+strlen(pbuf)), "FACILITY: ");
- break;
- case 0x68:
- sprintf((pbuf+strlen(pbuf)), "FACILITY ACKNOWLEDGE: ");
- break;
- case 0x66:
- sprintf((pbuf+strlen(pbuf)), "FACILITY CANCEL: ");
- break;
- case 0x64:
- sprintf((pbuf+strlen(pbuf)), "FACILITY REGISTER: ");
- break;
- case 0x65:
- sprintf((pbuf+strlen(pbuf)), "FACILITY REJECT: ");
- break;
- case 0x6d:
- sprintf((pbuf+strlen(pbuf)), "INFORMATION: ");
- break;
- case 0x6c:
- sprintf((pbuf+strlen(pbuf)), "REGISTER ACKNOWLEDGE: ");
- break;
- case 0x6f:
- sprintf((pbuf+strlen(pbuf)), "REGISTER REJECT: ");
- break;
- case 0x63:
- sprintf((pbuf+strlen(pbuf)), "STATUS: ");
- break;
-
- default:
- sprintf((pbuf+strlen(pbuf)), "ERROR: PD=0x41 MSG=0x%02x, ", buf[i]);
- break;
- }
- }
- else
- {
- sprintf((pbuf+strlen(pbuf)), "ERROR: PD=0x%02x MSG=0x%02x, ", pd, buf[i]);
- }
-
- /* other information elements */
-
- i++;
-
- for (; i < n;)
- {
- sprintf((pbuf+strlen(pbuf)), "\n ");
-
- if(buf[i] & 0x80)
- {
- /* single octett info element */
-
- switch(buf[i] & 0x70)
- {
- case 0x00: /* reserved */
- sprintf((pbuf+strlen(pbuf)), "[reserved single octett info]");
- break;
-
- case 0x10: /* shift */
- oldcodeset = codeset;
- codeset = buf[i] & 0x07;
- if(buf[i] & 0x08)
- codelock = 0;
- else
- codelock = 1;
- sprintf((pbuf+strlen(pbuf)), "[shift: codeset=%d lock=%d]", codeset, codelock);
- break;
-
- case 0x20: /* more data */
- sprintf((pbuf+strlen(pbuf)), "[more data]");
- break;
-
- case 0x30: /* congestion level */
- sprintf((pbuf+strlen(pbuf)), "[congestion level = %d]", buf[i] & 0x0f);
- break;
-
- default:
- sprintf((pbuf+strlen(pbuf)), "[UNDEF SINGLE OCTET ELEMENT 0x%02x]", buf[i]);
- break;
- }
-
- i++; /* next */
-
- }
- else
- {
- /* variable length info element */
-
- if(codeset == 0)
- {
- switch(buf[i])
- {
- case 0x08:
- sprintf((pbuf+strlen(pbuf)), "[cause: ");
- i += p_1tr6cause(pbuf, &buf[i]);
- goto next;
- break;
-
- case 0x0c:
- sprintf((pbuf+strlen(pbuf)), "[connected address: ");
- i += p_1tr6address(pbuf, &buf[i]);
- goto next;
- break;
-
- case 0x10:
- sprintf((pbuf+strlen(pbuf)), "[call identity: ");
- break;
- case 0x18:
- sprintf((pbuf+strlen(pbuf)), "[channel id: channel=");
- i += 2;
- switch(buf[i] & 0x03)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "no channel");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "B-1");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "B-2");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "any channel");
- break;
- }
- if(buf[i] & 0x08)
- sprintf((pbuf+strlen(pbuf)), " (exclusive)]");
- else
- sprintf((pbuf+strlen(pbuf)), " (preferred)]");
- i++;
- goto next;
- break;
- case 0x20:
- sprintf((pbuf+strlen(pbuf)), "[network specific facilities: ");
- i++;
- len = buf[i];
- i+=2;
- switch(buf[i])
- {
- case 1:
- sprintf((pbuf+strlen(pbuf)), "Sperre");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "AWS 1");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "AWS 2");
- break;
- case 0xe:
- sprintf((pbuf+strlen(pbuf)), "Konferenz");
- break;
- case 0xf:
- sprintf((pbuf+strlen(pbuf)), "B-Kan uebern.");
- break;
- case 0x10:
- sprintf((pbuf+strlen(pbuf)), "aktvrg. ghlt. Vbdg.");
- break;
- case 0x11:
- sprintf((pbuf+strlen(pbuf)), "3er Konf");
- break;
- case 0x12:
- sprintf((pbuf+strlen(pbuf)), "1seitg D/G Wechsel");
- break;
- case 0x13:
- sprintf((pbuf+strlen(pbuf)), "2seitig D/G Wechsel");
- break;
- case 0x14:
- sprintf((pbuf+strlen(pbuf)), "Rufnr. identifiz.");
- break;
- case 0x15:
- sprintf((pbuf+strlen(pbuf)), "GBG");
- break;
- case 0x17:
- sprintf((pbuf+strlen(pbuf)), "ueberg. Ruf");
- break;
- case 0x1a:
- sprintf((pbuf+strlen(pbuf)), "um/weitergel. Ruf");
- break;
- case 0x1b:
- sprintf((pbuf+strlen(pbuf)), "unterdr. A-Rufnr.");
- break;
- case 0x1e:
- sprintf((pbuf+strlen(pbuf)), "Verbdg. deaktivieren");
- break;
- case 0x1d:
- sprintf((pbuf+strlen(pbuf)), "Verbdg. aktivieren");
- break;
- case 0x1f:
- sprintf((pbuf+strlen(pbuf)), "SPV");
- break;
- case 0x23:
- sprintf((pbuf+strlen(pbuf)), "Rueckw. 2seitg. DW");
- break;
- case 0x24:
- sprintf((pbuf+strlen(pbuf)), "Anrufumltg. priv. Netz");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "undefined");
- break;
- }
- i++;
- sprintf((pbuf+strlen(pbuf)), ", serv=%d", buf[i]);
- i++;
- sprintf((pbuf+strlen(pbuf)), ", ainfo=%d", buf[i]);
- i++;
- len-=4;
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf))," 0x%02x", buf[j+i]);
- }
- sprintf((pbuf+strlen(pbuf)),"]");
- i += j;
- goto next;
- break;
- case 0x28:
- sprintf((pbuf+strlen(pbuf)), "[display: ");
- break;
- case 0x2c:
- sprintf((pbuf+strlen(pbuf)), "[keypad: ");
- break;
- case 0x6c:
- sprintf((pbuf+strlen(pbuf)), "[origination address: ");
- i += p_1tr6address(pbuf, &buf[i]);
- goto next;
- break;
- case 0x70:
- sprintf((pbuf+strlen(pbuf)), "[destination address: ");
- i += p_1tr6address(pbuf, &buf[i]);
- goto next;
- break;
- case 0x7e:
- sprintf((pbuf+strlen(pbuf)), "[user-user information: ");
- break;
- case 0x7f:
- sprintf((pbuf+strlen(pbuf)), "[reserved: ");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "[UNKNOWN INFO-ELEMENT-ID");
- break;
- }
- }
- else if(codeset == 6)
- {
- switch(buf[i])
- {
- case 0x01:
- sprintf((pbuf+strlen(pbuf)), "[service ind: serv=");
- i+= 2;
- switch(buf[i])
- {
- case 0x01:
- sprintf((pbuf+strlen(pbuf)), "phone");
- break;
- case 0x02:
- sprintf((pbuf+strlen(pbuf)), "a/b");
- break;
- case 0x03:
- sprintf((pbuf+strlen(pbuf)), "X.21");
- break;
- case 0x04:
- sprintf((pbuf+strlen(pbuf)), "fax g4");
- break;
- case 0x05:
- sprintf((pbuf+strlen(pbuf)), "btx");
- break;
- case 0x07:
- sprintf((pbuf+strlen(pbuf)), "64k data");
- break;
- case 0x08:
- sprintf((pbuf+strlen(pbuf)), "X.25");
- break;
- case 0x09:
- sprintf((pbuf+strlen(pbuf)), "teletex");
- break;
- case 0x0a:
- sprintf((pbuf+strlen(pbuf)), "mixed");
- break;
- case 0x0d:
- sprintf((pbuf+strlen(pbuf)), "temex");
- break;
- case 0x0e:
- sprintf((pbuf+strlen(pbuf)), "picturephone");
- break;
- case 0x0f:
- sprintf((pbuf+strlen(pbuf)), "btx (new)");
- break;
- case 0x10:
- sprintf((pbuf+strlen(pbuf)), "videophone");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "undefined");
- break;
- }
- i++;
- sprintf((pbuf+strlen(pbuf)), ", ainfo=0x%02x]", buf[i]);
- i++;
- goto next;
- break;
- case 0x02:
- sprintf((pbuf+strlen(pbuf)), "[charging information: ");
- break;
- case 0x03:
- sprintf((pbuf+strlen(pbuf)), "[date: ");
- i++;
- len = buf[i];
- i++;
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf)),"%c", buf[j+i]);
- }
- sprintf((pbuf+strlen(pbuf)),"]");
- i += j;
- goto next;
- break;
- case 0x05:
- sprintf((pbuf+strlen(pbuf)), "[facility select: ");
- break;
- case 0x06:
- sprintf((pbuf+strlen(pbuf)), "[status of facilities: ");
- break;
- case 0x07:
- sprintf((pbuf+strlen(pbuf)), "[status of called party: ");
- i+=2;
- switch(buf[i])
- {
- case 1:
- sprintf((pbuf+strlen(pbuf)), "no information]");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "is being called]");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "undefined (0x%02x)]", buf[i]);
- break;
- }
- i++;
- goto next;
- break;
- case 0x08:
- sprintf((pbuf+strlen(pbuf)), "[additional tx attributes: ");
- i++;
- len = buf[i];
- i++;
- for(j = 0; j < len; j++)
- {
- switch(buf[j+i] &0x70)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "no satellite link");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "one satellite link");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "two satellite links");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "three satellite links");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "undefined value");
- break;
- }
- if(buf[j+i] & 0x80)
- sprintf((pbuf+strlen(pbuf)),"(flag=req)]");
- else
- sprintf((pbuf+strlen(pbuf)),"(flag=ind)]");
- }
- i += j;
- goto next;
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "[UNKNOWN INFO-ELEMENT-ID");
- break;
- }
- }
- else
- {
- sprintf((pbuf+strlen(pbuf)), "[ILLEGAL CODESET = 0x%02x", codeset);
- }
-
- i++; /* index -> length */
-
- len = buf[i];
-
- i++; /* index -> 1st param */
-
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf))," 0x%02x", buf[j+i]);
- }
-
- sprintf((pbuf+strlen(pbuf)),"]");
-
- i += len;
-
-next:
-
- if(!codelock && (codeset != oldcodeset))
- codeset = oldcodeset;
- }
- }
- sprintf((pbuf+strlen(pbuf)),"\n");
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print the cause
- *---------------------------------------------------------------------------*/
-static int
-p_1tr6cause(char *pbuf, unsigned char buf[])
-{
- int j;
- int len;
- int i = 0;
-
- i++; /* index -> length */
-
- len = buf[i];
-
- switch(len)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "%s", print_cause_1tr6(0));
- break;
- case 1:
- i++;
- sprintf((pbuf+strlen(pbuf)), "%s", print_cause_1tr6(buf[i] & 0x7f));
- break;
- case 2:
- i++;
- sprintf((pbuf+strlen(pbuf)), "%s, location: ", print_cause_1tr6(buf[i] & 0x7f));
- i++;
- switch(buf[i] & 0x0f)
- {
- case 0x04:
- sprintf((pbuf+strlen(pbuf)), "public network");
- break;
- case 0x05:
- sprintf((pbuf+strlen(pbuf)), "private network");
- break;
- case 0x0f:
- sprintf((pbuf+strlen(pbuf)), "no information");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
- break;
- default:
- i++; /* index -> length */
- len = buf[i];
- i++; /* index -> 1st param */
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf))," 0x%02x", buf[j+i]);
- }
- break;
- }
- i++;
- sprintf((pbuf+strlen(pbuf)),"]");
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print the ISDN (telephone) number
- *---------------------------------------------------------------------------*/
-static int
-p_1tr6address(char *pbuf, unsigned char buf[])
-{
- int j;
- int len;
- int i = 0;
- int tp;
-
- i++; /* index -> length */
- len = buf[i];
- i++; /* index -> 1st param */
- tp = buf[i];
-
- i++;
- len--;
-
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf)),"%c", buf[j+i]);
- }
-
- switch((tp & 0x70) >> 4)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), " (type=unknown, ");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), " (type=international, ");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), " (type=national, ");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), " (type=%d, ", ((tp & 0x70) >> 4));
- break;
- }
-
- switch(tp & 0x0f)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "plan=unknown)");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "plan=ISDN)");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "plan=%d)", (tp & 0x0f));
- break;
- }
-
- sprintf((pbuf+strlen(pbuf)),"]");
-
- i += j;
-
- return(i);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/Makefile b/usr.sbin/i4b/isdntrace/Makefile
deleted file mode 100644
index 150c18d88022..000000000000
--- a/usr.sbin/i4b/isdntrace/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG = isdntrace
-SRCS = q921.c q931.c q931_util.c q932_fac.c 1tr6.c trace.c \
- pcause_1tr6.c pcause_q850.c
-#CFLAGS += -Wall -g
-MAN8 = isdntrace.8
-
-.include <bsd.prog.mk>
-
diff --git a/usr.sbin/i4b/isdntrace/cable.txt b/usr.sbin/i4b/isdntrace/cable.txt
deleted file mode 100644
index 890d8d4d7104..000000000000
--- a/usr.sbin/i4b/isdntrace/cable.txt
+++ /dev/null
@@ -1,60 +0,0 @@
- *---------------------------------------------------------------------------
- *
- * Custom cable to trace an ISDN S0 bus with two passive (!) ISDN boards
- * ---------------------------------------------------------------------
- *
- * $Id: cable.txt,v 1.2 1998/01/22 20:39:49 hm Exp $
- *
- * last edit-date: [Thu Jan 22 19:57:50 1998]
- *
- * -hm documentation of analyze mode
- *
- *---------------------------------------------------------------------------*/
-
-The cable consists of a RJ-45 plug with both tx and rx connected and
-two jacks; the tx cables from the plug are wired to one jack and the
-rx cables from the plug are wired to the other jack.
-
-The computer must be equipped with two (!) supported passive cards and
-the cable from one card is plugged into one of the jacks while the cable
-to from the other card is plugged into the other jack.
-
-Now one card monitors the tx part of the S0 bus and the other card
-monitors the rx part.
-
-Which card functions as the rx side and which as the tx side can be
-specified as options to the isdntrace utility (-R and -T) which has
-to be run in analyzer mode (-a) to support this configuration.
-
-
- 1
- 2
- 3
- +--------------4 receiving-side board
- S0-bus +--|--------------5 in computer (jack for
- to analyze | | 6 cable to passive controller)
- 8 | | 7
- 7 | | 8
- transmit - 6------------|--|--+
- receive - 5------------+ | |
- receive + 4---------------+ |
- transmit + 3------------+ |
- 2 | | 1
- 1 | | 2
- plug into | | 3
- S0 bus +-----|-----------4 transmitting-side board
- +-----------5 in computer (jack for
- 6 cable to passive controller)
- 7
- 8
-
-
-
- RJ-45 plug RJ-45 jack
- view from the front view from the front
- cable goes out to the rear
-
- /--------- / ----------
- | 87654321 | | 12345678 |
- |__ __|/ |/_ /_|
- |____|/ |/___|
diff --git a/usr.sbin/i4b/isdntrace/isdntrace.8 b/usr.sbin/i4b/isdntrace/isdntrace.8
deleted file mode 100644
index 62c5d07eef59..000000000000
--- a/usr.sbin/i4b/isdntrace/isdntrace.8
+++ /dev/null
@@ -1,205 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isdntrace.8,v 1.9 1998/12/05 18:04:10 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:18:59 1998]
-.\"
-.Dd October 19, 1998
-.Dt isdntrace 8
-.Sh NAME
-.Nm isdntrace
-.Nd isdn4bsd ISDN protocol trace utility
-.Sh SYNOPSIS
-.Nm isdntrace
-.Op Fl a
-.Op Fl b
-.Op Fl d
-.Op Fl f Ar filename
-.Op Fl h
-.Op Fl i
-.Op Fl l
-.Op Fl n Ar number
-.Op Fl o
-.Op Fl p Ar filename
-.Op Fl r
-.Op Fl u Ar number
-.Op Fl B
-.Op Fl F
-.Op Fl P
-.Op Fl R Ar unit
-.Op Fl T Ar unit
-.Sh DESCRIPTION
-.Nm isdntrace
-is part of the isdn4bsd package and is used to provide the user with a
-mnemonic display of the layers 1, 2 and 3 protocol activities on
-the D channel and hex dump of the B channel(s) activities.
-.Pp
-Together with two passive supported cards and an easy to build cable it can
-also be used to monitor the complete traffic on a S0 bus providing S0 bus
-analyzer features.
-.Pp
-The
-.Nm
-utility is only available for passive supported cards.
-.Pp
-The following options can be used:
-.Bl -tag -width Ds
-.It Fl a
-Run
-.Nm
-in analyzer mode by using two passive cards and a custom cable which can
-be build as described in the file
-.Em cable.txt
-in the isdn4bsd source distribution. One card acts as a receiver for the
-transmitting direction on the S0 bus while the other card acts as a receiver
-for the receiving direction on the S0 bus. Complete traffic monitoring is
-possible using this setup.
-.It Fl b
-switch B channel tracing on (default off).
-.It Fl d
-switch D channel tracing off (default on).
-.It Fl f
-Use
-.Ar filename
-as the name of a file into which to write tracing output (default filename is
-isdntrace<n> where n is the number of the unit to trace).
-.It Fl h
-switch display of header off (default on).
-.It Fl i
-print layer 1 (I.430) INFO signals to monitor layer 1 activity (default off).
-.It Fl l
-switch displaying of Layer 2 (Q.921) frames off (default on).
-.It Fl n
-This option takes a numeric argument specifying the minimum
-frame size in octetts a frame must have to be displayed. (default 0)
-.It Fl o
-switch off writing trace output to a file (default on).
-.It Fl p
-Use
-.Ar filename
-as the name of a file used for the -B and -P options (default filename
-is isdntracebin<n> where n is the number of the unit to trace).
-.It Fl r
-Switch off printing a raw hexadecimal dump of the packets preceding
-the decoded protocol information (default on).
-.It Fl u
-Use
-.Ar number
-as the unit number of the controller card to trace (default 0).
-.It Fl B
-Write undecoded binary trace data to a file for later or remote
-analyzing (default off).
-.It Fl F
-This option can only be used when option -P (playback from binary data file)
-is used. The -F option causes playback not to stop at end of file but rather
-to wait for additional data to be available from the input file.
-.Pp
-This option is useful when trace data is accumulated in binary format (to
-save disk space) but a monitoring functionality is desired.
-(default off).
-.It Fl P
-Read undecoded binary trace data from file instead from device (default off).
-.It Fl R
-Use
-.Ar unit
-as the receiving interface unit number in analyze mode.
-.It Fl T
-Use
-.Ar unit
-as the transmitting interface unit number in analyze mode.
-.El
-.Pp
-When the USR1 signal is sent to a
-.Nm
-process, the currently used logfiles are reopened, so that logfile
-rotation becomes possible.
-.Pp
-The trace output should be obvious. It is very handy to have the following
-standard texts available when tracing ISDN protocols:
-.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It Ar I.430
-ISDN BRI layer 1 protocol description.
-.It Ar Q.921
-ISDN D-channel layer 2 protocol description.
-.It Ar Q.931
-ISDN D-channel layer 3 protocol description.
-.It Ar 1TR6
-German-specific ISDN layer 3 protocol description. (NOTICE: decoding
-of the 1TR6 protocol is included but not supported since i dont have
-any longer access to a 1TR6 based ISDN installation.)
-.El
-.Pp
-
-.Nm Isdntrace
-automatically detects the layer 3 protocol being used by looking at the
-Protocol Discriminator (see: Q.931/1993 pp. 53).
-.Pp
-
-
-.Sh FILES
-.Bl -tag -width daddeldi -compact
-.It Pa /dev/i4btrc<n>
-The devicefile(s) used to get the trace messages for ISDN card unit <n>
-out of the kernel.
-.El
-
-.Sh EXAMPLES
-The command:
-.Bd -literal -offset indent
-isdntrace -f /var/tmp/isdn.trace
-.Ed
-.Pp
-will start D channel tracing on passive controller 0 with all except B
-channel tracing enabled and logs everything into the output file
-/tmp/isdn.trace.
-
-.Sh SEE ALSO
-.Xr isdnd 8
-
-.Sh BUGS
-Still some or more left.
-
-.Sh STANDARDS
-ITU Recommendations I.430, Q.920, Q.921, Q.930, Q.931
-.Pp
-FTZ Richtlinie 1TR3, Band III
-.Pp
-ITU Recommendation Q.932 (03/93), Q.950 (03/93)
-.Pp
-ETSI Recommendation ETS 300 179 (10/92), ETS 300 180 (10/92)
-.Pp
-ETSI Recommendation ETS 300 181 (04/93), ETS 300 182 (04/93)
-.Pp
-ITU Recommendation X.208, X.209
-
-.Sh AUTHOR
-The
-.Nm
-utility was written by Gary Jennejohn and Hellmuth Michaelis.
-.Pp
-This manual page was written by Hellmuth Michaelis, he can be reached
-at hm@kts.org.
-
diff --git a/usr.sbin/i4b/isdntrace/pcause_1tr6.c b/usr.sbin/i4b/isdntrace/pcause_1tr6.c
deleted file mode 100644
index 42f244d3f24b..000000000000
--- a/usr.sbin/i4b/isdntrace/pcause_1tr6.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * printing cause values
- * ---------------------
- *
- * $Id: pcause_1tr6.c,v 1.4 1998/12/23 10:03:55 hm Exp $
- *
- * last edit-date: [Wed Dec 23 10:57:11 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "trace.h"
-#include "pcause_1tr6.h"
-
-char *
-print_cause_1tr6(unsigned char code)
-{
- static char error_message[120];
- char *e;
-
- switch(code)
- {
- case CAUSE_1TR6_SHUTDN:
- e = "normal D-channel shutdown";
- break;
-
- case CAUSE_1TR6_ICRV:
- e = "invalid call reference value";
- break;
-
- case CAUSE_1TR6_BSNI:
- e = "bearer service not implemented";
- break;
-
- case CAUSE_1TR6_CIDNE:
- e = "call identity does not exist";
- break;
-
- case CAUSE_1TR6_CIIU:
- e = "call identity in use";
- break;
-
- case CAUSE_1TR6_NCA:
- e = "no channel available";
- break;
-
- case CAUSE_1TR6_RFNI:
- e = "requested facility not implemented";
- break;
-
- case CAUSE_1TR6_RFNS:
- e = "requested facility not subscribed";
- break;
-
- case CAUSE_1TR6_OCB:
- e = "outgoing calls barred";
- break;
-
- case CAUSE_1TR6_UAB:
- e = "user access busy";
- break;
-
- case CAUSE_1TR6_NECUG:
- e = "non existent CUG";
- break;
-
- case CAUSE_1TR6_NECUG1:
- e = "non existent CUG";
- break;
-
- case CAUSE_1TR6_SPV:
- e = "kommunikationsbeziehung als SPV nicht erlaubt";
- break;
-
- case CAUSE_1TR6_DNO:
- e = "destination not obtainable";
- break;
-
- case CAUSE_1TR6_NC:
- e = "number changed";
- break;
-
- case CAUSE_1TR6_OOO:
- e = "out of order";
- break;
-
- case CAUSE_1TR6_NUR:
- e = "no user responding";
- break;
-
- case CAUSE_1TR6_UB:
- e = "user busy";
- break;
-
- case CAUSE_1TR6_ICB:
- e = "incoming calls barred";
- break;
-
- case CAUSE_1TR6_CR:
- e = "call rejected";
- break;
-
- case CAUSE_1TR6_NCO:
- e = "network congestion";
- break;
-
- case CAUSE_1TR6_RUI:
- e = "remote user initiated";
- break;
-
- case CAUSE_1TR6_LPE:
- e = "local procedure error";
- break;
-
- case CAUSE_1TR6_RPE:
- e = "remote procedure error";
- break;
-
- case CAUSE_1TR6_RUS:
- e = "remote user suspended";
- break;
-
- case CAUSE_1TR6_RUR:
- e = "remote user resumed";
- break;
-
- case CAUSE_1TR6_UIDL:
- e = "user info discharded locally";
- break;
-
- default:
- e = "UNKNOWN error occured";
- break;
- }
-
- sprintf(error_message, "0x%02x: %s", code & 0x7f, e);
- return(error_message);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/pcause_1tr6.h b/usr.sbin/i4b/isdntrace/pcause_1tr6.h
deleted file mode 100644
index f327cc721c87..000000000000
--- a/usr.sbin/i4b/isdntrace/pcause_1tr6.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * pcause1tr6.h - 1TR6 causes definitions
- * --------------------------------------
- *
- * $Id: pcause_1tr6.h,v 1.3 1998/12/05 18:04:13 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:19:39 1998]
- *
- *---------------------------------------------------------------------------*/
-
-char *print_cause_1tr6(unsigned char code);
-
-/* 1TR6 protocol causes */
-
-#define CAUSE_1TR6_SHUTDN 0x00 /* normal D-channel shutdown */
-#define CAUSE_1TR6_ICRV 0x01 /* invalid call reference value */
-#define CAUSE_1TR6_BSNI 0x03 /* bearer service not implemented */
-#define CAUSE_1TR6_CIDNE 0x07 /* call identity does not exist */
-#define CAUSE_1TR6_CIIU 0x08 /* call identity in use */
-#define CAUSE_1TR6_NCA 0x0A /* no channel available */
-#define CAUSE_1TR6_RFNI 0x10 /* requested facility not implemented */
-#define CAUSE_1TR6_RFNS 0x11 /* requested facility not subscribed */
-#define CAUSE_1TR6_OCB 0x20 /* outgoing calls barred */
-#define CAUSE_1TR6_UAB 0x21 /* user access busy */
-#define CAUSE_1TR6_NECUG 0x22 /* non existent CUG */
-#define CAUSE_1TR6_NECUG1 0x23 /* non existent CUG */
-#define CAUSE_1TR6_SPV 0x25 /* kommunikationsbeziehung als SPV nicht erlaubt */
-#define CAUSE_1TR6_DNO 0x35 /* destination not obtainable */
-#define CAUSE_1TR6_NC 0x38 /* number changed */
-#define CAUSE_1TR6_OOO 0x39 /* out of order */
-#define CAUSE_1TR6_NUR 0x3A /* no user responding */
-#define CAUSE_1TR6_UB 0x3B /* user busy */
-#define CAUSE_1TR6_ICB 0x3D /* incoming calls barred */
-#define CAUSE_1TR6_CR 0x3E /* call rejected */
-#define CAUSE_1TR6_NCO 0x59 /* network congestion */
-#define CAUSE_1TR6_RUI 0x5A /* remote user initiated */
-#define CAUSE_1TR6_LPE 0x70 /* local procedure error */
-#define CAUSE_1TR6_RPE 0x71 /* remote procedure error */
-#define CAUSE_1TR6_RUS 0x72 /* remote user suspended */
-#define CAUSE_1TR6_RUR 0x73 /* remote user resumed */
-#define CAUSE_1TR6_UIDL 0x7F /* user info discharded locally */
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/pcause_q850.c b/usr.sbin/i4b/isdntrace/pcause_q850.c
deleted file mode 100644
index 1c98388a4ef9..000000000000
--- a/usr.sbin/i4b/isdntrace/pcause_q850.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * printing cause values
- * ---------------------
- *
- * $Id: pcause_q850.c,v 1.4 1998/12/23 10:03:55 hm Exp $
- *
- * last edit-date: [Wed Dec 23 10:57:36 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "trace.h"
-#include "pcause_q850.h"
-
-char *
-print_cause_q850(unsigned char code)
-{
- static char error_message[120];
- char *e;
-
- switch(code)
- {
- case CAUSE_Q850_SHUTDN:
- e = "normal D-channel shutdown";
- break;
-
- case CAUSE_Q850_NUNALLC:
- e = "Unallocated (unassigned) number";
- break;
-
- case CAUSE_Q850_NRTTN:
- e = "No route to specified transit network";
- break;
-
- case CAUSE_Q850_NRTDST:
- e = "No route to destination";
- break;
-
- case CAUSE_Q850_SSINFTN:
- e = "Send special information tone";
- break;
-
- case CAUSE_Q850_MDIALTP:
- e = "Misdialled trunk prefix";
- break;
-
- case CAUSE_Q850_CHUNACC:
- e = "Channel unacceptable";
- break;
-
- case CAUSE_Q850_CALLAWD:
- e = "Call awarded and being delivered in an established channel";
- break;
-
- case CAUSE_Q850_PREEMPT:
- e = "Preemption";
- break;
-
- case CAUSE_Q850_PREECRR:
- e = "Preemption - circuit reserved for reuse";
- break;
-
- case CAUSE_Q850_NCCLR:
- e = "Normal call clearing";
- break;
-
- case CAUSE_Q850_USRBSY:
- e = "User busy";
- break;
-
- case CAUSE_Q850_NOUSRRSP:
- e = "No user responding";
- break;
-
- case CAUSE_Q850_NOANSWR:
- e = "No answer from user (user alerted)";
- break;
-
- case CAUSE_Q850_SUBSABS:
- e = "Subscriber absent";
- break;
-
- case CAUSE_Q850_CALLREJ:
- e = "Call rejected";
- break;
-
- case CAUSE_Q850_NUCHNG:
- e = "Number changed";
- break;
-
- case CAUSE_Q850_NONSELUC:
- e = "Non-selected user clearing";
- break;
-
- case CAUSE_Q850_DSTOOORDR:
- e = "Destination out of order";
- break;
-
- case CAUSE_Q850_INVNUFMT:
- e = "Invalid number format";
- break;
-
- case CAUSE_Q850_FACREJ:
- e = "Facility rejected";
- break;
-
- case CAUSE_Q850_STENQRSP:
- e = "Response to STATUS ENQUIRY";
- break;
-
- case CAUSE_Q850_NORMUNSP:
- e = "Normal, unspecified";
- break;
-
- case CAUSE_Q850_NOCAVAIL:
- e = "No circuit / channel available";
- break;
-
- case CAUSE_Q850_NETOOORDR:
- e = "Network out of order";
- break;
-
- case CAUSE_Q850_PFMCDOOSERV:
- e = "Permanent frame mode connection out of service";
- break;
-
- case CAUSE_Q850_PFMCOPER:
- e = "Permanent frame mode connection operational";
- break;
-
- case CAUSE_Q850_TMPFAIL:
- e = "Temporary failure";
- break;
-
- case CAUSE_Q850_SWEQCONG:
- e = "Switching equipment congestion";
- break;
-
- case CAUSE_Q850_ACCINFDIS:
- e = "Access information discarded";
- break;
-
- case CAUSE_Q850_REQCNOTAV:
- e = "Requested circuit/channel not available";
- break;
-
- case CAUSE_Q850_PRECALBLK:
- e = "Precedence call blocked";
- break;
-
- case CAUSE_Q850_RESUNAVAIL:
- e = "Resources unavailable, unspecified";
- break;
-
- case CAUSE_Q850_QOSUNAVAIL:
- e = "Quality of service unavailable";
- break;
-
- case CAUSE_Q850_REQSERVNS:
- e = "Requested facility not subscribed";
- break;
-
- case CAUSE_Q850_OCBARRCUG:
- e = "Outgoing calls barred within CUG";
- break;
-
- case CAUSE_Q850_ICBARRCUG:
- e = "Incoming calls barred within CUG";
- break;
-
- case CAUSE_Q850_BCAPNAUTH:
- e = "Bearer capability not authorized";
- break;
-
- case CAUSE_Q850_BCAPNAVAIL:
- e = "Bearer capability not presently available";
- break;
-
- case CAUSE_Q850_INCSTOACISC:
- e = "Inconsistenciy in designated outg. access info and subscriber class";
- break;
-
- case CAUSE_Q850_SOONOTAVAIL:
- e = "Service or option not available, unspecified";
- break;
-
- case CAUSE_Q850_BCAPNOTIMPL:
- e = "Bearer capability not implemented";
- break;
-
- case CAUSE_Q850_CHTYPNIMPL:
- e = "Channel type not implemented";
- break;
-
- case CAUSE_Q850_REQFACNIMPL:
- e = "Requested facility not implemented";
- break;
-
- case CAUSE_Q850_ORDINBCAVL:
- e = "Only restricted digital information bearer capability is available";
- break;
-
- case CAUSE_Q850_SOONOTIMPL:
- e = "Service or option not implemented, unspecified";
- break;
-
- case CAUSE_Q850_INVCLRFVAL:
- e = "Invalid call reference value";
- break;
-
- case CAUSE_Q850_IDCHDNOEX:
- e = "Identified channel does not exist";
- break;
-
- case CAUSE_Q850_SUSCAEXIN:
- e = "A suspended call exists, but this call identity does not";
- break;
-
- case CAUSE_Q850_CLIDINUSE:
- e = "Call identity in use";
- break;
-
- case CAUSE_Q850_NOCLSUSP:
- e = "No call suspended";
- break;
-
- case CAUSE_Q850_CLIDCLRD:
- e = "Call having the requested call identity has been cleared";
- break;
-
- case CAUSE_Q850_UNOTMEMCUG:
- e = "User not member of CUG";
- break;
-
- case CAUSE_Q850_INCDEST:
- e = "Incompatible destination";
- break;
-
- case CAUSE_Q850_NONEXCUG:
- e = "Non-existent CUG";
- break;
-
- case CAUSE_Q850_INVNTWSEL:
- e = "Invalid transit network selection";
- break;
-
- case CAUSE_Q850_INVMSG:
- e = "Invalid message, unspecified";
- break;
-
- case CAUSE_Q850_MIEMISS:
- e = "Mandatory information element is missing";
- break;
-
- case CAUSE_Q850_MSGTNI:
- e = "Message type non-existent or not implemented";
- break;
-
- case CAUSE_Q850_MSGNCMPT:
- e = "Msg incompatible with call state/message type non-existent/not implemented";
- break;
-
- case CAUSE_Q850_IENENI:
- e = "Information element/parameter non-existent or not implemented";
- break;
-
- case CAUSE_Q850_INVIEC:
- e = "Invalid information element contents";
- break;
-
- case CAUSE_Q850_MSGNCWCS:
- e = "Message not compatible with call state";
- break;
-
- case CAUSE_Q850_RECOTIMEXP:
- e = "Recovery on timer expiry";
- break;
-
- case CAUSE_Q850_PARMNENIPO:
- e = "Parameter non-existent or not implemented, passed on";
- break;
-
- case CAUSE_Q850_MSGUNRDPRM:
- e = "Message with unrecognized parameter, discarded";
- break;
-
- case CAUSE_Q850_PROTERR:
- e = "Protocol error, unspecified";
- break;
-
- case CAUSE_Q850_INTWRKU:
- e = "Interworking, unspecified";
- break;
-
- default:
- e = "ERROR, unknown cause value!";
- break;
- }
-
- sprintf(error_message, "%d: %s (Q.850)", code, e);
- return(error_message);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/pcause_q850.h b/usr.sbin/i4b/isdntrace/pcause_q850.h
deleted file mode 100644
index a6b947fefa25..000000000000
--- a/usr.sbin/i4b/isdntrace/pcause_q850.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * pcauseq850.h - Q.850 causes definitions
- * ---------------------------------------
- *
- * $Id: pcause_q850.h,v 1.3 1998/12/05 18:04:18 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:20:05 1998]
- *
- *---------------------------------------------------------------------------*/
-
-char *print_cause_q850(unsigned char code);
-
-/* Q.850 causes */
-
-#define CAUSE_Q850_SHUTDN 0x00 /* normal D-channel shutdown */
-#define CAUSE_Q850_NUNALLC 0x01 /* Unallocated (unassigned) number */
-#define CAUSE_Q850_NRTTN 0x02 /* No route to specified transit network */
-#define CAUSE_Q850_NRTDST 0x03 /* No route to destination */
-#define CAUSE_Q850_SSINFTN 0x04 /* Send special information tone */
-#define CAUSE_Q850_MDIALTP 0x05 /* Misdialled trunk prefix */
-#define CAUSE_Q850_CHUNACC 0x06 /* Channel unacceptable */
-#define CAUSE_Q850_CALLAWD 0x07 /* Call awarded and being delivered in an established channel */
-#define CAUSE_Q850_PREEMPT 0x08 /* Preemption */
-#define CAUSE_Q850_PREECRR 0x09 /* Preemption - circuit reserved for reuse */
-#define CAUSE_Q850_NCCLR 0x10 /* Normal call clearing */
-#define CAUSE_Q850_USRBSY 0x11 /* User busy */
-#define CAUSE_Q850_NOUSRRSP 0x12 /* No user responding */
-#define CAUSE_Q850_NOANSWR 0x13 /* No answer from user (user alerted) */
-#define CAUSE_Q850_SUBSABS 0x14 /* Subscriber absent */
-#define CAUSE_Q850_CALLREJ 0x15 /* Call rejected */
-#define CAUSE_Q850_NUCHNG 0x16 /* Number changed */
-#define CAUSE_Q850_NONSELUC 0x1A /* Non-selected user clearing */
-#define CAUSE_Q850_DSTOOORDR 0x1B /* Destination out of order */
-#define CAUSE_Q850_INVNUFMT 0x1C /* Invalid number format */
-#define CAUSE_Q850_FACREJ 0x1D /* Facility rejected */
-#define CAUSE_Q850_STENQRSP 0x1E /* Response to STATUS ENQUIRY */
-#define CAUSE_Q850_NORMUNSP 0x1F /* Normal, unspecified */
-#define CAUSE_Q850_NOCAVAIL 0x22 /* No circuit / channel available */
-#define CAUSE_Q850_NETOOORDR 0x26 /* Network out of order */
-#define CAUSE_Q850_PFMCDOOSERV 0x27 /* Permanent frame mode connection out of service */
-#define CAUSE_Q850_PFMCOPER 0x28 /* Permanent frame mode connection operational */
-#define CAUSE_Q850_TMPFAIL 0x29 /* Temporary failure */
-#define CAUSE_Q850_SWEQCONG 0x2A /* Switching equipment congestion */
-#define CAUSE_Q850_ACCINFDIS 0x2B /* Access information discarded */
-#define CAUSE_Q850_REQCNOTAV 0x2C /* Requested circuit/channel not available */
-#define CAUSE_Q850_PRECALBLK 0x2E /* Precedence call blocked */
-#define CAUSE_Q850_RESUNAVAIL 0x2F /* Resources unavailable, unspecified */
-#define CAUSE_Q850_QOSUNAVAIL 0x31 /* Quality of service unavailable */
-#define CAUSE_Q850_REQSERVNS 0x32 /* Requested facility not subscribed */
-#define CAUSE_Q850_OCBARRCUG 0x35 /* Outgoing calls barred within CUG */
-#define CAUSE_Q850_ICBARRCUG 0x36 /* Incoming calls barred within CUG */
-#define CAUSE_Q850_BCAPNAUTH 0x39 /* Bearer capability not authorized */
-#define CAUSE_Q850_BCAPNAVAIL 0x3A /* Bearer capability not presently available */
-#define CAUSE_Q850_INCSTOACISC 0x3E /* Inconsistenciy in designated outgoing access information and subscriber class */
-#define CAUSE_Q850_SOONOTAVAIL 0x3F /* Service or option not available, unspecified */
-#define CAUSE_Q850_BCAPNOTIMPL 0x41 /* Bearer capability not implemented */
-#define CAUSE_Q850_CHTYPNIMPL 0x42 /* Channel type not implemented */
-#define CAUSE_Q850_REQFACNIMPL 0x45 /* Requested facility not implemented */
-#define CAUSE_Q850_ORDINBCAVL 0x46 /* Only restricted digital information bearer capability is available */
-#define CAUSE_Q850_SOONOTIMPL 0x4F /* Service or option not implemented, unspecified */
-#define CAUSE_Q850_INVCLRFVAL 0x51 /* Invalid call reference value */
-#define CAUSE_Q850_IDCHDNOEX 0x52 /* Identified channel does not exist */
-#define CAUSE_Q850_SUSCAEXIN 0x53 /* A suspended call exists, but this call identity does not */
-#define CAUSE_Q850_CLIDINUSE 0x54 /* Call identity in use */
-#define CAUSE_Q850_NOCLSUSP 0x55 /* No call suspended */
-#define CAUSE_Q850_CLIDCLRD 0x56 /* Call having the requested call identity has been cleared */
-#define CAUSE_Q850_UNOTMEMCUG 0x57 /* User not member of CUG */
-#define CAUSE_Q850_INCDEST 0x58 /* Incompatible destination */
-#define CAUSE_Q850_NONEXCUG 0x5A /* Non-existent CUG */
-#define CAUSE_Q850_INVNTWSEL 0x5B /* Invalid transit network selection */
-#define CAUSE_Q850_INVMSG 0x5F /* Invalid message, unspecified */
-#define CAUSE_Q850_MIEMISS 0x60 /* Mandatory information element is missing */
-#define CAUSE_Q850_MSGTNI 0x61 /* Message type non-existent or not implemented */
-#define CAUSE_Q850_MSGNCMPT 0x62 /* Message not compatible with call state or message type non-existent or not implemented */
-#define CAUSE_Q850_IENENI 0x63 /* Information element/parameter non-existent or not implemented */
-#define CAUSE_Q850_INVIEC 0x64 /* Invalid information element contents */
-#define CAUSE_Q850_MSGNCWCS 0x65 /* Message not compatible with call state */
-#define CAUSE_Q850_RECOTIMEXP 0x66 /* Recovery on timer expiry */
-#define CAUSE_Q850_PARMNENIPO 0x67 /* Parameter non-existent or not implemented, passed on */
-#define CAUSE_Q850_MSGUNRDPRM 0x6E /* Message with unrecognized parameter, discarded */
-#define CAUSE_Q850_PROTERR 0x6F /* Protocol error, unspecified */
-#define CAUSE_Q850_INTWRKU 0x7F /* Interworking, unspecified */
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/q921.c b/usr.sbin/i4b/isdntrace/q921.c
deleted file mode 100644
index df007a49daca..000000000000
--- a/usr.sbin/i4b/isdntrace/q921.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (c) 1996 Gary Jennejohn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------*
- *
- * q.921.c - print Q.921 traces
- * ----------------------------
- *
- * $Id: q921.c,v 1.2 1998/04/16 15:27:02 hm Exp $
- *
- * last edit-date: [Thu Apr 16 15:38:34 1998]
- *
- * -hm splitting
- * -hm printing to buffer
- * -hm slightly reformatted TEI management proc output
- * -hm minor fixes
- * -hm fixing response/command
- * -hm fixing count off by one
- * -hm dump only Q.921 part of frame
- * -hm cleanup
- *
- *---------------------------------------------------------------------------*/
-
-#include "trace.h"
-
-/*---------------------------------------------------------------------------*
- * decode LAPD (Q.921) protocol
- *---------------------------------------------------------------------------*/
-int
-decode_lapd(char *pbuf, int n, unsigned char *buf, int dir, int raw, int printit)
-{
- int sap, tei, cmd, p_f;
- int cnt = 0;
- int i;
- char locbuf[32000];
- char *lbufp = &locbuf[0];
-
- *lbufp = '\0';
- *pbuf = '\0';
-
- sap = (buf[0] >> 2) & 0x3f;
- cnt++;
-
- tei = buf[1] >> 1;
- cnt++;
-
- if(dir == FROM_TE)
- cmd = !(buf[0] & 2);
- else
- cmd = buf[0] & 2;
-
- switch (sap)
- {
- /* SAPI control procedures */
- case 0:
- {
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "Q921: SAP=%d (Call Control), %c, TEI=%d, ", sap, cmd?'C':'R', tei);
-
- if((buf[2] & 0x01) == 0)
- {
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "I-Frame: ");
-
- p_f = buf [3] & 1;
-
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "N(S) %d N(R) %d P %d ", buf [2] >> 1, buf [3] >> 1, p_f);
-
- cnt += 2;
- }
- else if((buf[2] & 0x03) == 0x01)
- {
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "S-Frame: ");
-
- p_f = buf [3] & 1;
- cmd = buf [2] & 0x0c;
-
- if(printit)
- {
- if (cmd == 0)
- sprintf((lbufp+strlen(lbufp)), "RR N(R) %d PF %d ", buf [3] >> 1, p_f);
- if (cmd == 4)
- sprintf((lbufp+strlen(lbufp)), "RNR N(R) %d PF %d ", buf [3] >> 1, p_f);
- if (cmd == 8)
- sprintf((lbufp+strlen(lbufp)), "REJ N(R) %d PF %d ", buf [3] >> 1, p_f);
- }
- cnt += 2;
- }
- else if((buf[2] & 0x03) == 0x03)
- {
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "U-Frame: ");
-
- p_f = (buf [2] & 0x10) >> 4;
- cmd = buf [2] & 0xec;
-
- if(printit)
- {
- if (cmd == 0x6c)
- sprintf((lbufp+strlen(lbufp)), "SABME PF %d ", p_f);
- if (cmd == 0x0c)
- sprintf((lbufp+strlen(lbufp)), "DM PF %d ", p_f);
- if (cmd == 0)
- sprintf((lbufp+strlen(lbufp)), "UI PF %d ", p_f);
- if (cmd == 0x40)
- sprintf((lbufp+strlen(lbufp)), "DISC PF %d ", p_f);
- if (cmd == 0x60)
- sprintf((lbufp+strlen(lbufp)), "UA PF %d ", p_f);
- if (cmd == 0x84)
- sprintf((lbufp+strlen(lbufp)), "FRMR PF %d ", p_f);
- if (cmd == 0xac)
- sprintf((lbufp+strlen(lbufp)), "XID PF %d ", p_f);
- /* information field ??? */
- }
- cnt++;
- }
- break;
- }
-
- /* D channel X.25 */
-
- case 16:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "Q921: SAP=%d (X.25), %c, TEI=%d, ", sap, cmd?'C':'R', tei);
- cnt = n;
- goto dump;
-
- /* Loopback test */
-
- case 32:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "Q921: SAP=%d (Loopbacktest), %c, TEI=%d, ", sap, cmd?'C':'R', tei);
- cnt = n;
- goto dump;
-
- /* SAPI layer 2 management functions */
-
- case 63:
- {
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "Q921: SAP=%d (TEI-Management), %c, TEI=%d, ", sap, cmd?'C':'R', tei);
-
- if (tei != 127)
- {
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "ILLEGAL TEI\n");
- cnt = n;
- goto dump;
- }
-
- if (buf [2] != 3 && buf [3] != 0xf)
- {
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "invalid format!\n");
- cnt = n;
- goto dump;
- }
- cnt+= 2; /* UI + MEI */
-
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "Ri=0x%04hx, ", *(short *)&buf[4]);
- cnt += 2; /* Ri */
-
- switch (buf[6])
- {
- case 1:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "IdRequest, Ai=%d", (buf [7] >> 1));
- cnt += 2;
- break;
- case 2:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "IdAssign, Ai=%d", (buf [7] >> 1));
- cnt += 2;
- break;
- case 3:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "IdDenied, Ai=%d", (buf [7] >> 1));
- cnt += 2;
- break;
- case 4:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "IdCheckReq, Ai=%d", (buf [7] >> 1));
- cnt += 2;
- break;
- case 5:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "IdCheckResp, Ai=%d", (buf [7] >> 1));
- cnt += 2;
- break;
- case 6:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "IdRemove, Ai=%d", (buf [7] >> 1));
- cnt += 2;
- break;
- case 7:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "IdVerify, Ai=%d", (buf [7] >> 1));
- cnt += 2;
- break;
- default:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "Unknown Msg Type\n");
- cnt = n;
- goto dump;
- }
- break;
- }
-
- /* Illegal SAPI */
-
- default:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "Q921: ERROR, SAP=%d (Illegal SAPI), %c, TEI=%d\n", sap, cmd?'C':'R', tei);
- cnt = n;
- goto dump;
- }
-
-dump:
- if(printit)
- sprintf((lbufp+strlen(lbufp)), "\n");
-
- if(raw && printit)
- {
- int j;
- for (i = 0; i < cnt; i += 16)
- {
- sprintf((pbuf+strlen(pbuf)),"Dump:%.3d ", i);
- for (j = 0; j < 16; j++)
- if (i + j < cnt)
- sprintf((pbuf+strlen(pbuf)),"%02x ", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf))," ");
- sprintf((pbuf+strlen(pbuf))," ");
- for (j = 0; j < 16 && i + j < cnt; j++)
- if (isprint(buf[i + j]))
- sprintf((pbuf+strlen(pbuf)),"%c", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf)),".");
- sprintf((pbuf+strlen(pbuf)),"\n");
- }
- }
-
- sprintf((pbuf+strlen(pbuf)),"%s", &locbuf[0]);
-
- return (cnt);
-}
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/q931.c b/usr.sbin/i4b/isdntrace/q931.c
deleted file mode 100644
index 3cc2a3848a4f..000000000000
--- a/usr.sbin/i4b/isdntrace/q931.c
+++ /dev/null
@@ -1,783 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * q931.c - print Q.931 traces
- * ---------------------------
- *
- * $Id: q931.c,v 1.4 1998/12/05 18:04:19 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:20:31 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "trace.h"
-
-/*---------------------------------------------------------------------------*
- * decode Q.931 protocol
- *---------------------------------------------------------------------------*/
-void
-decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
-{
- int codeset = 0;
- int codelock = 0;
- int oldcodeset = 0;
-
- int pd;
- int len;
- int j;
- int i;
-
- if(n <= 0)
- return;
-
- *pbuf = '\0';
-
- if(raw)
- {
-
- for (i = 0; i < n; i += 16)
- {
- sprintf((pbuf+strlen(pbuf)),"Dump:%.3d ", i+off);
- for (j = 0; j < 16; j++)
- if (i + j < n)
- sprintf((pbuf+strlen(pbuf)),"%02x ", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf))," ");
- sprintf((pbuf+strlen(pbuf))," ");
- for (j = 0; j < 16 && i + j < n; j++)
- if (isprint(buf[i + j]))
- sprintf((pbuf+strlen(pbuf)),"%c", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf)),".");
- sprintf((pbuf+strlen(pbuf)),"\n");
- }
- }
-
- i = 0;
-
- sprintf((pbuf+strlen(pbuf)), "Q931: ");
-
- /* protocol discriminator */
-
- pd = buf[i];
-
- if(pd >= 0x00 && pd <= 0x07)
- sprintf((pbuf+strlen(pbuf)), "pd=User-User (0x%02x), ",pd);
- else if(pd == 0x08)
- sprintf((pbuf+strlen(pbuf)), "pd=Q.931/I.451, ");
- else if(pd >= 0x10 && pd <= 0x3f)
- sprintf((pbuf+strlen(pbuf)), "pd=Other Layer 3 or X.25 (0x%02x), ",pd);
- else if(pd >= 0x40 && pd <= 0x4f)
- sprintf((pbuf+strlen(pbuf)), "pd=National Use (0x%02x), ",pd);
- else if(pd >= 0x50 && pd <= 0xfe)
- sprintf((pbuf+strlen(pbuf)), "pd=Other Layer 3 or X.25 (0x%02x), ",pd);
- else
- sprintf((pbuf+strlen(pbuf)), "pd=Reserved (0x%02x), ",pd);
-
- /* call reference */
-
- i++;
-
- len = buf[i] & 0x0f;
-
- switch(len)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "cr=Dummy, ");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "cr=0x%02x %s, ", (buf[i+1] & 0x7f), (buf[i+1] & 0x80) ? "(from destination)" : "(from origination)");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "cr=0x%02x 0x%02x %s, ", (buf[i+1] & 0x7f), (buf[i+2] & 0x7f), (buf[i+1] & 0x80) ? "(org)" : "(dst)");
- break;
- }
-
- i += (len+1);
-
- /* message type */
-
- sprintf((pbuf+strlen(pbuf)), "message=");
-
- switch(buf[i])
- {
- /* escape to nationally specific message type */
-
- case 0x00:
- sprintf((pbuf+strlen(pbuf)), "ESCAPE: ");
- break;
-
- /* call establishment */
-
- case 0x01:
- sprintf((pbuf+strlen(pbuf)), "ALERTING: ");
- break;
- case 0x02:
- sprintf((pbuf+strlen(pbuf)), "CALL PROCEEDING: ");
- break;
- case 0x03:
- sprintf((pbuf+strlen(pbuf)), "PROGRESS: ");
- break;
- case 0x05:
- sprintf((pbuf+strlen(pbuf)), "SETUP: ");
- break;
- case 0x07:
- sprintf((pbuf+strlen(pbuf)), "CONNECT: ");
- break;
- case 0x0d:
- sprintf((pbuf+strlen(pbuf)), "SETUP ACKNOWLEDGE: ");
- break;
- case 0x0f:
- sprintf((pbuf+strlen(pbuf)), "CONNECT ACKNOWLEDGE: ");
- break;
-
- /* call information phase */
-
- case 0x20:
- sprintf((pbuf+strlen(pbuf)), "USER INFORMATION: ");
- break;
- case 0x21:
- sprintf((pbuf+strlen(pbuf)), "SUSPEND REJECT: ");
- break;
- case 0x22:
- sprintf((pbuf+strlen(pbuf)), "RESUME REJECT: ");
- break;
- case 0x24:
- sprintf((pbuf+strlen(pbuf)), "HOLD (Q.932): ");
- break;
- case 0x25:
- sprintf((pbuf+strlen(pbuf)), "SUSPEND: ");
- break;
- case 0x26:
- sprintf((pbuf+strlen(pbuf)), "RESUME: ");
- break;
- case 0x28:
- sprintf((pbuf+strlen(pbuf)), "HOLD ACKNOWLEDGE (Q.932): ");
- break;
- case 0x2d:
- sprintf((pbuf+strlen(pbuf)), "SUSPEND ACKNOWLEDGE: ");
- break;
- case 0x2e:
- sprintf((pbuf+strlen(pbuf)), "RESUME ACKNOWLEDGE: ");
- break;
- case 0x30:
- sprintf((pbuf+strlen(pbuf)), "HOLD REJECT (Q.932): ");
- break;
- case 0x31:
- sprintf((pbuf+strlen(pbuf)), "RETRIEVE (Q.932): ");
- break;
- case 0x32:
- sprintf((pbuf+strlen(pbuf)), "RETRIEVE ACKNOWLEDGE (Q.932): ");
- break;
- case 0x37:
- sprintf((pbuf+strlen(pbuf)), "RETRIEVE REJECT (Q.932): ");
- break;
-
- /* call clearing */
-
- case 0x40:
- sprintf((pbuf+strlen(pbuf)), "DETACH: ");
- break;
- case 0x45:
- sprintf((pbuf+strlen(pbuf)), "DISCONNECT: ");
- break;
- case 0x46:
- sprintf((pbuf+strlen(pbuf)), "RESTART: ");
- break;
- case 0x48:
- sprintf((pbuf+strlen(pbuf)), "DETACH ACKNOWLEDGE: ");
- break;
- case 0x4d:
- sprintf((pbuf+strlen(pbuf)), "RELEASE: ");
- break;
- case 0x4e:
- sprintf((pbuf+strlen(pbuf)), "RESTART ACKNOWLEDGE: ");
- break;
- case 0x5a:
- sprintf((pbuf+strlen(pbuf)), "RELEASE COMPLETE: ");
- break;
-
- /* misc messages */
-
- case 0x60:
- sprintf((pbuf+strlen(pbuf)), "SEGMENT: ");
- break;
- case 0x62:
- sprintf((pbuf+strlen(pbuf)), "FACILITY (Q.932): ");
- break;
- case 0x64:
- sprintf((pbuf+strlen(pbuf)), "REGISTER (Q.932): ");
- break;
- case 0x68:
- sprintf((pbuf+strlen(pbuf)), "CANCEL ACKNOWLEDGE: ");
- break;
- case 0x6a:
- sprintf((pbuf+strlen(pbuf)), "FACILITY ACKNOWLEDGE: ");
- break;
- case 0x6c:
- sprintf((pbuf+strlen(pbuf)), "REGISTER ACKNOWLEDGE: ");
- break;
- case 0x6e:
- sprintf((pbuf+strlen(pbuf)), "NOTIFY: ");
- break;
- case 0x70:
- sprintf((pbuf+strlen(pbuf)), "CANCEL REJECT: ");
- break;
- case 0x72:
- sprintf((pbuf+strlen(pbuf)), "FACILITY REJECT: ");
- break;
- case 0x74:
- sprintf((pbuf+strlen(pbuf)), "REGISTER REJECT: ");
- break;
- case 0x75:
- sprintf((pbuf+strlen(pbuf)), "STATUS ENQIRY: ");
- break;
- case 0x79:
- sprintf((pbuf+strlen(pbuf)), "CONGESTION CONTROL: ");
- break;
- case 0x7b:
- sprintf((pbuf+strlen(pbuf)), "INFORMATION: ");
- break;
- case 0x7d:
- sprintf((pbuf+strlen(pbuf)), "STATUS: ");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "UNDEFINED, TYPE=0x%02x, ", buf[i]);
- break;
- }
-
- /* other information elements */
-
- i++;
-
- for (; i < n;)
- {
- sprintf((pbuf+strlen(pbuf)), "\n ");
-
- if(buf[i] & 0x80)
- {
- /* single octett info element */
-
- switch(buf[i] & 0x70)
- {
- case 0x00: /* reserved */
- sprintf((pbuf+strlen(pbuf)), "[reserved single octett info]");
- break;
-
- case 0x10: /* shift */
- oldcodeset = codeset;
- codeset = buf[i] & 0x07;
- if(buf[i] & 0x08)
- codelock = 0;
- else
- codelock = 1;
- sprintf((pbuf+strlen(pbuf)), "[shift: codeset=%d lock=%d]", codeset, codelock);
- break;
-
- case 0x20: /* more data */
- if(buf[i] & 0x01)
- sprintf((pbuf+strlen(pbuf)), "[sending complete]");
- else
- sprintf((pbuf+strlen(pbuf)), "[more data]");
- break;
-
- case 0x30: /* congestion level */
- sprintf((pbuf+strlen(pbuf)), "[congestion level=");
- switch(buf[i] & 0x0f)
- {
- case 0x00:
- sprintf((pbuf+strlen(pbuf)), "rx-ready]");
- break;
- case 0x0f:
- sprintf((pbuf+strlen(pbuf)), "rx-not-ready]");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)]", buf[i] & 0x0f);
- break;
- }
- break;
-
- case 0x50: /* repeat ind */
- sprintf((pbuf+strlen(pbuf)), "[repeat indicator]");
- break;
-
- default:
- sprintf((pbuf+strlen(pbuf)), "[UNKNOWN SINGLE OCTET ELEMENT 0x%02x]", buf[i]);
- break;
- }
-
- i++; /* next */
-
- }
- else
- {
- /* variable length info element */
-
- if(codeset == 0)
- {
- switch(buf[i])
- {
- case 0x00:
- sprintf((pbuf+strlen(pbuf)), "[segmented message: ");
- break;
- case 0x04:
- sprintf((pbuf+strlen(pbuf)), "[bearer capability: ");
- i += p_q931bc(pbuf, &buf[i]);
- goto next;
- break;
- case 0x08:
- sprintf((pbuf+strlen(pbuf)), "[cause: ");
- i += p_q931cause(pbuf, &buf[i]);
- goto next;
- break;
- case 0x0c:
- sprintf((pbuf+strlen(pbuf)), "[connected address (old): ");
- break;
- case 0x0d:
- sprintf((pbuf+strlen(pbuf)), "[extended facility (Q.932: )");
- break;
- case 0x10:
- sprintf((pbuf+strlen(pbuf)), "[call identity: ");
- break;
- case 0x14:
- sprintf((pbuf+strlen(pbuf)), "[call state: ");
- i++;
- len = buf[i];
- i++;
- sprintf((pbuf+strlen(pbuf)), "Std=");
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "CCITT");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "ISO/IEC");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "National");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "Special");
- break;
- }
- sprintf((pbuf+strlen(pbuf)), ", State=");
-
- switch((buf[i] & 0x3f))
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "Null");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "Call initiated");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "Overlap sending");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "Outgoing call proceeding");
- break;
- case 4:
- sprintf((pbuf+strlen(pbuf)), "Call delivered");
- break;
- case 6:
- sprintf((pbuf+strlen(pbuf)), "Call present");
- break;
- case 7:
- sprintf((pbuf+strlen(pbuf)), "Call received");
- break;
- case 8:
- sprintf((pbuf+strlen(pbuf)), "Connect request");
- break;
- case 9:
- sprintf((pbuf+strlen(pbuf)), "Incoming call proceeding");
- break;
- case 10:
- sprintf((pbuf+strlen(pbuf)), "Active");
- break;
- case 11:
- sprintf((pbuf+strlen(pbuf)), "Disconnect request");
- break;
- case 12:
- sprintf((pbuf+strlen(pbuf)), "Disconnect indication");
- break;
- case 15:
- sprintf((pbuf+strlen(pbuf)), "Suspend request");
- break;
- case 17:
- sprintf((pbuf+strlen(pbuf)), "Resume request");
- break;
- case 19:
- sprintf((pbuf+strlen(pbuf)), "Release request");
- break;
- case 22:
- sprintf((pbuf+strlen(pbuf)), "Call abort");
- break;
- case 25:
- sprintf((pbuf+strlen(pbuf)), "Overlap receiving");
- break;
- case 0x3d:
- sprintf((pbuf+strlen(pbuf)), "Restart request");
- break;
- case 0x3e:
- sprintf((pbuf+strlen(pbuf)), "Restart");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "ERROR: undefined/reserved");
- break;
- }
- sprintf((pbuf+strlen(pbuf)), "]");
- i++;
- goto next;
- break;
- case 0x18:
- sprintf((pbuf+strlen(pbuf)), "[channel id: channel=");
- i++;
- len = buf[i];
- i++;
- switch(buf[i] & 0x03)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "no channel");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "B-1");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "B-2");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "any channel");
- break;
- }
- if(buf[i] & 0x08)
- sprintf((pbuf+strlen(pbuf)), " (exclusive)]");
- else
- sprintf((pbuf+strlen(pbuf)), " (preferred)]");
- i++;
- goto next;
- break;
- case 0x19:
- sprintf((pbuf+strlen(pbuf)), "[data link connection id (Q.933): ");
- break;
- case 0x1c:
- i += q932_facility(pbuf, &buf[i]);
- goto next;
- break;
- case 0x1e:
- sprintf((pbuf+strlen(pbuf)), "[progress ind: ");
- i++;
- len = buf[i];
- i++;
- sprintf((pbuf+strlen(pbuf)), "Std=");
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "CCITT");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "ISO/IEC");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "National");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "Local");
- break;
- }
- sprintf((pbuf+strlen(pbuf)), ", Loc=");
-
- switch((buf[i] & 0x0f))
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "User");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "Private network serving local user");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "Public network serving local user");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "Transit network");
- break;
- case 4:
- sprintf((pbuf+strlen(pbuf)), "Public network serving remote user");
- break;
- case 5:
- sprintf((pbuf+strlen(pbuf)), "Private network serving remote user");
- break;
- case 6:
- sprintf((pbuf+strlen(pbuf)), "Network beyond interworking point");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "ERROR: undefined/reserved");
- break;
- }
-
- i++;
-
- sprintf((pbuf+strlen(pbuf)), "\n Description: ");
-
- switch((buf[i] & 0x7f))
- {
- case 1:
- sprintf((pbuf+strlen(pbuf)), "Call is not end-to-end ISDN");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "Destination address is non-ISDN");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "Origination address is non-ISDN");
- break;
- case 4:
- sprintf((pbuf+strlen(pbuf)), "Call has returned to the ISDN");
- break;
- case 5:
- sprintf((pbuf+strlen(pbuf)), "Interworking occured, Service change");
- break;
- case 8:
- sprintf((pbuf+strlen(pbuf)), "In-band info or appropriate pattern now available");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "ERROR: undefined/reserved");
- break;
- }
- sprintf((pbuf+strlen(pbuf)), "]");
- i++;
- goto next;
- break;
- case 0x20:
- sprintf((pbuf+strlen(pbuf)), "[network specific facilities: ");
- break;
- case 0x24:
- sprintf((pbuf+strlen(pbuf)), "[terminal capabilities: ");
- break;
- case 0x27:
- sprintf((pbuf+strlen(pbuf)), "[notification ind: ");
- break;
- case 0x28:
- sprintf((pbuf+strlen(pbuf)), "[display: ");
- i++;
- len = buf[i];
- i++;
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf)),"%c", buf[j+i]);
- }
- sprintf((pbuf+strlen(pbuf)),"]");
- i += j;
- goto next;
- break;
- case 0x29:
- sprintf((pbuf+strlen(pbuf)), "[date/time: ");
- i++;
- len = buf[i];
- i++;
- j = 0;
- sprintf((pbuf+strlen(pbuf)),"%.2d.%.2d.%.2d",
- buf[i+2], buf[i+1], buf[i]);
- j+=3;
- if(j < len)
- {
- sprintf((pbuf+strlen(pbuf))," %.2d", buf[i+3]);
- j++;
- }
- if(j < len)
- {
- sprintf((pbuf+strlen(pbuf)),":%.2d", buf[i+4]);
- j++;
- }
- if(j < len)
- {
- sprintf((pbuf+strlen(pbuf)),":%.2d", buf[i+5]);
- j++;
- }
- sprintf((pbuf+strlen(pbuf)),"]");
- i += len;
- goto next;
- break;
- case 0x2c:
- sprintf((pbuf+strlen(pbuf)), "[keypad: ");
- break;
- case 0x30:
- sprintf((pbuf+strlen(pbuf)), "[keypad echo: ");
- break;
- case 0x32:
- sprintf((pbuf+strlen(pbuf)), "[information req (Q.932): ");
- break;
- case 0x34:
- sprintf((pbuf+strlen(pbuf)), "[signal: ");
- break;
- case 0x36:
- sprintf((pbuf+strlen(pbuf)), "[switchhook: ");
- break;
- case 0x38:
- sprintf((pbuf+strlen(pbuf)), "[feature activation (Q.932): ");
- break;
- case 0x39:
- sprintf((pbuf+strlen(pbuf)), "[feature ind (Q.932): ");
- break;
- case 0x3a:
- sprintf((pbuf+strlen(pbuf)), "[service profile id (Q.932): ");
- break;
- case 0x3b:
- sprintf((pbuf+strlen(pbuf)), "[endpoint id (Q.932): ");
- break;
- case 0x40:
- sprintf((pbuf+strlen(pbuf)), "[information rate: ");
- break;
- case 0x41:
- sprintf((pbuf+strlen(pbuf)), "[precedence level (Q.955): ");
- break;
- case 0x42:
- sprintf((pbuf+strlen(pbuf)), "[end-to-end transit delay: ");
- break;
- case 0x43:
- sprintf((pbuf+strlen(pbuf)), "[transit delay detection and indication: ");
- break;
- case 0x44:
- sprintf((pbuf+strlen(pbuf)), "[packet layer binary parameters: ");
- break;
- case 0x45:
- sprintf((pbuf+strlen(pbuf)), "[packet layer window size: ");
- break;
- case 0x46:
- sprintf((pbuf+strlen(pbuf)), "[packet size: ");
- break;
- case 0x47:
- sprintf((pbuf+strlen(pbuf)), "[closed user group: ");
- break;
- case 0x48:
- sprintf((pbuf+strlen(pbuf)), "[link layer core parameters (Q.933): ");
- break;
- case 0x49:
- sprintf((pbuf+strlen(pbuf)), "[link layer protocol parameters (Q.933): ");
- break;
- case 0x4a:
- sprintf((pbuf+strlen(pbuf)), "[reverse charging information: ");
- break;
- case 0x4c:
- sprintf((pbuf+strlen(pbuf)), "[connected number (Q.951): ");
- i += p_q931address(pbuf, &buf[i]);
- goto next;
- break;
-
- break;
- case 0x4d:
- sprintf((pbuf+strlen(pbuf)), "[connected subaddress (Q.951): ");
- break;
- case 0x50:
- sprintf((pbuf+strlen(pbuf)), "[X.213 priority (Q.933): ");
- break;
- case 0x51:
- sprintf((pbuf+strlen(pbuf)), "[report type (Q.933): ");
- break;
- case 0x53:
- sprintf((pbuf+strlen(pbuf)), "[link integrity verification (Q.933): ");
- break;
- case 0x57:
- sprintf((pbuf+strlen(pbuf)), "[PVC status (Q.933): ");
- break;
- case 0x6c:
- sprintf((pbuf+strlen(pbuf)), "[calling party number: ");
- i += p_q931address(pbuf, &buf[i]);
- goto next;
- break;
- case 0x6d:
- sprintf((pbuf+strlen(pbuf)), "[calling party subaddress: ");
- break;
- case 0x70:
- sprintf((pbuf+strlen(pbuf)), "[called party number: ");
- i += p_q931address(pbuf, &buf[i]);
- goto next;
- break;
- case 0x71:
- sprintf((pbuf+strlen(pbuf)), "[called party subaddress: ");
- break;
- case 0x74:
- sprintf((pbuf+strlen(pbuf)), "[redirecting number: ");
- break;
- case 0x76:
- sprintf((pbuf+strlen(pbuf)), "[redirection number: ");
- break;
- case 0x78:
- sprintf((pbuf+strlen(pbuf)), "[transit network selection: ");
- break;
- case 0x79:
- sprintf((pbuf+strlen(pbuf)), "[restart indicator: ");
- break;
- case 0x7c:
- sprintf((pbuf+strlen(pbuf)), "[low layer compatibility: ");
- break;
- case 0x7d:
- sprintf((pbuf+strlen(pbuf)), "[high layer compatibility:");
- i += p_q931high_compat(pbuf, &buf[i]);
- goto next;
- break;
- case 0x7e:
- sprintf((pbuf+strlen(pbuf)), "[user-user: ");
- break;
- case 0x7f:
- sprintf((pbuf+strlen(pbuf)), "[escape for extension: ");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "[UNKNOWN INFO-ELEMENT-ID=0x%02x: ", buf[i]);
- break;
- }
- }
- else
- {
- sprintf((pbuf+strlen(pbuf)), "[UNKNOWN CODESET=%d, IE=0x%02x: ", codeset, buf[i]);
- }
-
- i++; /* index -> length */
-
- len = buf[i];
-
- sprintf((pbuf+strlen(pbuf)), "LEN=0x%02x, DATA=", len);
-
- i++; /* index -> 1st param */
-
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf)),"0x%02x ", buf[j+i]);
- }
-
- sprintf((pbuf+strlen(pbuf)),"]");
-
- i += len;
-
-next:
-
- if(!codelock && (codeset != oldcodeset))
- codeset = oldcodeset;
- }
- }
- sprintf((pbuf+strlen(pbuf)),"\n");
-}
-
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdntrace/q931_util.c b/usr.sbin/i4b/isdntrace/q931_util.c
deleted file mode 100644
index 1b2ab09faef5..000000000000
--- a/usr.sbin/i4b/isdntrace/q931_util.c
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * q931_util.c - utility functions to print Q.931 traces
- * -----------------------------------------------------
- *
- * $Id: q931_util.c,v 1.4 1998/12/05 18:04:21 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:20:43 1998]
- *
- *---------------------------------------------------------------------------*/
-
-#include "trace.h"
-
-/*---------------------------------------------------------------------------*
- * decode and print the cause
- *---------------------------------------------------------------------------*/
-int
-p_q931cause(char *pbuf, unsigned char *buf)
-{
- int j;
- int len;
- int i = 0;
- int ls;
- int r = 0;
- int rflag = 0;
-
- i++; /* index -> length */
-
- len = buf[i];
-
- i++; /* coding/location */
- len--;
-
- ls = buf[i];
-
- i++;
- len--;
-
- if(!(buf[i-1] & 0x80))
- {
- r = buf[i];
- rflag = 1;
- i++;
- len--;
- }
-
- sprintf((pbuf+strlen(pbuf)), "%s ", print_cause_q850(buf[i] & 0x7f));
-
- sprintf((pbuf+strlen(pbuf)), "\n (location=");
-
- switch(ls & 0x0f)
- {
- case 0x00:
- sprintf((pbuf+strlen(pbuf)), "user");
- break;
- case 0x01:
- sprintf((pbuf+strlen(pbuf)), "private network serving local user");
- break;
- case 0x02:
- sprintf((pbuf+strlen(pbuf)), "public network serving local user");
- break;
- case 0x03:
- sprintf((pbuf+strlen(pbuf)), "transit network");
- break;
- case 0x04:
- sprintf((pbuf+strlen(pbuf)), "public network serving remote user");
- break;
- case 0x05:
- sprintf((pbuf+strlen(pbuf)), "private network serving remote user");
- break;
- case 0x07:
- sprintf((pbuf+strlen(pbuf)), "international network");
- break;
- case 0x0a:
- sprintf((pbuf+strlen(pbuf)), "network beyond interworking point");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", ls & 0x0f);
- break;
- }
-
- sprintf((pbuf+strlen(pbuf)), ", std=");
-
- switch((ls & 0x60) >> 5)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "CCITT");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "ISO/IEC");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "National");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "Local");
- break;
- }
-
- if(rflag)
- {
- sprintf((pbuf+strlen(pbuf)), ", rec=");
-
- switch(r & 0x7f)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "Q.931");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "X.21");
- break;
- case 4:
- sprintf((pbuf+strlen(pbuf)), "X.25");
- break;
- case 5:
- sprintf((pbuf+strlen(pbuf)), "Q.1031/Q.1051");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "Reserved");
- break;
- }
- }
-
- sprintf((pbuf+strlen(pbuf)),")");
-
- i++;
- len--;
-
- for(j = 0; j < len; j++)
- sprintf((pbuf+strlen(pbuf))," 0x%02x", buf[j+i]);
-
- sprintf((pbuf+strlen(pbuf)),"]");
-
- i += (len+1);
-
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print the bearer capability
- *---------------------------------------------------------------------------*/
-int
-p_q931bc(char *pbuf, unsigned char *buf)
-{
- int len;
- int i = 0;
- int mr = 0;
-
- i++; /* index -> length */
-
- len = buf[i];
-
- i++;
-
- sprintf((pbuf+strlen(pbuf)), "\n cap=");
-
- switch(buf[i] & 0x1f)
- {
- case 0x00:
- sprintf((pbuf+strlen(pbuf)), "speech");
- break;
- case 0x08:
- sprintf((pbuf+strlen(pbuf)), "unrestricted digital information");
- break;
- case 0x09:
- sprintf((pbuf+strlen(pbuf)), "restricted digital information");
- break;
- case 0x10:
- sprintf((pbuf+strlen(pbuf)), "3.1 kHz audio");
- break;
- case 0x11:
- sprintf((pbuf+strlen(pbuf)), "unrestricted digital information with tones");
- break;
- case 0x18:
- sprintf((pbuf+strlen(pbuf)), "video");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
-
- sprintf((pbuf+strlen(pbuf)), "\n std=");
-
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "CCITT");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "ISO/IEC");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "National");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "NSI Std");
- break;
- }
-
- i++;
- len--;
-
- sprintf((pbuf+strlen(pbuf)), "\n rate=");
-
- switch(buf[i] & 0x1f)
- {
- case 0x00:
- sprintf((pbuf+strlen(pbuf)), "packet mode");
- break;
- case 0x10:
- sprintf((pbuf+strlen(pbuf)), "64 kbit/s");
- break;
- case 0x11:
- sprintf((pbuf+strlen(pbuf)), "2 x 64 kbit/s");
- break;
- case 0x13:
- sprintf((pbuf+strlen(pbuf)), "384 kbit/s");
- break;
- case 0x15:
- sprintf((pbuf+strlen(pbuf)), "1536 kbit/s");
- break;
- case 0x17:
- sprintf((pbuf+strlen(pbuf)), "1920 kbit/s");
- break;
- case 0x18:
- sprintf((pbuf+strlen(pbuf)), "Multirate");
- mr = 1;
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
-
- sprintf((pbuf+strlen(pbuf)), "\n mode=");
-
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "circuit");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "packet");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", ((buf[i] & 0x60) >> 5));
- break;
- }
-
- i++;
- len--;
-
- if(!len)
- goto exit;
-
- if(mr)
- {
- sprintf((pbuf+strlen(pbuf)), "\n rate multiplier=%d", buf[i] & 0x7f);
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- sprintf((pbuf+strlen(pbuf)), "\n layer1=");
-
- switch(buf[i] & 0x1f)
- {
- case 0x01:
- sprintf((pbuf+strlen(pbuf)), "V.110");
- break;
- case 0x02:
- sprintf((pbuf+strlen(pbuf)), "G.711 u-law");
- break;
- case 0x03:
- sprintf((pbuf+strlen(pbuf)), "G.711 A-law");
- break;
- case 0x04:
- sprintf((pbuf+strlen(pbuf)), "G.721");
- break;
- case 0x05:
- sprintf((pbuf+strlen(pbuf)), "H.221/H.242");
- break;
- case 0x07:
- sprintf((pbuf+strlen(pbuf)), "Non-Std");
- break;
- case 0x08:
- sprintf((pbuf+strlen(pbuf)), "V.120");
- break;
- case 0x09:
- sprintf((pbuf+strlen(pbuf)), "X.31");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "reserved (0x%02x)", buf[i] & 0x0f);
- break;
- }
- i++;
- len--;
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n user rate=0x%02x ", buf[i] & 0x1f);
-
- if(buf[i] & 0x40)
- sprintf((pbuf+strlen(pbuf)), "(async,");
- else
- sprintf((pbuf+strlen(pbuf)), "(sync,");
-
- if(buf[i] & 0x20)
- sprintf((pbuf+strlen(pbuf)), "in-band neg. possible)");
- else
- sprintf((pbuf+strlen(pbuf)), "in-band neg not possible)");
-
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n clk/flow=0x%02x", buf[i] & 0x1f);
-
- sprintf((pbuf+strlen(pbuf)), "\n intermediate rate=");
-
- switch((buf[i] & 0x60) >> 5)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "not used");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "8 kbit/s");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "16 kbit/s");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "32 kbit/s");
- break;
- }
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n hdr/mfrm/etc.=0x%02x", buf[i]);
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n stop/data/parity=0x%02x", buf[i]);
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- if(!(buf[i-1] & 0x80))
- {
- sprintf((pbuf+strlen(pbuf)), "\n modemtype=0x%02x", buf[i]);
- i++;
- len--;
- }
-
- if(!len)
- goto exit;
-
- switch(buf[i] & 0x7f)
- {
- case 0x42:
- sprintf((pbuf+strlen(pbuf)), "\n layer2=Q.921/I.441");
- break;
- case 0x46:
- sprintf((pbuf+strlen(pbuf)), "\n layer2=X.25 link");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "\n layer2=0x%02x",(buf[i] & 0x7f));
- break;
- }
- i++;
- len--;
-
- if(!len)
- goto exit;
-
- switch(buf[i] & 0x7f)
- {
- case 0x62:
- sprintf((pbuf+strlen(pbuf)), "\n layer3=Q.921/I.441");
- break;
- case 0x66:
- sprintf((pbuf+strlen(pbuf)), "\n layer3=X.25 packet");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "\n layer3=0x%02x",(buf[i] & 0x7f));
- break;
- }
- i++;
- len--;
-
-exit:
- sprintf((pbuf+strlen(pbuf)), "]");
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print the ISDN (telephone) number
- *---------------------------------------------------------------------------*/
-int
-p_q931address(char *pbuf, unsigned char *buf)
-{
- int j;
- int len;
- int i = 0;
- int tp;
- int ind = 0;
- int indflag = 0;
-
- i++; /* index -> length */
- len = buf[i];
-
- i++; /* index -> type/plan */
- tp = buf[i];
-
- i++;
- len--;
-
- if(!(tp & 0x80))
- {
- ind = buf[i];
- indflag = 1;
- i++;
- len--;
- }
-
- for(j = 0; j < len; j++)
- {
- sprintf((pbuf+strlen(pbuf)),"%c", buf[j+i]);
- }
-
- switch((tp & 0x70) >> 4)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), " (type=unknown, ");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), " (type=international, ");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), " (type=national, ");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), " (type=network specific, ");
- break;
- case 4:
- sprintf((pbuf+strlen(pbuf)), " (type=subscriber, ");
- break;
- case 6:
- sprintf((pbuf+strlen(pbuf)), " (type=abbreviated, ");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), " (type=reserved (%d), ", ((tp & 0x70) >> 4));
- break;
- }
-
- switch(tp & 0x0f)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "plan=unknown");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "plan=ISDN");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "plan=Data");
- break;
- case 4:
- sprintf((pbuf+strlen(pbuf)), "plan=Telex");
- break;
- case 8:
- sprintf((pbuf+strlen(pbuf)), "plan=National");
- break;
- case 9:
- sprintf((pbuf+strlen(pbuf)), "plan=private");
- break;
- default:
- sprintf((pbuf+strlen(pbuf)), "plan=reserved (%d)", (tp & 0x0f));
- break;
- }
-
- if(indflag)
- {
- sprintf((pbuf+strlen(pbuf)), ",\n ");
- switch((ind & 0x60) >> 5)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "presentation allowed, ");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "presentation restricted, ");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "number not available, ");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "reserved, ");
- break;
- }
-
- switch(ind & 0x03)
- {
- case 0:
- sprintf((pbuf+strlen(pbuf)), "screening user provided: not screened");
- break;
- case 1:
- sprintf((pbuf+strlen(pbuf)), "screening user provided: verified & passed");
- break;
- case 2:
- sprintf((pbuf+strlen(pbuf)), "screening user provided: verified & failed");
- break;
- case 3:
- sprintf((pbuf+strlen(pbuf)), "screening network provided");
- break;
- }
- }
-
- sprintf((pbuf+strlen(pbuf)),")]");
-
- i += j;
-
- return(i);
-}
-
-/*---------------------------------------------------------------------------*
- * decode and print HL comatibility
- *---------------------------------------------------------------------------*/
-int
-p_q931high_compat(char *pbuf, unsigned char *buf)
-{
- int len = buf[1];
-
- sprintf(pbuf+strlen(pbuf), " standard=");
-
- switch ((buf[2] >> 5) & 0x03)
- {
- case 0: sprintf(pbuf+strlen(pbuf), "CCITT");
- break;
- case 1: sprintf(pbuf+strlen(pbuf), "unknown international standard");
- break;
- case 2: sprintf(pbuf+strlen(pbuf), "unknown national standard");
- break;
- case 3: sprintf(pbuf+strlen(pbuf), "local network standard");
- }
-
- len--;
-
- sprintf(pbuf+strlen(pbuf), ", characteristics=");
-
- switch (buf[3] & 0x7f)
- {
- case 0x01:
- sprintf(pbuf+strlen(pbuf), "Telephony");
- break;
- case 0x04:
- sprintf(pbuf+strlen(pbuf), "Fax Group 2/3");
- break;
- case 0x21:
- sprintf(pbuf+strlen(pbuf), "Fax Group 4 Class I (F.184)");
- break;
- case 0x24:
- sprintf(pbuf+strlen(pbuf), "Teletex basic/mixed (F.230) or Fax Group 4 Class II/III (F.184)");
- break;
- case 0x28:
- sprintf(pbuf+strlen(pbuf), "Teletex basic/processable (F.220)");
- break;
- case 0x31:
- sprintf(pbuf+strlen(pbuf), "Teletex basic mode (F.200)");
- break;
- case 0x32:
- sprintf(pbuf+strlen(pbuf), "Videotex (F.300 and T.101)");
- break;
- case 0x35:
- sprintf(pbuf+strlen(pbuf), "Telex (F.60)");
- break;
- case 0x38:
- sprintf(pbuf+strlen(pbuf), "MHS (X.400 series)");
- break;
- case 0x41:
- sprintf(pbuf+strlen(pbuf), "OSI application (X.200 series)");
- break;
- case 0x5e:
- sprintf(pbuf+strlen(pbuf), "Maintenance");
- break;
- case 0x5f:
- sprintf(pbuf+strlen(pbuf), "Management");
- break;
- case 0x7f:
- sprintf(pbuf+strlen(pbuf), "reserved");
- break;
- default:
- sprintf(pbuf+strlen(pbuf), "UNKNOWN (0x%02x)", buf[3]);
- break;
- }
-
- len--;
-
- if (!len)
- {
- sprintf(pbuf+strlen(pbuf), "]");
- return 4;
- }
-
- sprintf(pbuf+strlen(pbuf), " of ");
-
- switch (buf[4] & 0x7f)
- {
- case 0x01:
- sprintf(pbuf+strlen(pbuf), "Telephony");
- break;
- case 0x04:
- sprintf(pbuf+strlen(pbuf), "Fax Group 2/3");
- break;
- case 0x21:
- sprintf(pbuf+strlen(pbuf), "Fax Group 4 Class I (F.184)");
- break;
- case 0x24:
- sprintf(pbuf+strlen(pbuf), "Teletex basic/mixed (F.230) or Fax Group 4 Class II/III (F.184)");
- break;
- case 0x28:
- sprintf(pbuf+strlen(pbuf), "Teletex basic/processable (F.220)");
- break;
- case 0x31:
- sprintf(pbuf+strlen(pbuf), "Teletex basic mode (F.200)");
- break;
- case 0x32:
- sprintf(pbuf+strlen(pbuf), "Videotex (F.300 and T.101)");
- break;
- case 0x35:
- sprintf(pbuf+strlen(pbuf), "Telex (F.60)");
- break;
- case 0x38:
- sprintf(pbuf+strlen(pbuf), "MHS (X.400 series)");
- break;
- case 0x41:
- sprintf(pbuf+strlen(pbuf), "OSI application (X.200 series)");
- break;
- case 0x7f:
- sprintf(pbuf+strlen(pbuf), "reserved");
- break;
- default:
- sprintf(pbuf+strlen(pbuf), "UNKNOWN (0x%02x)", buf[3]);
- break;
- }
- sprintf(pbuf+strlen(pbuf), "]");
- return 5;
-}
-
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdntrace/q932_fac.c b/usr.sbin/i4b/isdntrace/q932_fac.c
deleted file mode 100644
index ba3f59d84a38..000000000000
--- a/usr.sbin/i4b/isdntrace/q932_fac.c
+++ /dev/null
@@ -1,926 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * q932_fac.c - decode Q.932 facilities
- * ------------------------------------
- *
- * $Id: q932_fac.c,v 1.4 1998/12/05 18:04:22 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:20:58 1998]
- *
- *---------------------------------------------------------------------------
- *
- * - Q.932 (03/93) Generic Procedures for the Control of
- * ISDN Supplementaty Services
- * - Q.950 (03/93) Supplementary Services Protocols, Structure and
- * General Principles
- * - ETS 300 179 (10/92) Advice Of Charge: charging information during
- * the call (AOC-D) supplementary service Service description
- * - ETS 300 180 (10/92) Advice Of Charge: charging information at the
- * end of call (AOC-E) supplementary service Service description
- * - ETS 300 181 (04/93) Advice Of Charge (AOC) supplementary service
- * Functional capabilities and information flows
- * - ETS 300 182 (04/93) Advice Of Charge (AOC) supplementary service
- * Digital Subscriber Signalling System No. one (DSS1) protocol
- * - X.208 Specification of Abstract Syntax Notation One (ASN.1)
- * - X.209 Specification of Basic Encoding Rules for
- * Abstract Syntax Notation One (ASN.1)
- * - "ASN.1 Abstract Syntax Notation One", Walter Gora, DATACOM-Verlag
- * 1992, 3rd Edition (ISBN 3-89238-062-7) (german !)
- *
- *---------------------------------------------------------------------------*/
-
-#include "trace.h"
-#include "q932_fac.h"
-
-static int do_component(int length, char *pbuf);
-static char *uni_str(int code);
-static char *opval_str(int val);
-static char *bid_str(int val);
-static void next_state(char *pbuf, int class, int form, int code, int val);
-
-static int byte_len;
-static unsigned char *byte_buf;
-static int state;
-
-/*---------------------------------------------------------------------------*
- * decode Q.931/Q.932 facility info element
- *---------------------------------------------------------------------------*/
-int
-q932_facility(char *pbuf, unsigned char *buf)
-{
- int len;
-
- sprintf((pbuf+strlen(pbuf)), "[facility (Q.932): ");
-
- buf++; /* length */
-
- len = *buf;
-
- buf++; /* protocol profile */
-
- sprintf((pbuf+strlen(pbuf)), "Protocol=");
-
- switch(*buf & 0x1f)
- {
- case FAC_PROTO_ROP:
- sprintf((pbuf+strlen(pbuf)), "Remote Operations Protocol\n");
- break;
-
- case FAC_PROTO_CMIP:
- sprintf((pbuf+strlen(pbuf)), "CMIP Protocol (Q.941), UNSUPPORTED!\n");
- return(len+2);
- break;
-
- case FAC_PROTO_ACSE:
- sprintf((pbuf+strlen(pbuf)), "ACSE Protocol (X.217/X.227), UNSUPPORTED!\n");
- return(len+2);
- break;
-
- default:
- sprintf((pbuf+strlen(pbuf)), "Unknown Protocol (val = 0x%x), UNSUPPORTED!\n", *buf & 0x1f);
- return(len+2);
- break;
- }
-
- /* next byte */
-
- buf++;
- len--;
-
- /* initialize variables for do_component */
-
- byte_len = 0;
- byte_buf = buf;
- state = ST_EXP_COMP_TYP;
-
- /* decode facility */
-
- do_component(len, pbuf);
-
- sprintf((pbuf+(strlen(pbuf)-1)), "]"); /* XXX replace last newline */
-
- return(len+3);
-}
-
-/*---------------------------------------------------------------------------*
- * handle a component recursively
- *---------------------------------------------------------------------------*/
-static int
-do_component(int length, char *pbuf)
-{
- int comp_tag_class; /* component tag class */
- int comp_tag_form; /* component form: constructor or primitive */
- int comp_tag_code; /* component code depending on class */
- int comp_length = 0; /* component length */
-
-#ifdef FAC_DEBUG
- sprintf((pbuf+strlen(pbuf)), "ENTER - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
-#endif
-
-again:
-
-#ifdef FAC_DEBUG
- sprintf((pbuf+strlen(pbuf)), "AGAIN - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
-#endif
-
- /*----------------------------------------*/
- /* first component element: component tag */
- /*----------------------------------------*/
-
- /* tag class bits */
-
- sprintf((pbuf+strlen(pbuf)), "\t0x%02x Tag: ", *byte_buf);
-
- comp_tag_class = (*byte_buf & 0xc0) >> 6;
-
- switch(comp_tag_class)
- {
- case FAC_TAGCLASS_UNI:
- sprintf((pbuf+strlen(pbuf)), "Universal");
- break;
- case FAC_TAGCLASS_APW:
- sprintf((pbuf+strlen(pbuf)), "Applic-wide");
- break;
- case FAC_TAGCLASS_COS:
- sprintf((pbuf+strlen(pbuf)), "Context-spec");
- break;
- case FAC_TAGCLASS_PRU:
- sprintf((pbuf+strlen(pbuf)), "Private");
- break;
- }
-
- /* tag form bit */
-
- comp_tag_form = (*byte_buf & 0x20) > 5;
-
- sprintf((pbuf+strlen(pbuf)), ", ");
-
- if(comp_tag_form == FAC_TAGFORM_CON)
- {
- sprintf((pbuf+strlen(pbuf)), "Constructor");
- }
- else
- {
- sprintf((pbuf+strlen(pbuf)), "Primitive");
- }
-
- /* tag code bits */
-
- comp_tag_code = *byte_buf & 0x1f;
-
- sprintf((pbuf+strlen(pbuf)), ", ");
-
- if(comp_tag_code == 0x1f)
- {
- comp_tag_code = 0;
-
- byte_buf++;
- byte_len++;
-
- while(*byte_buf & 0x80)
- {
- comp_tag_code += (*byte_buf & 0x7f);
- byte_buf++;
- byte_len++;
- }
- comp_tag_code += (*byte_buf & 0x7f);
- sprintf((pbuf+strlen(pbuf)), "%d (ext)\n", comp_tag_code);
- }
- else
- {
- comp_tag_code = (*byte_buf & 0x1f);
-
- if(comp_tag_class == FAC_TAGCLASS_UNI)
- {
- sprintf((pbuf+strlen(pbuf)), "%s (%d)\n", uni_str(comp_tag_code), comp_tag_code);
- }
- else
- {
- sprintf((pbuf+strlen(pbuf)), "code = %d\n", comp_tag_code);
- }
- }
-
- byte_buf++;
- byte_len++;
-
- /*--------------------------------------------*/
- /* second component element: component length */
- /*--------------------------------------------*/
-
- sprintf((pbuf+strlen(pbuf)), "\t0x%02x Len: ", *byte_buf);
-
- comp_length = 0;
-
- if(*byte_buf & 0x80)
- {
- int i = *byte_buf & 0x7f;
-
- byte_len += i;
-
- for(;i > 0;i++)
- {
- byte_buf++;
- comp_length += (*byte_buf * (i*256));
- }
- sprintf((pbuf+strlen(pbuf)), "%d (long form)\n", comp_length);
- }
- else
- {
- comp_length = *byte_buf & 0x7f;
- sprintf((pbuf+strlen(pbuf)), "%d (short form)\n", comp_length);
- }
-
- next_state(pbuf, comp_tag_class, comp_tag_form, comp_tag_code, -1);
-
- byte_len++;
- byte_buf++;
-
- if(comp_length)
- {
-
- /*---------------------------------------------*/
- /* third component element: component contents */
- /*---------------------------------------------*/
-
- if(comp_tag_form) /* == constructor */
- {
- do_component(comp_length, pbuf);
- }
- else
- {
- int val = 0;
- if(comp_tag_class == FAC_TAGCLASS_UNI)
- {
- switch(comp_tag_code)
- {
- case FAC_CODEUNI_INT:
- case FAC_CODEUNI_ENUM:
- case FAC_CODEUNI_BOOL:
- if(comp_length)
- {
- int i;
-
- sprintf((pbuf+strlen(pbuf)), "\t");
-
- for(i = comp_length-1; i >= 0; i--)
- {
- sprintf((pbuf+strlen(pbuf)), "0x%02x ", *byte_buf);
- val += (*byte_buf + (i*255));
- byte_buf++;
- byte_len++;
- if(i)
- sprintf((pbuf+strlen(pbuf)), "\n\t");
- }
- sprintf((pbuf+strlen(pbuf)), "Val: %d\n", val);
- }
- break;
- default:
- if(comp_length)
- {
- int i;
-
- sprintf((pbuf+strlen(pbuf)), "\t");
-
- for(i = comp_length-1; i >= 0; i--)
- {
- sprintf((pbuf+strlen(pbuf)), "0x%02x = %d", *byte_buf, *byte_buf);
- if(isprint(*byte_buf))
- sprintf((pbuf+strlen(pbuf)), " = '%c'", *byte_buf);
- byte_buf++;
- byte_len++;
- if(i)
- sprintf((pbuf+strlen(pbuf)), "\n\t");
- }
- }
- break;
- }
- }
-
- else /* comp_tag_class != FAC_TAGCLASS_UNI */
- {
- if(comp_length)
- {
- int i;
-
- sprintf((pbuf+strlen(pbuf)), "\t");
-
- for(i = comp_length-1; i >= 0; i--)
- {
- sprintf((pbuf+strlen(pbuf)), "0x%02x", *byte_buf);
- val += (*byte_buf + (i*255));
- byte_buf++;
- byte_len++;
- if(i)
- sprintf((pbuf+strlen(pbuf)), "\n\t");
- }
- sprintf((pbuf+strlen(pbuf)), "\n");
- }
- }
- next_state(pbuf, comp_tag_class, comp_tag_form, comp_tag_code, val);
- }
- }
-
-#ifdef FAC_DEBUG
- sprintf((pbuf+strlen(pbuf)), "PREGOTO - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
-#endif
- if(byte_len < length)
- goto again;
-#ifdef FAC_DEBUG
- sprintf((pbuf+strlen(pbuf)), "RETURN - comp_length = %d, byte_len = %d, length =%d\n", comp_length, byte_len, length);
-#endif
- return(byte_len);
-}
-
-/*---------------------------------------------------------------------------*
- * print universal id type
- *---------------------------------------------------------------------------*/
-static char *uni_str(int code)
-{
- static char *tbl[] = {
- "BOOLEAN",
- "INTEGER",
- "BIT STRING",
- "OCTET STRING",
- "NULL",
- "OBJECT IDENTIFIER",
- "OBJECT DESCRIPTOR",
- "EXTERNAL",
- "REAL",
- "ENUMERATED",
- "RESERVED11",
- "RESERVED12",
- "RESERVED13",
- "RESERVED14",
- "RESERVED15",
- "SEQUENCE",
- "SET",
- "NUMERIC STRING",
- "PRINTABLE STRING",
- "TELETEX STRING",
- "ISO646 STRING",
- "IA5 STRING",
- "GRAPHIC STRING",
- "GENERAL STRING"
- };
-
- if(code >= 1 && code <= FAC_CODEUNI_GNSTR)
- return(tbl[code-1]);
- else
- return("ERROR, Value out of Range!");
-}
-
-/*---------------------------------------------------------------------------*
- * print operation value
- *---------------------------------------------------------------------------*/
-static char *opval_str(int val)
-{
- static char buffer[80];
- char *r;
-
- switch(val)
- {
- case FAC_OPVAL_UUS:
- r = "uUs";
- break;
- case FAC_OPVAL_CUG:
- r = "cUGCall";
- break;
- case FAC_OPVAL_MCID:
- r = "mCIDRequest";
- break;
- case FAC_OPVAL_BTPY:
- r = "beginTPY";
- break;
- case FAC_OPVAL_ETPY:
- r = "endTPY";
- break;
- case FAC_OPVAL_ECT:
- r = "eCTRequest";
- break;
- case FAC_OPVAL_DIV_ACT:
- r = "activationDiversion";
- break;
- case FAC_OPVAL_DIV_DEACT:
- r = "deactivationDiversion";
- break;
- case FAC_OPVAL_DIV_ACTSN:
- r = "activationStatusNotificationDiv";
- break;
- case FAC_OPVAL_DIV_DEACTSN:
- r = "deactivationStatusNotificationDiv";
- break;
- case FAC_OPVAL_DIV_INTER:
- r = "interrogationDiversion";
- break;
- case FAC_OPVAL_DIV_INFO:
- r = "diversionInformation";
- break;
- case FAC_OPVAL_DIV_CALLDEF:
- r = "callDeflection";
- break;
- case FAC_OPVAL_DIV_CALLRER:
- r = "callRerouting";
- break;
- case FAC_OPVAL_DIV_LINF2:
- r = "divertingLegInformation2";
- break;
- case FAC_OPVAL_DIV_INVS:
- r = "invokeStatus";
- break;
- case FAC_OPVAL_DIV_INTER1:
- r = "interrogationDiversion1";
- break;
- case FAC_OPVAL_DIV_LINF1:
- r = "divertingLegInformation1";
- break;
- case FAC_OPVAL_DIV_LINF3:
- r = "divertingLegInformation3";
- break;
- case FAC_OPVAL_ER_CRCO:
- r = "explicitReservationCreationControl";
- break;
- case FAC_OPVAL_ER_MGMT:
- r = "explicitReservationManagement";
- break;
- case FAC_OPVAL_ER_CANC:
- r = "explicitReservationCancel";
- break;
- case FAC_OPVAL_MLPP_QUERY:
- r = "mLPP lfb Query";
- break;
- case FAC_OPVAL_MLPP_CALLR:
- r = "mLPP Call Request";
- break;
- case FAC_OPVAL_MLPP_CALLP:
- r = "mLPP Call Preemption";
- break;
- case FAC_OPVAL_AOC_REQ:
- r = "chargingRequest";
- break;
- case FAC_OPVAL_AOC_S_CUR:
- r = "aOCSCurrency";
- break;
- case FAC_OPVAL_AOC_S_SPC:
- r = "aOCSSpecialArrangement";
- break;
- case FAC_OPVAL_AOC_D_CUR:
- r = "aOCDCurrency";
- break;
- case FAC_OPVAL_AOC_D_UNIT:
- r = "aOCDChargingUnit";
- break;
- case FAC_OPVAL_AOC_E_CUR:
- r = "aOCECurrency";
- break;
- case FAC_OPVAL_AOC_E_UNIT:
- r = "aOCEChargingUnit";
- break;
- case FAC_OPVAL_AOC_IDOFCRG:
- r = "identificationOfCharge";
- break;
- case FAC_OPVAL_CONF_BEG:
- r = "beginConf";
- break;
- case FAC_OPVAL_CONF_ADD:
- r = "addConf";
- break;
- case FAC_OPVAL_CONF_SPLIT:
- r = "splitConf";
- break;
- case FAC_OPVAL_CONF_DROP:
- r = "dropConf";
- break;
- case FAC_OPVAL_CONF_ISOLATE:
- r = "isolateConf";
- break;
- case FAC_OPVAL_CONF_REATT:
- r = "reattachConf";
- break;
- case FAC_OPVAL_CONF_PDISC:
- r = "partyDISC";
- break;
- case FAC_OPVAL_CONF_FCONF:
- r = "floatConf";
- break;
- case FAC_OPVAL_CONF_END:
- r = "endConf";
- break;
- case FAC_OPVAL_CONF_IDCFE:
- r = "indentifyConferee";
- break;
- case FAC_OPVAL_REVC_REQ:
- r = "requestREV";
- break;
- default:
- sprintf(buffer, "unknown operation value %d!", val);
- r = buffer;
- }
- return(r);
-}
-
-/*---------------------------------------------------------------------------*
- * billing id string
- *---------------------------------------------------------------------------*/
-static char *bid_str(int val)
-{
- static char buffer[80];
- char *r;
-
- switch(val)
- {
- case 0:
- r = "normalCharging";
- break;
- case 1:
- r = "reverseCharging";
- break;
- case 2:
- r = "creditCardCharging";
- break;
- case 3:
- r = "callForwardingUnconditional";
- break;
- case 4:
- r = "callForwardingBusy";
- break;
- case 5:
- r = "callForwardingNoReply";
- break;
- case 6:
- r = "callDeflection";
- break;
- case 7:
- r = "callTransfer";
- break;
- default:
- sprintf(buffer, "unknown billing-id value %d!", val);
- r = buffer;
- }
- return(r);
-}
-
-/*---------------------------------------------------------------------------*
- * invoke component
- *---------------------------------------------------------------------------*/
-static void
-F_1_1(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_1, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t invokeComponent\n");
- state = ST_EXP_INV_ID;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return result
- *---------------------------------------------------------------------------*/
-static void
-F_1_2(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_2, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t returnResult\n");
- state = ST_EXP_RR_INV_ID;
- }
-}
-/*---------------------------------------------------------------------------*
- * return error
- *---------------------------------------------------------------------------*/
-static void
-F_1_3(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_3, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t returnError\n");
- state = ST_EXP_NIX;
- }
-}
-/*---------------------------------------------------------------------------*
- * reject
- *---------------------------------------------------------------------------*/
-static void
-F_1_4(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_1_4, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t reject\n");
- state = ST_EXP_NIX;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * invoke component: invoke id
- *---------------------------------------------------------------------------*/
-static void
-F_2(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_2, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t InvokeIdentifier = %d\n", val);
- state = ST_EXP_OP_VAL;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return result: invoke id
- *---------------------------------------------------------------------------*/
-static void
-F_RR2(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RR2, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t InvokeIdentifier = %d\n", val);
- state = ST_EXP_RR_OP_VAL;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * invoke component: operation value
- *---------------------------------------------------------------------------*/
-static void
-F_3(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_3, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t Operation Value = %s (%d)\n", opval_str(val), val);
- state = ST_EXP_INFO;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return result: operation value
- *---------------------------------------------------------------------------*/
-static void
-F_RR3(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RR3, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t Operation Value = %s (%d)\n", opval_str(val), val);
- state = ST_EXP_RR_RESULT;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * return result: RESULT
- *---------------------------------------------------------------------------*/
-static void
-F_RRR(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RRR, val = %d\n", val);
-#endif
- state = ST_EXP_NIX;
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_4(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t specificChargingUnits\n");
- state = ST_EXP_RUL;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_4_1(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4_1, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t freeOfCharge\n");
- state = ST_EXP_NIX;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_4_2(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_4_2, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t chargeNotAvailable\n");
- state = ST_EXP_NIX;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_5(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_5, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t recordedUnitsList [1]\n");
- state = ST_EXP_RU;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_6(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_6, val = %d\n", val);
-#endif
- if(val == -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t RecordedUnits\n");
- state = ST_EXP_RNOU;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_7(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_7, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t NumberOfUnits = %d\n", val);
- state = ST_EXP_TOCI;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_8(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_8, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t typeOfChargingInfo = %s\n", val == 0 ? "subTotal" : "total");
- state = ST_EXP_DBID;
- }
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_9(char *pbuf, int val)
-{
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: exec F_9, val = %d\n", val);
-#endif
- if(val != -1)
- {
- sprintf((pbuf+strlen(pbuf)), "\t AOCDBillingId = %s (%d)\n", bid_str(val), val);
- state = ST_EXP_NIX;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * state table
- *---------------------------------------------------------------------------*/
-static struct statetab {
- int currstate; /* input: current state we are in */
- int form; /* input: current tag form */
- int class; /* input: current tag class */
- int code; /* input: current tag code */
- void (*func)(char *,int); /* output: func to exec */
-} statetab[] = {
-
-/* current state tag form tag class tag code function */
-/* --------------------- ---------------------- ---------------------- ---------------------- ----------------*/
-
-/* invoke */
-
- {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 1, F_1_1 },
- {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 2, F_1_2 },
- {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 3, F_1_3 },
- {ST_EXP_COMP_TYP, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 4, F_1_4 },
- {ST_EXP_INV_ID, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_2 },
- {ST_EXP_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_3 },
- {ST_EXP_INFO, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SEQ, F_4 },
- {ST_EXP_INFO, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_NULL, F_4_1 },
- {ST_EXP_INFO, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 1, F_4_2 },
- {ST_EXP_RUL, FAC_TAGFORM_CON, FAC_TAGCLASS_COS, 1, F_5 },
- {ST_EXP_RU, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SEQ, F_6 },
- {ST_EXP_RNOU, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_7 },
- {ST_EXP_TOCI, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 2, F_8 },
- {ST_EXP_DBID, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 3, F_9 },
-
-/* return result */
-
- {ST_EXP_RR_INV_ID, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RR2 },
- {ST_EXP_RR_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RR3 },
- {ST_EXP_RR_RESULT, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SET, F_RRR },
-
-/* end */
-
- {-1, -1, -1, -1, NULL }
-};
-
-/*---------------------------------------------------------------------------*
- * state decode for do_component
- *---------------------------------------------------------------------------*/
-static void
-next_state(char *pbuf, int class, int form, int code, int val)
-{
- int i;
-
-#ifdef ST_DEBUG
- sprintf((pbuf+strlen(pbuf)), "next_state: class=%d, form=%d, code=%d, val=%d\n", class, form, code, val);
-#endif
-
- for(i=0; ; i++)
- {
- if((statetab[i].currstate > state) ||
- (statetab[i].currstate == -1))
- {
- break;
- }
-
- if((statetab[i].currstate == state) &&
- (statetab[i].form == form) &&
- (statetab[i].class == class) &&
- (statetab[i].code == code))
- {
- (*statetab[i].func)(pbuf, val);
- break;
- }
- }
-}
-
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdntrace/q932_fac.h b/usr.sbin/i4b/isdntrace/q932_fac.h
deleted file mode 100644
index feae4487e6b8..000000000000
--- a/usr.sbin/i4b/isdntrace/q932_fac.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * q932_fac.h - facility header file
- * ---------------------------------
- *
- * $Id: q932_fac.h,v 1.4 1998/12/05 18:04:24 hm Exp $
- *
- * last edit-date: [Sat Dec 5 18:21:17 1998]
- *
- *---------------------------------------------------------------------------
- *
- * - Q.932 (03/93) Generic Procedures for the Control of
- * ISDN Supplementaty Services
- * - Q.950 (03/93) Supplementary Services Protocols, Structure and
- * General Principles
- * - ETS 300 179 (10/92) Advice Of Charge: charging information during
- * the call (AOC-D) supplementary service Service description
- * - ETS 300 180 (10/92) Advice Of Charge: charging information at the
- * end of call (AOC-E) supplementary service Service description
- * - ETS 300 181 (04/93) Advice Of Charge (AOC) supplementary service
- * Functional capabilities and information flows
- * - ETS 300 182 (04/93) Advice Of Charge (AOC) supplementary service
- * Digital Subscriber Signalling System No. one (DSS1) protocol
- * - X.208 Specification of Abstract Syntax Notation One (ASN.1)
- * - X.209 Specification of Basic Encoding Rules for
- * Abstract Syntax Notation One (ASN.1)
- * - "ASN.1 Abstract Syntax Notation One", Walter Gora, DATACOM-Verlag
- * 1992, 3rd Edition (ISBN 3-89238-062-7) (german !)
- *
- *---------------------------------------------------------------------------*/
-
-/* #define FAC_DEBUG */
-/* #define ST_DEBUG */
-
-/* protocols */
-#define FAC_PROTO_ROP 0x11
-#define FAC_PROTO_CMIP 0x12
-#define FAC_PROTO_ACSE 0x13
-
-/* tag classes */
-#define FAC_TAGCLASS_UNI 0x00
-#define FAC_TAGCLASS_APW 0x01
-#define FAC_TAGCLASS_COS 0x02
-#define FAC_TAGCLASS_PRU 0x03
-
-/* tag forms */
-#define FAC_TAGFORM_PRI 0x00
-#define FAC_TAGFORM_CON 0x01
-
-/* class UNIVERSAL values */
-#define FAC_CODEUNI_BOOL 1
-#define FAC_CODEUNI_INT 2
-#define FAC_CODEUNI_BITS 3
-#define FAC_CODEUNI_OCTS 4
-#define FAC_CODEUNI_NULL 5
-#define FAC_CODEUNI_OBJI 6
-#define FAC_CODEUNI_OBJD 7
-#define FAC_CODEUNI_EXT 8
-#define FAC_CODEUNI_REAL 9
-#define FAC_CODEUNI_ENUM 10
-#define FAC_CODEUNI_R11 11
-#define FAC_CODEUNI_R12 12
-#define FAC_CODEUNI_R13 13
-#define FAC_CODEUNI_R14 14
-#define FAC_CODEUNI_R15 15
-#define FAC_CODEUNI_SEQ 16
-#define FAC_CODEUNI_SET 17
-#define FAC_CODEUNI_NSTR 18
-#define FAC_CODEUNI_PSTR 19
-#define FAC_CODEUNI_TSTR 20
-#define FAC_CODEUNI_VSTR 21
-#define FAC_CODEUNI_ISTR 22
-#define FAC_CODEUNI_UTIME 23
-#define FAC_CODEUNI_GTIME 24
-#define FAC_CODEUNI_GSTR 25
-#define FAC_CODEUNI_VISTR 26
-#define FAC_CODEUNI_GNSTR 27
-
-/* operation values */
-#define FAC_OPVAL_UUS 1
-#define FAC_OPVAL_CUG 2
-#define FAC_OPVAL_MCID 3
-#define FAC_OPVAL_BTPY 4
-#define FAC_OPVAL_ETPY 5
-#define FAC_OPVAL_ECT 6
-
-#define FAC_OPVAL_DIV_ACT 7
-#define FAC_OPVAL_DIV_DEACT 8
-#define FAC_OPVAL_DIV_ACTSN 9
-#define FAC_OPVAL_DIV_DEACTSN 10
-#define FAC_OPVAL_DIV_INTER 11
-#define FAC_OPVAL_DIV_INFO 12
-#define FAC_OPVAL_DIV_CALLDEF 13
-#define FAC_OPVAL_DIV_CALLRER 14
-#define FAC_OPVAL_DIV_LINF2 15
-#define FAC_OPVAL_DIV_INVS 16
-#define FAC_OPVAL_DIV_INTER1 17
-#define FAC_OPVAL_DIV_LINF1 18
-#define FAC_OPVAL_DIV_LINF3 19
-
-#define FAC_OPVAL_ER_CRCO 20
-#define FAC_OPVAL_ER_MGMT 21
-#define FAC_OPVAL_ER_CANC 22
-
-#define FAC_OPVAL_MLPP_QUERY 24
-#define FAC_OPVAL_MLPP_CALLR 25
-#define FAC_OPVAL_MLPP_CALLP 26
-
-#define FAC_OPVAL_AOC_REQ 30
-#define FAC_OPVAL_AOC_S_CUR 31
-#define FAC_OPVAL_AOC_S_SPC 32
-#define FAC_OPVAL_AOC_D_CUR 33
-#define FAC_OPVAL_AOC_D_UNIT 34
-#define FAC_OPVAL_AOC_E_CUR 35
-#define FAC_OPVAL_AOC_E_UNIT 36
-#define FAC_OPVAL_AOC_IDOFCRG 37
-
-#define FAC_OPVAL_CONF_BEG 40
-#define FAC_OPVAL_CONF_ADD 41
-#define FAC_OPVAL_CONF_SPLIT 42
-#define FAC_OPVAL_CONF_DROP 43
-#define FAC_OPVAL_CONF_ISOLATE 44
-#define FAC_OPVAL_CONF_REATT 45
-#define FAC_OPVAL_CONF_PDISC 46
-#define FAC_OPVAL_CONF_FCONF 47
-#define FAC_OPVAL_CONF_END 48
-#define FAC_OPVAL_CONF_IDCFE 49
-
-#define FAC_OPVAL_REVC_REQ 60
-
-enum states {
- ST_EXP_COMP_TYP,
- ST_EXP_INV_ID,
- ST_EXP_OP_VAL,
- ST_EXP_INFO,
- ST_EXP_RUL,
- ST_EXP_RU,
- ST_EXP_RNOU,
- ST_EXP_TOCI,
- ST_EXP_DBID,
-
- ST_EXP_RR_INV_ID,
- ST_EXP_RR_OP_VAL,
- ST_EXP_RR_RESULT,
-
- ST_EXP_NIX
-};
-
-/* EOF */
-
diff --git a/usr.sbin/i4b/isdntrace/trace.c b/usr.sbin/i4b/isdntrace/trace.c
deleted file mode 100644
index a9dde80108c8..000000000000
--- a/usr.sbin/i4b/isdntrace/trace.c
+++ /dev/null
@@ -1,809 +0,0 @@
-/*
- * Copyright (c) 1996, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Copyright (c) 1996 Gary Jennejohn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * 4. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software and/or documentation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------*
- *
- * trace.c - print traces of D (B) channel activity for isdn4bsd
- * -------------------------------------------------------------
- *
- * $Id: trace.c,v 1.10 1998/10/19 12:32:21 hm Exp $
- *
- * last edit-date: [Mon Oct 19 14:30:58 1998]
- *
- * -hm rewriting for isic and new trace format
- * -hm new option -f, use automatic name for -o
- * -hm changed default option setting
- * -hm multi unit support
- * -hm analyzer functionality
- * -hm binary record/playback
- * -hm -p option
- * -hm cleanup
- * -hm adding date to timestamp field
- * -hm reopen files on SIGUSR1 for rotation
- * -hm Joerg reported a bug with commandline options
- * -hm I.430 INFO signals from layer 1
- *
- *---------------------------------------------------------------------------*/
-
-#include "trace.h"
-
-unsigned char buf[BSIZE];
-FILE *Fout = NULL;
-FILE *BP = NULL;
-int outflag = 1;
-int header = 1;
-int print_q921 = 1;
-int unit = 0;
-int dchan = 0;
-int bchan = 0;
-int traceon = 0;
-int analyze = 0;
-int Rx = RxUDEF;
-int Tx = TxUDEF;
-int f;
-int Bopt = 0;
-int Popt = 0;
-int bpopt = 0;
-int info = 0;
-int Fopt = 0;
-
-static char outfilename[1024];
-static char BPfilename[1024];
-static struct stat fst;
-
-static void dumpbuf( int n, unsigned char *buf, i4b_trace_hdr_t *hdr, int raw );
-static int switch_driver( int value, int rx, int tx );
-static void usage( void );
-static void exit_hdl( void );
-static void reopenfiles( int );
-
-/*---------------------------------------------------------------------------*
- * usage instructions
- *---------------------------------------------------------------------------*/
-void
-usage(void)
-{
- fprintf(stderr,"\n");
- fprintf(stderr,"isdntrace - i4b package ISDN trace facility for passive cards (%02d.%02d.%d)\n", VERSION, REL, STEP);
- fprintf(stderr,"usage: isdntrace -a -b -d -f <file> -h -i -l -n <val> -o -p <file> -r -u <unit>\n");
- fprintf(stderr," -B -F -P -R <unit> -T <unit>\n");
- fprintf(stderr," -a analyzer mode ................................... (default off)\n");
- fprintf(stderr," -b switch B channel trace on ....................... (default off)\n");
- fprintf(stderr," -d switch D channel trace off ....................... (default on)\n");
- fprintf(stderr," -f <file> write output to file filename ............ (default %s0)\n", TRACE_FILE_NAME);
- fprintf(stderr," -h don't print header for each message ............. (default off)\n");
- fprintf(stderr," -i print I.430 (layer 1) INFO signals .............. (default off)\n");
- fprintf(stderr," -l don't decode low layer Q.921 messages ........... (default off)\n");
- fprintf(stderr," -n <val> process packet if it is longer than <val> octetts . (default 0)\n");
- fprintf(stderr," -o don't write output to a file .................... (default off)\n");
- fprintf(stderr," -p <file> specify filename for -B and -P ........ (default %s0)\n", BIN_FILE_NAME);
- fprintf(stderr," -r don't print raw hex/ASCII dump of protocol ...... (default off)\n");
- fprintf(stderr," -u <unit> specify controller unit number ............... (default unit 0)\n");
- fprintf(stderr," -B write binary trace data to file filename ........ (default off)\n");
- fprintf(stderr," -F with -P and -p: wait for more data at EOF ....... (default off)\n");
- fprintf(stderr," -P playback from binary trace data file ............ (default off)\n");
- fprintf(stderr," -R <unit> analyze Rx controller unit number (for -a) ... (default unit %d)\n", RxUDEF);
- fprintf(stderr," -T <unit> analyze Tx controller unit number (for -a) ... (default unit %d)\n", TxUDEF);
- fprintf(stderr,"\n");
- exit(1);
-}
-
-/*---------------------------------------------------------------------------*
- * main
- *---------------------------------------------------------------------------*/
-int
-main(int argc, char *argv[])
-{
- extern int optind;
- extern int opterr;
- extern char *optarg;
- char devicename[80];
- char headerbuf[256];
-
- int n;
- int c;
- char *b;
-
- int enable_trace = TRACE_D_RX | TRACE_D_TX;
- char *outfile = TRACE_FILE_NAME;
- char *binfile = BIN_FILE_NAME;
- int outfileset = 0;
- int raw = 1;
- int noct = -1;
- time_t tm;
- i4b_trace_hdr_t *ithp = NULL;
- int l;
- static struct stat fstnew;
-
- b = &buf[sizeof(i4b_trace_hdr_t)];
-
- while( (c = getopt(argc, argv, "abdf:hiln:op:ru:BFPR:T:?")) != EOF)
- {
- switch(c)
- {
- case 'a':
- analyze = 1;
- break;
-
- case 'b':
- enable_trace |= (TRACE_B_RX | TRACE_B_TX);
- break;
-
- case 'd':
- enable_trace &= (~(TRACE_D_TX | TRACE_D_RX));
- break;
-
- case 'o':
- outflag = 0;
- break;
-
- case 'f':
- outfile = optarg;
- outfileset = 1;
- break;
-
- case 'n':
- noct = atoi(optarg);
- break;
-
- case 'h':
- header = 0;
- break;
-
- case 'i':
- enable_trace |= TRACE_I;
- info = 1;
- break;
-
- case 'l':
- print_q921 = 0;
- break;
-
- case 'p':
- binfile = optarg;
- bpopt = 1;
- break;
-
- case 'r':
- raw = 0;
- break;
-
- case 'u':
- unit = atoi(optarg);
- if(unit < 0 || unit >= MAX_CONTROLLERS)
- usage();
- break;
-
- case 'B':
- Bopt = 1;
- break;
-
- case 'F':
- Fopt = 1;
- break;
-
- case 'P':
- Popt = 1;
- break;
-
- case 'R':
- Rx = atoi(optarg);
- if(Rx < 0 || Rx >= MAX_CONTROLLERS)
- usage();
- break;
-
- case 'T':
- Tx = atoi(optarg);
- if(Tx < 0 || Tx >= MAX_CONTROLLERS)
- usage();
- break;
-
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if(enable_trace == 0)
- usage();
-
- if(Bopt && Popt)
- usage();
-
- atexit(exit_hdl);
-
- if(Bopt)
- {
- if(bpopt)
- sprintf(BPfilename, "%s", binfile);
- else
- sprintf(BPfilename, "%s%d", BIN_FILE_NAME, unit);
-
- if((BP = fopen(BPfilename, "r")) != NULL)
- {
- char buffer[1024];
- fclose(BP);
- sprintf(buffer, "%s%s", BPfilename, TRACE_FILE_NAME_BAK);
- rename(BPfilename, buffer);
- }
- if((BP = fopen(BPfilename, "w")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error opening file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
-
- if((setvbuf(BP, (char *)NULL, _IONBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error setting file [%s] to unbuffered", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
-
- if(Popt)
- {
- if(bpopt)
- sprintf(BPfilename, "%s", binfile);
- else
- sprintf(BPfilename, "%s%d", BIN_FILE_NAME, unit);
-
- if((BP = fopen(BPfilename, "r")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error opening file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
- if(Fopt)
- {
- if(fstat(fileno(BP), &fst))
- {
- char buffer[80];
- sprintf(buffer, "Error fstat file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
- }
- else
- {
- sprintf(devicename, "%s%d", I4BTRC_DEVICE, unit);
-
- if((f = open(devicename, O_RDWR)) < 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error opening trace device [%s]", devicename);
- perror(buffer);
- exit(1);
- }
- }
-
- if(outflag)
- {
- if(outfileset == 0)
- sprintf(outfilename, "%s%d", TRACE_FILE_NAME, unit);
- else
- strcpy(outfilename, outfile);
-
-
- if((Fout = fopen(outfilename, "r")) != NULL)
- {
- char buffer[1024];
- fclose(Fout);
- sprintf(buffer, "%s%s", outfilename, TRACE_FILE_NAME_BAK);
- rename(outfilename, buffer);
- }
-
- if((Fout = fopen(outfilename, "w")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error opening file [%s]", outfilename);
- perror(buffer);
- exit(1);
- }
-
- if((setvbuf(Fout, (char *)NULL, _IONBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error setting file [%s] to unbuffered", outfile);
- perror(buffer);
- exit(1);
- }
- }
-
- if((setvbuf(stdout, (char *)NULL, _IOLBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error setting stdout to line-buffered");
- perror(buffer);
- exit(1);
- }
-
- if(!Popt)
- {
- if((switch_driver(enable_trace, Rx, Tx)) == -1)
- exit(1);
- else
- traceon = 1;
- }
-
- signal(SIGHUP, SIG_IGN); /* ignore hangup signal */
- signal(SIGUSR1, reopenfiles); /* rotate logfile(s) */
-
- time(&tm);
-
- if(analyze)
- {
- sprintf(headerbuf, "\n==== isdnanalyze controller rx #%d - tx #%d ==== started %s",
- Rx, Tx, ctime(&tm));
- }
- else
- {
- sprintf(headerbuf, "\n=========== isdntrace controller #%d =========== started %s",
- unit, ctime(&tm));
- }
-
- printf("%s", headerbuf);
-
- if(outflag)
- fprintf(Fout, "%s", headerbuf);
-
- for (;;)
- {
- if(Popt == 0)
- {
- n = read(f, buf, BSIZE);
-
- if(Bopt)
- {
- if((fwrite(buf, 1, n, BP)) != n)
- {
- char buffer[80];
- sprintf(buffer, "Error writing file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
-
- n -= sizeof(i4b_trace_hdr_t);
- }
- else
- {
-again:
- if((fread(buf, 1, sizeof(i4b_trace_hdr_t), BP)) != sizeof(i4b_trace_hdr_t))
- {
- if(feof(BP))
- {
- if(Fopt)
- {
- if(ferror(BP))
- {
- char buffer[80];
- sprintf(buffer, "Error reading hdr from file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
-
- usleep(250000);
- clearerr(BP);
-
- if(stat(BPfilename, &fstnew) != -1)
- {
- if((fst.st_ino != fstnew.st_ino) ||
- (fstnew.st_nlink == 0))
- {
- if((BP = freopen(BPfilename, "r", BP)) == NULL)
- {
- char buffer[80];
- sprintf(buffer, "Error reopening file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
- stat(BPfilename, &fst);
- }
- }
- goto again;
- }
- else
- {
- printf("\nEnd of playback input file reached.\n");
- exit(0);
- }
- }
- else
- {
- char buffer[80];
- sprintf(buffer, "Error reading hdr from file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
-
- ithp = (i4b_trace_hdr_t *)buf;
- l = ithp->length - sizeof(i4b_trace_hdr_t);
-
- if((n = fread(buf+sizeof(i4b_trace_hdr_t), 1, l , BP)) != l)
- {
- char buffer[80];
- sprintf(buffer, "Error reading data from file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
-
- }
-
- if((n > 0) && (n > noct))
- {
- dumpbuf(n, b, (i4b_trace_hdr_t *)buf, raw);
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * format header into static buffer, return buffer address
- *---------------------------------------------------------------------------*/
-char *
-fmt_hdr(i4b_trace_hdr_t *hdr, int frm_len)
-{
- struct tm *s;
- static char hbuf[256];
- int i = 0;
-
- s = localtime(&(hdr->time.tv_sec));
-
- if(hdr->type == TRC_CH_I) /* Layer 1 INFO's */
- {
- sprintf(hbuf,"\n-- %s - unit:%d ---------------- time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%6u ",
- ((hdr->dir) ? "NT->TE" : "TE->NT"),
- hdr->unit,
- s->tm_mday,
- s->tm_mon + 1,
- s->tm_hour,
- s->tm_min,
- s->tm_sec,
- (u_int32_t)hdr->time.tv_usec);
- }
- else
- {
- if(hdr->trunc > 0)
- {
- sprintf(hbuf,"\n-- %s - unit:%d - frame:%6.6u - time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%6u - length:%d (%d) ",
- ((hdr->dir) ? "NT->TE" : "TE->NT"),
- hdr->unit,
- hdr->count,
- s->tm_mday,
- s->tm_mon + 1,
- s->tm_hour,
- s->tm_min,
- s->tm_sec,
- (u_int32_t)hdr->time.tv_usec,
- frm_len,
- hdr->trunc);
- }
- else
- {
- sprintf(hbuf,"\n-- %s - unit:%d - frame:%6.6u - time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%6u - length:%d ",
- ((hdr->dir) ? "NT->TE" : "TE->NT"),
- hdr->unit,
- hdr->count,
- s->tm_mday,
- s->tm_mon + 1,
- s->tm_hour,
- s->tm_min,
- s->tm_sec,
- (u_int32_t)hdr->time.tv_usec,
- frm_len);
- }
- }
-
- for(i=strlen(hbuf); i <= NCOLS;)
- hbuf[i++] = '-';
-
- hbuf[i++] = '\n';
- hbuf[i] = '\0';
-
- return(hbuf);
-}
-
-/*---------------------------------------------------------------------------*
- * decode protocol and output to file(s)
- *---------------------------------------------------------------------------*/
-static void
-dumpbuf(int n, unsigned char *buf, i4b_trace_hdr_t *hdr, int raw)
-{
- static char l1buf[128];
- static unsigned char l2buf[32000];
- static unsigned char l3buf[32000];
- int cnt;
- int nsave = n;
- char *pbuf;
- int i, j;
-
- l1buf[0] = '\0';
- l2buf[0] = '\0';
- l3buf[0] = '\0';
-
- switch(hdr->type)
- {
- case TRC_CH_I: /* Layer 1 INFO's */
- pbuf = &l1buf[0];
-
- switch(buf[0])
- {
- case INFO0:
- sprintf((pbuf+strlen(pbuf)),"I430: INFO0 (No Signal)\n");
- break;
-
- case INFO1_8:
- sprintf((pbuf+strlen(pbuf)),"I430: INFO1 (Activation Request, Priority = 8, from TE)\n");
- break;
-
- case INFO1_10:
- sprintf((pbuf+strlen(pbuf)),"I430: INFO1 (Activation Request, Priority = 10, from TE)\n");
- break;
-
- case INFO2:
- sprintf((pbuf+strlen(pbuf)),"I430: INFO2 (Pending Activation, from NT)\n");
- break;
-
- case INFO3:
- sprintf((pbuf+strlen(pbuf)),"I430: INFO3 (Synchronized, from TE)\n");
- break;
-
- case INFO4_8:
- sprintf((pbuf+strlen(pbuf)),"I430: INFO4 (Activated, Priority = 8/9, from NT)\n");
- break;
-
- case INFO4_10:
- sprintf((pbuf+strlen(pbuf)),"I430: INFO4 (Activated, Priority = 10/11, from NT)\n");
- break;
-
- default:
- sprintf((pbuf+strlen(pbuf)),"I430: ERROR, invalid INFO value 0x%x!\n", buf[0]);
- break;
- }
- break;
-
- case TRC_CH_D: /* D-channel data */
-
- cnt = decode_lapd(l2buf, n, buf, hdr->dir, raw, print_q921);
-
- n -= cnt;
- buf += cnt;
-
- if(n)
- {
- switch(*buf)
- {
- case 0x40:
- case 0x41:
- decode_1tr6(l3buf, n, cnt, buf, raw);
- break;
-
- default:
- decode_q931(l3buf, n, cnt, buf, raw);
- break;
- }
- }
- break;
-
- default: /* B-channel data */
-
- pbuf = &l2buf[0];
-
- for (i = 0; i < n; i += 16)
- {
- sprintf((pbuf+strlen(pbuf)),"B%d:%.3x ", hdr->type, i);
-
- for (j = 0; j < 16; j++)
- if (i + j < n)
- sprintf((pbuf+strlen(pbuf)),"%02x ", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf))," ");
-
- sprintf((pbuf+strlen(pbuf))," ");
-
- for (j = 0; j < 16 && i + j < n; j++)
- if (isprint(buf[i + j]))
- sprintf((pbuf+strlen(pbuf)),"%c", buf[i + j]);
- else
- sprintf((pbuf+strlen(pbuf)),".");
-
- sprintf((pbuf+strlen(pbuf)),"\n");
- }
- break;
- }
-
- if(header && ((l1buf[0] != '\0' || l2buf[0] != '\0') || (l3buf[0] != 0)))
- {
- char *p;
- p = fmt_hdr(hdr, nsave);
- printf("%s", p);
- if(outflag)
- fprintf(Fout, "%s", p);
- }
-
- if(l1buf[0] != '\0')
- {
- printf("%s", l1buf);
- if(outflag)
- fprintf(Fout, "%s", l1buf);
- }
-
- if(l2buf[0] != '\0')
- {
- printf("%s", l2buf);
- if(outflag)
- fprintf(Fout, "%s", l2buf);
- }
-
- if(l3buf[0] != '\0')
- {
- printf("%s", l3buf);
- if(outflag)
- fprintf(Fout, "%s", l3buf);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * exit handler function to be called at program exit
- *---------------------------------------------------------------------------*/
-void
-exit_hdl()
-{
- if(traceon)
- switch_driver(TRACE_OFF, Rx, Tx);
-}
-
-/*---------------------------------------------------------------------------*
- * switch driver debugging output on/off
- *---------------------------------------------------------------------------*/
-static int
-switch_driver(int value, int rx, int tx)
-{
- char buffer[80];
- int v = value;
-
- if(analyze == 0)
- {
- if(ioctl(f, I4B_TRC_SET, &v) < 0)
- {
- sprintf(buffer, "Error ioctl I4B_TRC_SET, val = %d", v);
- perror(buffer);
- return(-1);
- }
- }
- else
- {
- if(value == TRACE_OFF)
- {
- if(ioctl(f, I4B_TRC_RESETA, &v) < 0)
- {
- sprintf(buffer, "Error ioctl I4B_TRC_RESETA - ");
- perror(buffer);
- return(-1);
- }
- }
- else
- {
- i4b_trace_setupa_t tsa;
-
- tsa.rxunit = rx;
- tsa.rxflags = value;
- tsa.txunit = tx;
- tsa.txflags = value;
-
- if(ioctl(f, I4B_TRC_SETA, &tsa) < 0)
- {
- sprintf(buffer, "Error ioctl I4B_TRC_SETA, val = %d", v);
- perror(buffer);
- return(-1);
- }
- }
- }
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * reopen files to support rotating logfile(s) on SIGUSR1
- *
- * based on an idea from Ripley (ripley@nostromo.in-berlin.de)
- *
- * close file and reopen it for append. this will be a nop
- * if the previously opened file hasn't moved but will open
- * a new one otherwise, thus enabling a rotation...
- *
- *---------------------------------------------------------------------------*/
-static void
-reopenfiles(int dummy)
-{
- if(outflag)
- {
- fclose(Fout);
-
- if((Fout = fopen(outfilename, "a")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error re-opening file [%s]", outfilename);
- perror(buffer);
- exit(1);
- }
-
- if((setvbuf(Fout, (char *)NULL, _IONBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error re-setting file [%s] to unbuffered", outfilename);
- perror(buffer);
- exit(1);
- }
- }
-
- if(Bopt)
- {
-
- fclose(BP);
-
- if((BP = fopen(BPfilename, "a")) == NULL)
- {
- char buffer[80];
-
- sprintf(buffer, "Error re-opening file [%s]", BPfilename);
- perror(buffer);
- exit(1);
- }
-
- if((setvbuf(BP, (char *)NULL, _IONBF, 0)) != 0)
- {
- char buffer[80];
-
- sprintf(buffer, "Error re-setting file [%s] to unbuffered", BPfilename);
- perror(buffer);
- exit(1);
- }
- }
-}
-
-
-/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/trace.h b/usr.sbin/i4b/isdntrace/trace.h
deleted file mode 100644
index e4c5b5a76c20..000000000000
--- a/usr.sbin/i4b/isdntrace/trace.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 1996, 1998 Hellmuth Michaelis. All rights reserved.
- *
- * Copyright (c) 1996 Gary Jennejohn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * 4. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software and/or documentation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- * trace.h - header file for isdn trace
- * ------------------------------------
- *
- * $Id: trace.h,v 1.7 1998/10/19 12:32:23 hm Exp $
- *
- * last edit-date: [Mon Oct 19 14:27:21 1998]
- *
- * -hm splitting
- * -hm new filenames
- *
- *---------------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include "pcause_1tr6.h" /* obsolete german national ISDN */
-#include "pcause_q850.h"
-
-#define I4BTRC_DEVICE "/dev/i4btrc" /* trace device file */
-#define TRACE_FILE_NAME "isdntrace" /* default output filename */
-#define TRACE_FILE_NAME_BAK ".last" /* backup filename trailer */
-#define BIN_FILE_NAME "isdntracebin" /* default binary filename */
-
-#define BSIZE 4096 /* read buffer size */
-#define NCOLS 80 /* screen width */
-
-#define RxUDEF 0 /* analyze mode, default unit for receiver side */
-#define TxUDEF 1 /* analyze mode, default unit for transmitter side */
-
-int decode_lapd(char *pbuf, int n, unsigned char *buf, int is_te, int raw, int printit);
-void decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw);
-void decode_1tr6(char *pbuf, int n, int off, unsigned char *buf, int raw);
-char *print_error(int prot, unsigned char code);
-int q931_facility(char *pbuf, unsigned char *buf);
-int p_q931cause(char *pbuf, unsigned char *buf);
-int p_q931address(char *pbuf, unsigned char *buf);
-int p_q931bc(char *pbuf, unsigned char *buf);
-int p_q931high_compat(char *pbuf, unsigned char *buf);
-int q932_facility(char *pbuf, unsigned char *buf);
-
-/* EOF */
diff --git a/usr.sbin/i4b/man/Makefile b/usr.sbin/i4b/man/Makefile
deleted file mode 100644
index 65248d6dd26b..000000000000
--- a/usr.sbin/i4b/man/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-MAN4 = i4b.4 i4bctl.4 i4bipr.4 i4bq921.4 i4bq931.4 i4brbch.4 i4btel.4 \
- i4btrc.4 isic.4 daic.4 i4bisppp.4
-
-.include <bsd.prog.mk>
-
diff --git a/usr.sbin/i4b/man/daic.4 b/usr.sbin/i4b/man/daic.4
deleted file mode 100644
index fc0479750d86..000000000000
--- a/usr.sbin/i4b/man/daic.4
+++ /dev/null
@@ -1,98 +0,0 @@
-.\" Copyright (c) 1997 Martin Husemann <martin@rumolt.teuto.de>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. The name of the author may not be used to endorse or promote products
-.\" derived from this software withough specific prior written permission
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $Id: daic.4,v 1.1 1998/02/03 12:43:07 hm Exp $
-.\"
-.\" last edit-date: [Fri Jan 30 22:49:48 1998]
-.\"
-.\" -mh writing manual pages
-.\"
-.\"
-.Dd January 30, 1998
-.Dt daic 4
-.Sh NAME
-.Nm daic
-.Nd isdn4bsd driver for EICON.Diehl active isdn cards
-.Pp
-The
-.Nm
-driver supports the old Diehl active cards:
-.Em S, SX, SXn, SCOM
-and
-.Em QUADRO.
-.Sh SYNOPSIS
-.Pp
-Use a config line like this
-.Cd "daic0 at isa? iomem 0xd8000 irq 10"
-.Pp
-For a
-.Em QUADRO
-card use the same, the driver will detect the board type and use
-all four ports, each attached as a controller of its own to the
-ISDN4BSD system, which can be listed using the isdnctl utility.
-.Sh DESCRIPTION
-The
-.Nm
-driver interfaces the isdn card to the ISDN4BSD kernel subsystem.
-All lower layer isdn control is handled by the card. This should
-allow you to run any national isdn protocol delivered by EICON.Diehl
-for your card, but the driver has only been tested with the DSS1
-protocol and some parts of the cards interface are isdn protocol
-dependend.
-.Pp
-The
-.Nm
-driver is written to conform to the software interface documented
-by Diehl in their
-.Nm ISDN-Karten Benutzerhandbuch
-from 1992.
-.Sh MICROCODE DOWNLOAD
-Every active card needs its own operating software before it can
-work. You have to download this to the card before using it with
-ISDN4BSD. Use the isdnctl utility to do this, i.e. call
-.Nm "isdnctl -d te_etsi.sx 1"
-to download the file
-.Nm te_etsi.sx
-to controller number 1. Use
-.Nm "isdnctl -l"
-to list all available controllers (and ports). You have to select the
-correct isdn protocol file for your isdn interface, see the Diehl documentation
-for details.
-.Pp
-The cards bootstrap process involves another file, which is independend
-of the card type you use and the protocol you run. It is called
-.Nm download.bin
-in current versions of the Diehl software distribution and has to be
-copied to the kernel compile directory under
-.Nm dev/ic/microcode/daic
-and converted into a header file used when compiling the kernel by running
-.Nm make
-in that directory. Your kernel compile will fail and remind you of this
-if you forget to do this. Due to copright restrictions we cannot distribute
-the driver with this file integrated. But if you own a card, you do have
-the file (or can get it from the Diehl web server).
-.Sh BUGS
-The driver is not yet finished. It will only compile on NetBSD and
-even there will not work. This should be fixed soon and the driver
-will be ported to FreeBSD.
-.Sh SEE ALSO
-.Xr isdnctl 1
diff --git a/usr.sbin/i4b/man/i4b.4 b/usr.sbin/i4b/man/i4b.4
deleted file mode 100644
index f285c08fa5fc..000000000000
--- a/usr.sbin/i4b/man/i4b.4
+++ /dev/null
@@ -1,108 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4b.4,v 1.6 1998/12/05 18:06:03 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:38:11 1998]
-.\"
-.Dd February 3, 1998
-.Dt i4b 4
-.Sh NAME
-.Nm i4b
-.Nd isdn4bsd call control ISDN driver
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4b\&"
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-The
-.Nm
-device driver is used by the
-.Xr isdnd 8
-daemon to exchange messages with the isdn4bsd kernel part for the purpose
-of call establishment, control and disconnection and to access various
-control and status informations.
-.Pp
-The messages and message parameters are documented in the include
-file
-.Em /usr/include/machine/i4b_ioctl.h .
-.Pp
-The available ioctl's are:
-.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It Ar I4B_CDID_REQ
-Request a unique Call Description IDentifier (cdid) which identifies
-uniquely a single interaction of the local D channel with the exchange.
-.It Ar I4B_CONNECT_REQ
-Actively request a call setup to a remote ISDN subscriber.
-.It Ar I4B_CONNECT_RESP
-Respond to an incoming call, either accept, reject or ignore it.
-.It Ar I4B_DISCONNECT_REQ
-Actively terminate a connection.
-.It Ar I4B_CTRL_INFO_REQ
-Request information about an installed ISDN controller card.
-.It Ar I4B_DIALOUT_RESP
-Give information about call setup to driver who requested dialing out.
-.It Ar I4B_TIMEOUT_UPD
-Update the kernels timeout value(s) in case of dynamically calculated
-shorthold mode timing changes.
-.It Ar I4B_UPDOWN_IND
-Inform the kernel userland drivers about interface soft up/down status
-changes.
-.It Ar I4B_CTRL_DOWNLOAD
-Download firmware to active card(s).
-.It Ar I4B_ACTIVE_DIAGNOSTIC
-Return diagnostic information from active cards.
-.El
-.Pp
-Status and event messages available from the kernel are:
-.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It Ar MSG_CONNECT_IND
-An incoming call from a remote ISDN user is indicated.
-.It Ar MSG_CONNECT_ACTIVE_IND
-After an incoming call has been accepted locally or an outgoing call has
-been accepted by a remote, the exchange signaled an active connection
-and the corresponding B-channel is switched through.
-.It Ar MSG_DISCONNECT_IND
-A call was terminated.
-.It Ar MSG_DIALOUT_IND
-A userland interface driver requests the daemon to dial out (typically a
-network interface when a packet arrives in its send queue).
-.It Ar MSG_IDLE_TIMEOUT_IND
-A call was terminated by the isdn4bsd kernel driver because a B-channel
-idle timeout occurred.
-.It Ar MSG_ACCT_IND
-Accounting information from a network driver.
-.It Ar MSG_CHARGING_IND
-Charging information from the kernel.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr isdnd 8
-.Sh AUTHOR
-The
-.Nm
-device driver and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/i4bctl.4 b/usr.sbin/i4b/man/i4bctl.4
deleted file mode 100644
index fa5fccd4fc86..000000000000
--- a/usr.sbin/i4b/man/i4bctl.4
+++ /dev/null
@@ -1,50 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4bctl.4,v 1.4 1998/12/05 18:06:04 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:38:22 1998]
-.\"
-.Dd February 3, 1998
-.Dt i4bctl 4
-.Sh NAME
-.Nm i4bctl
-.Nd control device for the isdn4bsd kernel part
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4bctl\&"
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-.Nm
-is used by the
-.Xr isdndebug 8
-utility to get and set the current debugging level and other information
-of the isdn4bsd package kernel ISDN handling layers.
-.Sh SEE ALSO
-.Xr isdndebug 8
-.Sh AUTHOR
-The
-.Nm
-device driver and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/i4bipr.4 b/usr.sbin/i4b/man/i4bipr.4
deleted file mode 100644
index f4cdeacff5c3..000000000000
--- a/usr.sbin/i4b/man/i4bipr.4
+++ /dev/null
@@ -1,98 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4bipr.4,v 1.8 1998/12/05 18:06:06 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:38:34 1998]
-.\"
-.Dd July 6, 1998
-.Dt i4bipr 4
-.Sh NAME
-.Nm i4bipr
-.Nd isdn4bsd IP over ISDN B-channel network driver
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4bipr\&" Op count
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-The
-.Nm
-driver interfaces the IP subsystem of the operating system with the
-isdn4bsd package so that transport of IP packets over an ISDN link
-is possible.
-.Pp
-The driver just packs IP packets without anything appended or prepended
-into raw HDLC packets on the B channel and transfers them to a remote site.
-IP packets received from the remote site are queued into the local IP
-protocol stack.
-.Pp
-The format of the resulting packet on the B channel is:
-.Pp
-.Dl (HDLC opening flag) (IP-packet) (CRC) (HDLC closing flag)
-.Pp
-In the case where an IP packet for a remote site arrives in the driver and no
-connection has been established yet, the driver communicates with the
-.Xr isdnd 8
-daemon to establish a connection.
-.Pp
-The driver has support for interfacing to the
-.Xr bpf 4
-subsystem for using
-.Xr tcpdump 1
-with the
-.Nm ipr
-interfaces.
-.Pp
-The driver optionally (when compiled with the IPR_VJ option) provides Van
-Jacobsen header compression, under control of the link0 and link1 options to
-.Xr ifconfig 8
-:
-.Pp
-.Bl -tag -width 15n -offset indent -compact
-.It link0
-Apply VJ compression to outgoing packets on this interface, and assume that
-incoming packets require decompression.
-.It link1
-Check incoming packets for Van Jacobsen compression; if they appear to be
-compressed, automatically set link0.
-.El
-.Pp
-The default values are
-.Em on
-for
-.Em link1
-and
-.Em off
-for
-.Em link0 .
-.Sh SEE ALSO
-.Xr isdnd 8
-.Xr isdnd.rc 5
-.Xr bpf 4
-.Xr tcpdump 1
-.Sh AUTHOR
-The
-.Nm
-device driver and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/i4bisppp.4 b/usr.sbin/i4b/man/i4bisppp.4
deleted file mode 100644
index ce65b823378b..000000000000
--- a/usr.sbin/i4b/man/i4bisppp.4
+++ /dev/null
@@ -1,107 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4bisppp.4,v 1.9 1998/12/22 19:16:57 hm Exp $
-.\"
-.\" last edit-date: [Tue Dec 22 20:15:08 1998]
-.\"
-.Dd December 22, 1998
-.Dt i4bisppp 4
-.Sh NAME
-.Nm i4bisppp
-.Nd isdn4bsd synchronous PPP over ISDN B-channel network driver
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4bisppp\&" Op count
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-The
-.Nm
-driver interfaces the IP subsystem of the operating system with the
-isdn4bsd package so that a transport of IP packets over an ISDN link
-is possible.
-.Pp
-The driver is just a glue layer between Serge Vakulenko's sppp
-backend and the ISDN4BSD package.
-.Pp
-In case an IP packet for a remote side arrives in the driver and no
-connection is established yet, the driver communicates with the
-.Xr isdnd 8
-daemon to establish a connection.
-.Pp
-The driver has support for interfacing to the
-.Xr bpf 4
-subsystem for using
-.Xr tcpdump 1
-with the
-.Nm isp
-interfaces.
-.Pp
-The
-.Xr spppcontrol 8
-utility is used to configure all aspects of PPP required to connect to a
-remote site.
-.Sh LINK0 and LINK1
-The
-.Em link0
-and
-.Em link1
-flags given as parameters to
-.Xr ifconfig 8
-have the following meaning for the
-.Nm isp
-devices:
-.Bl -tag -width link0 -compact
-.Pp
-.It Li link0
-wait passively for connection
-.Pp
-.It Li link1
-auto-dial on output
-.El
-.Pp
-The
-.Em link0
-and
-.Em link1
-flags are set to
-.Em off
-by default.
-.Pp
-See
-.Xr sppp 4
-for a more detailed discussion of the flags,
-.Pp
-.Sh SEE ALSO
-.Xr isdnd 8
-.Xr isdnd.rc 5
-.Xr spppcontrol 8
-.Xr sppp 4
-.Xr bpf 4
-.Xr tcpdump 1
-.Sh AUTHOR
-The
-.Nm
-device driver was written by Joerg Wunsch and then added to ISDN4BSD by Gary Jennejohn.
-This manpage was written by Hellmuth Michaelis. He can be contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/i4bq921.4 b/usr.sbin/i4b/man/i4bq921.4
deleted file mode 100644
index bb5bcfc5fe27..000000000000
--- a/usr.sbin/i4b/man/i4bq921.4
+++ /dev/null
@@ -1,49 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4bq921.4,v 1.5 1998/12/05 18:06:08 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:38:57 1998]
-.\"
-.Dd February 3, 1998
-.Dt i4bq921 4
-.Sh NAME
-.Nm i4bq921
-.Nd isdn4bsd pseudo device driver handling the Q.921 protocol
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4bq921\&"
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-.Nm
-is the ISDN D channel layer 2 handler.
-.Sh STANDARDS
-ITU Recommendation Q.920 and Q.921
-.Sh SEE ALSO
-.Xr i4bq931 4
-.Sh AUTHOR
-The
-.Nm
-driver and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/i4bq931.4 b/usr.sbin/i4b/man/i4bq931.4
deleted file mode 100644
index 7c8d155fa035..000000000000
--- a/usr.sbin/i4b/man/i4bq931.4
+++ /dev/null
@@ -1,49 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4bq931.4,v 1.5 1998/12/05 18:06:10 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:39:08 1998]
-.\"
-.Dd February 3, 1998
-.Dt i4bq931 4
-.Sh NAME
-.Nm i4bq931
-.Nd isdn4bsd pseudo device driver handling the Q.931 protocol
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4bq931\&"
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-.Nm
-is the ISDN D channel layer 2 handler.
-.Sh STANDARDS
-ITU Recommendation Q.930 and Q.931
-.Sh SEE ALSO
-.Xr i4bq921 4
-.Sh AUTHOR
-The
-.Nm
-driver and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/i4brbch.4 b/usr.sbin/i4b/man/i4brbch.4
deleted file mode 100644
index b7ee3dfc3965..000000000000
--- a/usr.sbin/i4b/man/i4brbch.4
+++ /dev/null
@@ -1,50 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4brbch.4,v 1.5 1998/12/05 18:06:11 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:39:19 1998]
-.\"
-.Dd February 3, 1998
-.Dt i4brbch 4
-.Sh NAME
-.Nm i4brbch
-.Nd isdn4bsd ISDN Raw B-CHannel access driver
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4brbch\&" Op count
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-The
-.Nm
-driver provides an interface to the raw untranslated B-channel. It is
-part of the isdn4bsd package.
-.Sh SEE ALSO
-.Xr isdnd 8
-.Xr isdnd.rc 5
-.Sh AUTHOR
-The
-.Nm
-device driver and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/i4btel.4 b/usr.sbin/i4b/man/i4btel.4
deleted file mode 100644
index e5f62523e44e..000000000000
--- a/usr.sbin/i4b/man/i4btel.4
+++ /dev/null
@@ -1,52 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4btel.4,v 1.5 1998/12/05 18:06:12 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:39:31 1998]
-.\"
-.Dd February 3, 1998
-.Dt i4btel 4
-.Sh NAME
-.Nm i4btel
-.Nd isdn4bsd ISDN B-channel telephony interface driver
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4btel\&" Op count
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-The
-.Nm
-driver provides an interface to the B-channel for telephony applications
-and is currently used by the
-.Xr isdnd 8
-for answering machine support. The driver is part of the isdn4bsd package.
-.Sh SEE ALSO
-.Xr isdnd 8
-.Xr isdnd.rc 5
-.Sh AUTHOR
-The
-.Nm
-device driver and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/i4btrc.4 b/usr.sbin/i4b/man/i4btrc.4
deleted file mode 100644
index 60b88ed971b5..000000000000
--- a/usr.sbin/i4b/man/i4btrc.4
+++ /dev/null
@@ -1,52 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: i4btrc.4,v 1.5 1998/12/05 18:06:13 hm Exp $
-.\"
-.\" last edit-date: [Sat Dec 5 18:39:42 1998]
-.\"
-.Dd February 3, 1998
-.Dt i4btrc 4
-.Sh NAME
-.Nm i4btrc
-.Nd isdn4bsd ISDN interface driver for D and B channel tracing
-.Sh FreeBSD SYNOPSIS
-.Cd pseudo-device \&"i4btrc\&" Op count
-.Sh NetBSD SYNOPSIS
-none
-.Sh DESCRIPTION
-The
-.Nm
-driver is used to add a header to the data got from the D and/or B channel
-and queues it to be read and further processed by the
-.Xr isdntrace 8
-utility.
-.Sh SEE ALSO
-.Xr isdnd 8
-.Xr isdntrace 8
-.Sh AUTHOR
-The
-.Nm
-device driver and this manpage were written by Hellmuth Michaelis. He can be
-contacted at hm@kts.org.
diff --git a/usr.sbin/i4b/man/isic.4 b/usr.sbin/i4b/man/isic.4
deleted file mode 100644
index 0ba54d697a2c..000000000000
--- a/usr.sbin/i4b/man/isic.4
+++ /dev/null
@@ -1,380 +0,0 @@
-.\"
-.\" Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $Id: isic.4,v 1.14 1998/12/22 19:12:13 hm Exp $
-.\"
-.\" last edit-date: [Tue Dec 22 20:08:06 1998]
-.\"
-.Dd December 22, 1998
-.Dt isic 4
-.Sh NAME
-.Nm isic
-.Nd isdn4bsd Siemens ISDN Chipset device driver
-.Sh FreeBSD SYNOPSIS
-.Pp
-For a Teles S0/8 or Niccy 1008 card:
-.Cd options \&"TEL_S0_8\&"
-.Cd "device isic0 at isa? iomem 0xd0000 net irq 5 flags 1 vector isicintr"
-.Pp
-For a Teles S0/16 or Creatix ISDN-S0 or Niccy 1016 card:
-.Cd options \&"TEL_S0_16\&"
-.Cd "device isic0 at isa? port 0xd80 iomem 0xd0000 net irq 5 flags 2 vector isicintr"
-.Pp
-For a Teles S0/16.3 card:
-.Cd options \&"TEL_S0_16_3\&"
-.Cd "device isic0 at isa? port 0xd80 net irq 5 flags 3 vector isicintr"
-.Pp
-For an AVM A1 or AVM Fritz!Card classic:
-.Cd options \&"AVM_A1\&"
-.Cd "device isic0 at isa? port 0x340 net irq 5 flags 4 vector isicintr"
-.Pp
-For an AVM Fritz!Card PCMCIA:
-.Cd options \&"AVM_A1_PCMCIA\&"
-.Cd "device isic0 at isa? port 0x340 net irq 5 flags 10 vector isicintr"
-.Pp
-For a Teles S0/16.3 PnP card (PnP):
-.Cd options \&"TEL_S0_16_3_P\&"
-.Cd "device isic0 at isa? port ? net irq ? vector isicintr"
-.Pp
-For a Creatix ISDN-S0 P&P card (PnP):
-.Cd options \&"CRTX_S0_P\&"
-.Cd "device isic0 at isa? port ? net irq ? vector isicintr"
-.Pp
-For an USRobotics Sportster ISDN TA internal or Stollmann Tina-pp card:
-.Cd options \&"USR_STI\&"
-.Cd "device isic0 at isa? port 0x268 net irq 5 flags 7 vector isicintr"
-.Pp
-For an ITK micro ix1 card:
-.Cd options \&"ITKIX1\&"
-.Cd "device isic0 at isa? port 0x398 net irq 10 flags 18 vector isicintr"
-.Pp
-For a Dr. Neuhaus Niccy Go@ (PnP):
-.Cd options \&"DRN_NGO\&"
-.Cd "device isic0 at isa? port ? net irq ? vector isicintr"
-.Pp
-For a Sedlbauer Win Speed card (PnP):
-.Cd options \&"SEDLBAUER\&"
-.Cd "device isic0 at isa? port ? net irq ? vector isicintr"
-.Pp
-For a Dynalink IS64PH (PnP):
-.Cd options \&"DYNALINK\&"
-.Cd "device isic0 at isa? port ? net irq ? vector isicintr"
-.Pp
-For an ELSA QuickStep 1000pro ISA (PnP):
-.Cd options \&"ELSA_QS1ISA\&"
-.Cd "device isic0 at isa? port ? net irq ? vector isicintr"
-.Pp
-For an ELSA QuickStep 1000pro PCI:
-.Cd options \&"ELSA_QS1PCI\&"
-.Cd "device isic0"
-.Pp
-.Ar FreeBSD PnP configuration:
-.Pp
-To be able to use PnP cards under FreeBSD, you have to add
-.Pp
-.Cd controller pnp0
-.Pp
-to you kernel config file. More, it is recommended to add
-.Pp
-.Cd options \&"USERCONFIG\&"
-.Cd options \&"USERCONFIG_BOOT\&"
-.Pp
-to your kernel config file to be able to adjust your PnP configuration
-in case of trouble.
-.Pp
-See also:
-.Xr pnp 4
-and
-.Xr boot 8
-.Pp
-.Sh NetBSD SYNOPSIS
-On the ISA bus:
-.Pp
-For a Teles S0/8 or Niccy 1008 card:
-.Cd options \&"TEL_S0_8\&"
-.Cd "isic0 at isa? iomem 0xd0000 irq 5"
-.Pp
-For a Teles S0/16 or Creatix ISDN-S0 or Niccy 1016 card:
-.Cd options \&"TEL_S0_16\&"
-.Cd "isic0 at isa? port 0xd80 iomem 0xd0000 irq 5"
-.Pp
-For a Teles S0/16.3 card:
-.Cd options \&"TEL_S0_16_3\&"
-.Cd "isic0 at isa? port 0xd80 irq 5"
-.Pp
-For an AVM A1 or AVM Fritz card:
-.Cd options \&"AVM_A1\&"
-.Cd "isic0 at isa? port 0x340 irq 5"
-.Pp
-For an USRobotics Sportster ISDN TA internal or Stollmann Tina-pp card:
-.Cd options \&"USR_STI\&"
-.Cd "isic0 at isa? port 0x268 irq 5"
-.Pp
-For an ITK ix1 micro card:
-.Cd options \&"ITKIX1\&"
-.Cd "isic0 at isa? port 0x398 irq 10"
-.Pp
-On the ISAPNP bus:
-.Pp
-For a Teles S0/16.3 PnP card
-.Cd options \&"TEL_S0_16_3_P\&"
-.Cd "isic* at isapnp?"
-.Pp
-For a Creatix ISDN-S0 P&P card
-.Cd options \&"CRTX_S0_P\&"
-.Cd "isic* at isapnp?"
-.Pp
-For a Dr. Neuhaus Niccy GO@
-.Cd options \&"DRN_NGO\&"
-.Cd "isic* at isapnp?"
-.Pp
-For an ELSA QuickStep 1000pro (ISA version):
-.Cd options \&"ELSA_QS1ISA\&"
-.Cd "isic* at isapnp?"
-.Pp
-For a Sedlbauer WinSpeed:
-.Cd options \&"SEDLBAUER\&"
-.Cd "isic* at isapnp?"
-.Pp
-For a Dynalink IS64PH:
-.Cd options \&"DYNALINK\&"
-.Cd "isic* at isapnp?"
-.Pp
-Cards on the PCI bus:
-.Pp
-For an ELSA QuickStep 1000pro (PCI version)
-.Cd options \&"ELSA_QS1PCI\&"
-.Cd "isic* at pci?"
-.Pp
-Cards on the PCMCIA or PCCARD bus:
-.Pp
-For an AVM Fritz!Card PCMCIA
-.Cd options \&"AVM_PCMCIA\&"
-.Cd "isic* at pcmcia? function ?"
-.Pp
-For an ELSA MicroLink ISDN/MC
-.Cd options \&"ELSA_ISDNMC\&"
-.Cd "isic* at pcmcia? function ?"
-.Pp
-For an ELSA MicroLink MC/all
-.Cd options \&"ELSA_MCALL\&"
-.Cd "isic* at pcmcia? function ?"
-.Pp
-.Sh DESCRIPTION
-The
-.Nm
-driver provides D-channel layer 1 supports as specified in ITU Recommendation
-I.430 and layer 1 support for the B-channel.
-.Pp
-The driver supports several 8 and 16bit passive ISDN cards from various
-manufacturers which are all based upon the popular Siemens ISDN chipset
-consisting of the ISDN Subscriber Access Controller ISAC (such as the
-PEB2085 or PSB 2186) and the High-Level Serial Communications Controller
-Extended HSCX (such as the SAB82525 or PSB21525). The newer IPAC chip
-(which integrates an ISAC and a HSCX in one chip, with the added benefit
-of larger FIFO buffers) is also supported.
-.Pp
-.Sh SUPPORTED CARDS
-.Pp
-.Bl -tag -width Ds -compact -offset
-.It Ar Teles S0/8, Dr. Neuhaus Niccy 1008, Creatix ISDN-S0/8
-.Pp
-The required (optional for NetBSD)
-.Em flag
-value is 1.
-.Pp
-Notice that this cards must not have a
-.Em port
-value in the config line.
-.Pp
-Valid interrupts are 2, 3, 4, 5, 6 and 7.
-.Pp
-The i/o ports are memory mapped and the memory start address may
-be in the range 0xA0000 to 0xDF000 and uses 4kB of memory.
-.Pp
-.It Ar Teles S0/16, Creatix ISDN-S0, Dr. Neuhaus Niccy 1016
-.Pp
-The required (optional under NetBSD)
-.Em flag
-value is 2.
-.Pp
-These boards have a jumper which specifies an i/o base address of either
-0xd80, 0xe80 or 0xf80. The remaining necessary configuration values are then
-programmed at run time by accessing this i/o port.
-.Pp
-Valid interrupts are 2, 3, 4, 5, 10, 11, 12 or 15.
-.Pp
-Valid memory start
-addresses are 0xC0000, 0xC2000, 0xC4000, 0xC6000, 0xC8000, 0xCA000, 0xCC000,
-0xCE000, 0xD0000, 0xD2000, 0xD4000, 0xD6000, 0xD8000, 0xDA000, 0xDC000 and
-0xDE000.
-.Pp
-Notice: Although the Jumpers are labeled 0xd80, 0xe80 or 0xf80, they
-also require i/o space at addresses 0x180, 0x280 or 0x380.
-.Pp
-.It Ar Teles S0/16.3
-.Pp
-The required (optional under NetBSD)
-.Em flag
-value is 3.
-.Pp
-This card is completely i/o mapped and must not have an
-.Em iomem
-statement in the config line.
-.Pp
-Valid interrupts are 2, 5, 9, 10, 12 or 15.
-.Pp
-Notice: Although the switch positions are labeled 0x180, 0x280 and 0x380,
-the card is to be configured at 0xd80, 0xe80 or 0xf80 respectively!
-.Pp
-.It Ar AVM A1, AVM Fritz!Card
-.Pp
-The required (optional under NetBSD)
-.Em flag
-value is 4.
-.Pp
-These boards have a jumper which specifies an i/o base address of either
-0x200, 0x240, 0x300 or 0x340.
-.Pp
-Valid interrupt configurations are 3, 4, 5, 6, 7, 10, 11, 12 or 15.
-.Pp
-Older Versions of the AVM A1 also require setting of an IRQ jumper, newer
-versions of this and the Fritz!Card only have an i/o base jumper and the
-interrupt is setup at runtime by reprogramming a register.
-.Pp
-This card is completely i/o mapped and must not have an
-.Em iomem
-statement in the config line.
-.Pp
-.It Ar Teles S0/16.3 PnP
-.Pp
-Possible i/o port values are 0x580, 0x500 and 0x680.
-Possible interrupt configurations are 3, 5, 7, 10, 11 and 12.
-.Pp
-The the card is auto-configured by the PnP kernel subsystem.
-.Pp
-.It Ar Creatix ISDN-S0 P&P
-.Pp
-Valid i/o port values are 0x120, 0x180 and 0x100.
-.Pp
-Valid interrupt configurations are 3, 5, 7, 10, 11 and 12.
-.Pp
-The card is auto-configured by the PnP kernel subsystem.
-.Pp
-.It Ar "3Com USRobotics Sportster ISDN TA intern and Stollmann Tina pp"
-.Pp
-The required (optional for NetBSD)
-.Em flag
-value is 7.
-.Pp
-Valid i/o port values are 0x200, 0x208, 0x210, 0x218, 0x220, 0x228, 0x230,
-0x238, 0x240, 0x248, 0x250, 0x258, 0x260, 0x268, 0x270 and 0x278.
-.Pp
-Valid interrupt configurations are 5, 7, 10, 11, 12, 14, 15.
-.Pp
-Notice: this card has a strange address decoding scheme resulting in 64
-windows of some bytes length. Anyway, support for this card is good because
-the manufacturer gave out technical docs for this card!
-.Pp
-.Pp
-.It Ar "Dr. Neuhaus Niccy Go@"
-.Pp
-Valid i/o port values must be in the range 0x200 ... 0x3e0.
-.Pp
-Valid interrupt configurations are 3, 4, 5, 9, 10, 11, 12, 15.
-.Pp
-The card is auto-configured by the PnP kernel subsystem.
-.Pp
-.It Ar "Sedlbauer Win Speed"
-.Pp
-Valid i/o port values must be in the range 0x100 ... 0x3f0. (alignment 0x8,
-len 0x8)
-.Pp
-Valid interrupt configurations are 3, 4, 5, 7, 10, 11, 12, 13, 15.
-.Pp
-The card is auto-configured by the PnP kernel subsystem.
-.Em FreeBSD:
-This card is PnP only, and so it can be configured using USERCONFIG
-('man 4 pnp'). This can be done via
-.Em /kernel.config
-\&. For example:
-.Pp
-.Cd USERCONFIG
-.Cd pnp 1 0 os enable port0 0x270 irq0 10
-.Cd quit
-.Pp
-.Pp
-.It Ar "ELSA QuickStep 1000pro (ISA)"
-.Pp
-I/O port in the range 0x160 ... 0x360 (occupies 8 bytes).
-.Pp
-Valid interrupt configurations are 3, 4, 5, 7, 10, 11, 12, 15.
-.Pp
-The card is auto-configured by the PnP kernel subsystem.
-.Pp
-.Pp
-.It Ar "ELSA QuickStep 1000pro-PCI"
-.Pp
-The card is auto-configured by the PCI kernel subsystem.
-.Pp
-.Pp
-.It Ar "ITK ix1 micro"
-.Pp
-The required (optional under NetBSD)
-.Em flag
-value is 18.
-.Pp
-Valid i/o port values must be in the range (<unknown>).
-.Pp
-Valid interrupt configurations are (<unknown>).
-.Pp
-.Sh CAVEATS
-Note that all of the boards with I/O ports actually use several ranges
-of port addresses; Teles happen to refer to the 0xd80 range in their
-documentation (the board also uses 0x180 etc.), while AVM happen to refer
-to the 0x200 range in their documentation (the board also uses 0x600 etc.)
-The driver matches the manufacturers' description for the purposes of
-configuration, but of course makes use of all the ports in order to
-operate the card.
-.Pp
-.Sh BUGS
-Since there is no hardware documentation available from several manufacturers
-for their boards, it is likely that there are many, many bugs left.
-
-.Sh STANDARDS
-CCITT Recommendation I.430
-
-.Sh SEE ALSO
-.Xr i4bq921 4
-.Xr i4bq931 4
-
-.Sh AUTHOR
-The
-.Nm
-driver and this manpage were written by Hellmuth Michaelis. It is based
-on earlier work of Arne Helme, Andrew Gordon and Gary Jennejohn. The author
-can be contacted at hm@kts.org.
-.Pp
-The complete porting to and maintenance of NetBSD was done by Martin Husemann.
-He can be contacted at martin@rumolt.teuto.de
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 124d8042ac9a..5d55861ac063 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)from: inetd.c 8.4 (Berkeley) 4/13/94";
#endif
static const char rcsid[] =
- "$Id: inetd.c,v 1.45 1999/01/02 16:04:19 des Exp $";
+ "$Id: inetd.c,v 1.39 1998/08/17 06:16:59 jb Exp $";
#endif /* not lint */
/*
@@ -172,7 +172,6 @@ int maxcpm = MAXCHILD;
struct servent *sp;
struct rpcent *rpc;
struct in_addr bind_address;
-int signalpipe[2];
struct servtab {
char *se_service; /* name of service */
@@ -218,9 +217,7 @@ struct servtab {
void chargen_dg __P((int, struct servtab *));
void chargen_stream __P((int, struct servtab *));
void close_sep __P((struct servtab *));
-void flag_signal __P((char));
-void flag_config __P((int));
-void config __P((void));
+void config __P((int));
void daytime_dg __P((int, struct servtab *));
void daytime_stream __P((int, struct servtab *));
void discard_dg __P((int, struct servtab *));
@@ -231,19 +228,16 @@ void endconfig __P((void));
struct servtab *enter __P((struct servtab *));
void freeconfig __P((struct servtab *));
struct servtab *getconfigent __P((void));
-void ident_stream __P((int, struct servtab *));
void machtime_dg __P((int, struct servtab *));
void machtime_stream __P((int, struct servtab *));
char *newstr __P((char *));
char *nextline __P((FILE *));
void print_service __P((char *, struct servtab *));
void addchild __P((struct servtab *, int));
-void flag_reapchild __P((int));
-void reapchild __P((void));
+void reapchild __P((int));
void enable __P((struct servtab *));
void disable __P((struct servtab *));
-void flag_retry __P((int));
-void retry __P((void));
+void retry __P((int));
int setconfig __P((void));
void setup __P((struct servtab *));
char *sskip __P((char **));
@@ -268,7 +262,7 @@ struct biltin {
{ "discard", SOCK_STREAM, 1, 0, discard_stream },
{ "discard", SOCK_DGRAM, 0, 0, discard_dg },
- /* Return 32 bit time since 1900 */
+ /* Return 32 bit time since 1970 */
{ "time", SOCK_STREAM, 0, 0, machtime_stream },
{ "time", SOCK_DGRAM, 0, 0, machtime_dg },
@@ -282,8 +276,6 @@ struct biltin {
{ "tcpmux", SOCK_STREAM, 1, 0, (void (*)())tcpmux },
- { "ident", SOCK_STREAM, 1, 0, ident_stream },
-
{ NULL }
};
@@ -416,12 +408,12 @@ main(argc, argv, envp)
sigaddset(&sa.sa_mask, SIGALRM);
sigaddset(&sa.sa_mask, SIGCHLD);
sigaddset(&sa.sa_mask, SIGHUP);
- sa.sa_handler = flag_retry;
+ sa.sa_handler = retry;
sigaction(SIGALRM, &sa, (struct sigaction *)0);
- config();
- sa.sa_handler = flag_config;
+ config(SIGHUP);
+ sa.sa_handler = config;
sigaction(SIGHUP, &sa, (struct sigaction *)0);
- sa.sa_handler = flag_reapchild;
+ sa.sa_handler = reapchild;
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sa, &sapipe);
@@ -436,13 +428,6 @@ main(argc, argv, envp)
(void)setenv("inetd_dummy", dummy, 1);
}
- if (pipe(signalpipe) != 0) {
- syslog(LOG_ERR, "pipe: %%m");
- exit(EX_OSERR);
- }
- FD_SET(signalpipe[0], &allsock);
- if (signalpipe[0]>maxsock) maxsock = signalpipe[0];
-
for (;;) {
int n, ctrl;
fd_set readable;
@@ -462,34 +447,6 @@ main(argc, argv, envp)
}
continue;
}
- /* handle any queued signal flags */
- if (FD_ISSET(signalpipe[0], &readable)) {
- int n;
- if (ioctl(signalpipe[0], FIONREAD, &n) != 0) {
- syslog(LOG_ERR, "ioctl: %m");
- exit(EX_OSERR);
- }
- while (--n >= 0) {
- char c;
- if (read(signalpipe[0], &c, 1) != 1) {
- syslog(LOG_ERR, "read: %m");
- exit(EX_OSERR);
- }
- if (debug)
- warnx("Handling signal flag %c", c);
- switch(c) {
- case 'A': /* sigalrm */
- retry();
- break;
- case 'C': /* sigchld */
- reapchild();
- break;
- case 'H': /* sighup */
- config();
- break;
- }
- }
- }
for (sep = servtab; n && sep; sep = sep->se_next)
if (sep->se_fd != -1 && FD_ISSET(sep->se_fd, &readable)) {
n--;
@@ -691,19 +648,6 @@ main(argc, argv, envp)
}
/*
- * Add a signal flag to the signal flag queue for later handling
- */
-
-void flag_signal(c)
- char c;
-{
- if (write(signalpipe[1], &c, 1) != 1) {
- syslog(LOG_ERR, "write: %m");
- exit(EX_OSERR);
- }
-}
-
-/*
* Record a new child pid for this service. If we've reached the
* limit on children, then stop accepting incoming requests.
*/
@@ -730,15 +674,9 @@ addchild(struct servtab *sep, pid_t pid)
*/
void
-flag_reapchild(signo)
+reapchild(signo)
int signo;
{
- flag_signal('C');
-}
-
-void
-reapchild()
-{
int k, status;
pid_t pid;
struct servtab *sep;
@@ -768,14 +706,9 @@ reapchild()
}
void
-flag_config(signo)
+config(signo)
int signo;
{
- flag_signal('H');
-}
-
-void config()
-{
struct servtab *sep, *new, **sepp;
long omask;
@@ -952,15 +885,9 @@ unregisterrpc(sep)
}
void
-flag_retry(signo)
+retry(signo)
int signo;
{
- flag_signal('A');
-}
-
-void
-retry()
-{
struct servtab *sep;
timingout = 0;
@@ -1523,33 +1450,6 @@ inetd_setproctitle(a, s)
*/
#define BUFSIZE 8192
-#define IDENT_RESPONSE ":ERROR:HIDDEN-USER\r\n"
-
-/* ARGSUSED */
-void
-ident_stream(s, sep) /* Ident service */
- int s;
- struct servtab *sep;
-{
- char buffer[BUFSIZE];
- int i, j;
-
- inetd_setproctitle(sep->se_service, s);
- j = 0;
- while ((i = read(s, buffer + j, sizeof(buffer) - j)) > 0) {
- j += i;
- buffer[j] = '\0';
- if (strchr(buffer, '\n'))
- break;
- if (strchr(buffer, '\r'))
- break;
- }
- while (j > 0 && (buffer[j-1] == '\n' || buffer[j-1] == '\r'))
- j--;
- write(s, buffer, j);
- write(s, IDENT_RESPONSE, strlen(IDENT_RESPONSE));
- exit(0);
-}
/* ARGSUSED */
void
echo_stream(s, sep) /* Echo service -- echo data back */
@@ -1736,7 +1636,7 @@ chargen_dg(s, sep) /* Character generator */
* some seventy years Bell Labs was asleep.
*/
-unsigned long
+long
machtime()
{
struct timeval tv;
@@ -1757,7 +1657,7 @@ machtime_stream(s, sep)
int s;
struct servtab *sep;
{
- unsigned long result;
+ long result;
result = machtime();
(void) write(s, (char *) &result, sizeof(result));
@@ -1769,7 +1669,7 @@ machtime_dg(s, sep)
int s;
struct servtab *sep;
{
- unsigned long result;
+ long result;
struct sockaddr_in sin;
int size;
diff --git a/usr.sbin/kbdcontrol/kbdcontrol.1 b/usr.sbin/kbdcontrol/kbdcontrol.1
index ebac0d978042..93c67700e091 100644
--- a/usr.sbin/kbdcontrol/kbdcontrol.1
+++ b/usr.sbin/kbdcontrol/kbdcontrol.1
@@ -36,7 +36,7 @@ characteristics etc.
.Pp
The following command line options are supported:
.Bl -tag -width indent
-.It Fl b Ar duration.pitch | Ar [quiet.]belltype
+.It Fl b Ar duration.pitch | Ar belltype
Set the bell duration in miliseconds and pitch in hertz.
If a
.Ar belltype
@@ -47,7 +47,7 @@ which set sound parameters back to normal values, or
which set the bell to visual mode, i.e. flashes the screen instead.
If
.Ar belltype
-is preceded by the word
+is proceeded by the word
.Ar quiet. ,
the bell will not be rung when the ringing process is in the background vty.
.It Fl r Ar delay.repeat | Ar speed
diff --git a/usr.sbin/kbdcontrol/kbdcontrol.c b/usr.sbin/kbdcontrol/kbdcontrol.c
index 5ea0d780b493..e1614c3dcc3e 100644
--- a/usr.sbin/kbdcontrol/kbdcontrol.c
+++ b/usr.sbin/kbdcontrol/kbdcontrol.c
@@ -28,7 +28,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: kbdcontrol.c,v 1.20 1999/01/11 03:20:24 yokota Exp $";
+ "$Id: kbdcontrol.c,v 1.18 1998/09/04 10:15:48 yokota Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -37,7 +37,6 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <fcntl.h>
#include <machine/console.h>
#include "path.h"
#include "lex.h"
@@ -417,13 +416,8 @@ print_entry(FILE *fp, int value)
}
-#ifdef __i386__
-void
-print_key_definition_line(FILE *fp, int scancode, struct keyent_t *key)
-#else
void
print_key_definition_line(FILE *fp, int scancode, struct key_t *key)
-#endif
{
int i;
@@ -871,116 +865,14 @@ set_history(char *opt)
warn("setting history buffer size");
}
-#ifdef __i386__
-static char
-*get_kbd_type_name(int type)
-{
- static struct {
- int type;
- char *name;
- } name_table[] = {
- { KB_84, "AT 84" },
- { KB_101, "AT 101/102" },
- { KB_OTHER, "generic" },
- };
- int i;
-
- for (i = 0; i < sizeof(name_table)/sizeof(name_table[0]); ++i) {
- if (type == name_table[i].type)
- return name_table[i].name;
- }
- return "unknown";
-}
-
-void
-show_kbd_info(void)
-{
- keyboard_info_t info;
-
- if (ioctl(0, KDGKBINFO, &info) == -1) {
- warn("unable to obtain keyboard information");
- return;
- }
- printf("kbd%d:\n", info.kb_index);
- printf(" %.*s%d, type:%s (%d)\n",
- sizeof(info.kb_name), info.kb_name, info.kb_unit,
- get_kbd_type_name(info.kb_type), info.kb_type);
-}
-
-
-void
-set_keyboard(char *device)
-{
- keyboard_info_t info;
- int fd;
-
- fd = open(device, O_RDONLY);
- if (fd < 0) {
- warn("cannot open %s", device);
- return;
- }
- if (ioctl(fd, KDGKBINFO, &info) == -1) {
- warn("unable to obtain keyboard information");
- close(fd);
- return;
- }
- /*
- * The keyboard device driver won't release the keyboard by
- * the following ioctl, but it automatically will, when the device
- * is closed. So, we don't check error here.
- */
- ioctl(fd, CONS_RELKBD, 0);
- close(fd);
-#if 1
- printf("kbd%d\n", info.kb_index);
- printf(" %.*s%d, type:%s (%d)\n",
- sizeof(info.kb_name), info.kb_name, info.kb_unit,
- get_kbd_type_name(info.kb_type), info.kb_type);
-#endif
-
- if (ioctl(0, CONS_SETKBD, info.kb_index) == -1)
- warn("unable to set keyboard");
-}
-
-
-void
-release_keyboard(void)
-{
- keyboard_info_t info;
-
- /*
- * If stdin is not associated with a keyboard, the following ioctl
- * will fail.
- */
- if (ioctl(0, KDGKBINFO, &info) == -1) {
- warn("unable to obtain keyboard information");
- return;
- }
-#if 1
- printf("kbd%d\n", info.kb_index);
- printf(" %.*s%d, type:%s (%d)\n",
- sizeof(info.kb_name), info.kb_name, info.kb_unit,
- get_kbd_type_name(info.kb_type), info.kb_type);
-#endif
- if (ioctl(0, CONS_RELKBD, 0) == -1)
- warn("unable to release the keyboard");
-}
-#endif /* __i386__ */
-
static void
usage()
{
fprintf(stderr, "%s\n%s\n%s\n",
-#ifdef __i386__
-"usage: kbdcontrol [-dFKix] [-b duration.pitch | [quiet.]belltype]",
-" [-r delay.repeat | speed] [-l mapfile] [-f # string]",
-" [-h size] [-k device] [-L mapfile]");
-#else
"usage: kbdcontrol [-dFx] [-b duration.pitch | [quiet.]belltype]",
" [-r delay.repeat | speed] [-l mapfile] [-f # string]",
" [-h size] [-L mapfile]");
-#endif
exit(1);
}
@@ -990,11 +882,7 @@ main(int argc, char **argv)
{
int opt;
-#ifdef __i386__
- while((opt = getopt(argc, argv, "b:df:h:iKk:Fl:L:r:x")) != -1)
-#else
while((opt = getopt(argc, argv, "b:df:h:Fl:L:r:x")) != -1)
-#endif
switch(opt) {
case 'b':
set_bell_values(optarg);
@@ -1018,17 +906,6 @@ main(int argc, char **argv)
case 'h':
set_history(optarg);
break;
-#ifdef __i386__
- case 'i':
- show_kbd_info();
- break;
- case 'K':
- release_keyboard();
- break;
- case 'k':
- set_keyboard(optarg);
- break;
-#endif /* __i386__ */
case 'r':
set_keyrates(optarg);
break;
diff --git a/usr.sbin/kvm_mkdb/nlist.c b/usr.sbin/kvm_mkdb/nlist.c
index e3e0666a48dd..b1c74036dc9c 100644
--- a/usr.sbin/kvm_mkdb/nlist.c
+++ b/usr.sbin/kvm_mkdb/nlist.c
@@ -29,8 +29,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef lint
@@ -38,7 +36,7 @@
static char sccsid[] = "@(#)from: nlist.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: nlist.c,v 1.9 1998/08/17 08:46:46 dfr Exp $";
+ "$Id: nlist.c,v 1.8 1997/09/24 06:44:10 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -182,16 +180,14 @@ __aout_knlist(name, db)
#ifdef DO_ELF
-static void elf_sym_to_nlist __P((struct nlist *, Elf_Sym *, Elf_Shdr *, int));
-
int
__elf_knlist(name, db)
char *name;
DB *db;
{
register caddr_t strtab;
- register off_t symstroff = 0, symoff = 0;
- register u_long symsize = 0;
+ register off_t symstroff, symoff;
+ register u_long symsize;
register u_long kernvma, kernoffs;
register int i;
Elf_Sym *sbuf;
@@ -245,8 +241,6 @@ __elf_knlist(name, db)
kernoffs = sh[i].sh_offset;
}
}
- if (symsize == 0)
- badfmt("stripped");
strtab = (char *)&filep[symstroff];
@@ -259,7 +253,24 @@ __elf_knlist(name, db)
sbuf = (Elf_Sym *)&filep[symoff + i * sizeof(*sbuf)];
if (!sbuf->st_name)
continue;
- elf_sym_to_nlist(&nbuf, sbuf, sh, eh->e_shnum);
+
+ nbuf.n_value = sbuf->st_value;
+
+ /*XXX type conversion is pretty rude... */
+ switch (ELF_ST_TYPE(sbuf->st_info)) {
+ case STT_NOTYPE:
+ nbuf.n_type = N_UNDF;
+ break;
+ case STT_FUNC:
+ nbuf.n_type = N_TEXT;
+ break;
+ case STT_OBJECT:
+ nbuf.n_type = N_DATA;
+ break;
+ }
+ if (ELF_ST_BIND(sbuf->st_info) == STB_LOCAL)
+ nbuf.n_type = N_EXT;
+
key.data = (u_char *)(strtab + sbuf->st_name);
key.size = strlen((char *)key.data);
if (db->put(db, &key, &data, 0))
@@ -300,46 +311,6 @@ __elf_knlist(name, db)
(void)close(fd);
return(0);
}
-
-/*
- * Convert an Elf_Sym into an nlist structure. This fills in only the
- * n_value and n_type members.
- */
-static void
-elf_sym_to_nlist(nl, s, shdr, shnum)
- struct nlist *nl;
- Elf_Sym *s;
- Elf_Shdr *shdr;
- int shnum;
-{
- nl->n_value = s->st_value;
-
- switch (s->st_shndx) {
- case SHN_UNDEF:
- case SHN_COMMON:
- nl->n_type = N_UNDF;
- break;
- case SHN_ABS:
- nl->n_type = ELF_ST_TYPE(s->st_info) == STT_FILE ?
- N_FN : N_ABS;
- break;
- default:
- if (s->st_shndx >= shnum)
- nl->n_type = N_UNDF;
- else {
- Elf_Shdr *sh = shdr + s->st_shndx;
-
- nl->n_type = sh->sh_type == SHT_PROGBITS ?
- (sh->sh_flags & SHF_WRITE ? N_DATA : N_TEXT) :
- (sh->sh_type == SHT_NOBITS ? N_BSS : N_UNDF);
- }
- break;
- }
-
- if (ELF_ST_BIND(s->st_info) == STB_GLOBAL ||
- ELF_ST_BIND(s->st_info) == STB_WEAK)
- nl->n_type |= N_EXT;
-}
#endif /* DO_ELF */
static struct knlist_handlers {
diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c
index 56a364da33e6..54131ad60250 100644
--- a/usr.sbin/lpr/lpr/lpr.c
+++ b/usr.sbin/lpr/lpr/lpr.c
@@ -48,7 +48,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)from: lpr.c 8.4 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: lpr.c,v 1.26 1999/01/06 08:25:56 imp Exp $";
+ "$Id: lpr.c,v 1.24 1998/04/17 17:25:49 obrien Exp $";
#endif /* not lint */
/*
@@ -126,7 +126,7 @@ main(argc, argv)
{
struct passwd *pw;
struct group *gptr;
- char *arg, *cp, *printer, *p;
+ char *arg, *cp, *printer;
char buf[BUFSIZ];
int c, i, f, errs;
struct stat stb;
@@ -154,9 +154,7 @@ main(argc, argv)
":#:1:2:3:4:C:J:P:T:U:cdfghi:lnmprstvw:")) != -1)
switch (c) {
case '#': /* n copies */
- i = strtol(optarg, &p, 10);
- if (*p)
- errx(1, "Bad argument to -#, number expected");
+ i = atoi(optarg);
if (i > 0)
ncopies = i;
break;
@@ -212,9 +210,7 @@ main(argc, argv)
case 'i': /* indent output */
iflag++;
- indent = strtol(optarg, &p, 10);
- if (*p)
- errx(1, "Bad argument to -i, number expected");
+ indent = atoi(optarg);
break;
case 'm': /* send mail when done */
diff --git a/usr.sbin/lptcontrol/lptcontrol.c b/usr.sbin/lptcontrol/lptcontrol.c
index afd234ee5ba6..73ea05cf459f 100644
--- a/usr.sbin/lptcontrol/lptcontrol.c
+++ b/usr.sbin/lptcontrol/lptcontrol.c
@@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: lptcontrol.c,v 1.6 1997/09/25 06:36:29 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include <ctype.h>
@@ -53,12 +53,10 @@ static const char rcsid[] =
#define IRQ_INVALID -1
#define DO_POLL 0
#define USE_IRQ 1
-#define USE_EXT_MODE 2
-#define USE_STD_MODE 3
static void usage()
{
- fprintf(stderr, "usage: lptcontrol -i | -p | -s | -e [-u <unit no.>]\n");
+ fprintf(stderr, "usage: lptcontrol -i | -p [-u <unit no.>]\n");
exit(1);
}
@@ -91,12 +89,10 @@ int main (int argc, char * argv[])
int irq_status = IRQ_INVALID;
char * unit = DEFAULT_UNIT;
- while((opt = getopt(argc, argv, "ipesu:")) != -1)
+ while((opt = getopt(argc, argv, "ipu:")) != -1)
switch(opt) {
case 'i': irq_status = USE_IRQ; break;
case 'p': irq_status = DO_POLL; break;
- case 'e': irq_status = USE_EXT_MODE; break;
- case 's': irq_status = USE_STD_MODE; break;
case 'u': unit = optarg;
if(!isdigit(*unit))
usage();
diff --git a/usr.sbin/moused/moused.8 b/usr.sbin/moused/moused.8
index 64cd108a4434..18d1b4dbb334 100644
--- a/usr.sbin/moused/moused.8
+++ b/usr.sbin/moused/moused.8
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: moused.8,v 1.17 1998/11/20 11:19:20 yokota Exp $
+.\" $Id: moused.8,v 1.15 1998/06/14 20:05:26 ahasty Exp $
.\"
.Dd December 3, 1997
.Dt MOUSED 8
@@ -45,7 +45,6 @@
.Op Fl S Ar baudrate
.Op Fl C Ar threshold
.Op Fl m Ar N=M
-.Op Fl w Ar N
.Op Fl z Ar target
.Op Fl t Ar mousetype
.Fl p Ar port
@@ -260,8 +259,6 @@ Kensington ThinkingMouse protocol.
Hitachi tablet protocol.
.It Ar x10mouseremote
X10 MouseRemote.
-.It Ar kidspad
-Genius Kidspad and Easypad protocol.
.El
.Pp
For the bus and InPort mouse:
@@ -278,15 +275,6 @@ For the PS/2 mouse:
This is the only protocol type available for the PS/2 mouse
and should be specified for any PS/2 mice, regardless of the brand.
.El
-.It Fl w Ar N
-Make the physical button
-.Ar N
-act as the wheel mode button.
-While this button is pressed, X and Y axis movement is reported to be zero
-and the Y axis movement is mapped to Z axis.
-You may further map the Z axis movement to virtual buttons by the
-.Fl z
-option below.
.It Fl z Ar target
Map Z axis (roller/wheel) movement to another axis or to virtual buttons.
Valid
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c
index a4ef99bf0759..2717fc00971e 100644
--- a/usr.sbin/moused/moused.c
+++ b/usr.sbin/moused/moused.c
@@ -46,7 +46,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: moused.c,v 1.23 1998/11/20 11:22:17 yokota Exp $";
+ "$Id: moused.c,v 1.19 1998/06/14 20:05:27 ahasty Exp $";
#endif /* not lint */
#include <err.h>
@@ -187,7 +187,6 @@ static char *rnames[] = {
"thinkingmouse",
"sysmouse",
"x10mouseremote",
- "kidspad",
#if notyet
"mariqua",
#endif
@@ -203,7 +202,6 @@ static symtab_t rmodels[] = {
{ "IntelliMouse", MOUSE_MODEL_INTELLI },
{ "EasyScroll", MOUSE_MODEL_EASYSCROLL },
{ "MouseMan+", MOUSE_MODEL_MOUSEMANPLUS },
- { "Kidspad", MOUSE_MODEL_KIDSPAD },
{ "generic", MOUSE_MODEL_GENERIC },
{ NULL, MOUSE_MODEL_UNKNOWN },
};
@@ -220,8 +218,6 @@ static symtab_t pnpprod[] = {
{ "KYE0001", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC },
/* Genius NetMouse */
{ "KYE0003", MOUSE_PROTO_INTELLI, MOUSE_MODEL_NET },
- /* Genius Kidspad, Easypad and other tablets */
- { "KYE0005", MOUSE_PROTO_KIDSPAD, MOUSE_MODEL_KIDSPAD },
/* Genius EZScroll */
{ "KYEEZ00", MOUSE_PROTO_MS, MOUSE_MODEL_EASYSCROLL },
/* Logitech MouseMan (new 4 button model) */
@@ -330,7 +326,6 @@ static unsigned short rodentcflags[] =
(CS7 | CREAD | CLOCAL | HUPCL ), /* Thinking Mouse */
(CS8 | CSTOPB | CREAD | CLOCAL | HUPCL ), /* sysmouse */
(CS7 | CREAD | CLOCAL | HUPCL ), /* X10 MouseRemote */
- (CS8 | PARENB | PARODD | CREAD | CLOCAL | HUPCL ), /* kidspad etc. */
#if notyet
(CS8 | CSTOPB | CREAD | CLOCAL | HUPCL ), /* Mariqua */
#endif
@@ -345,7 +340,6 @@ static struct rodentparam {
int rate; /* report rate */
int resolution; /* MOUSE_RES_XXX or a positive number */
int zmap; /* MOUSE_{X|Y}AXIS or a button number */
- int wmode; /* wheel mode button number */
int mfd; /* mouse file descriptor */
int cfd; /* /dev/consolectl file descriptor */
int mremsfd; /* mouse remote server file descriptor */
@@ -362,7 +356,6 @@ static struct rodentparam {
rate : 0,
resolution : MOUSE_RES_UNKNOWN,
zmap: 0,
- wmode: 0,
mfd : -1,
cfd : -1,
mremsfd : -1,
@@ -408,15 +401,13 @@ static char *gettokenname(symtab_t *tab, int val);
static void mremote_serversetup();
static void mremote_clientchg(int add);
-static int kidspad(u_char rxc, mousestatus_t *act);
-
void
main(int argc, char *argv[])
{
int c;
int i;
- while((c = getopt(argc,argv,"3C:DF:I:PRS:cdfhi:l:m:p:r:st:w:z:")) != -1)
+ while((c = getopt(argc,argv,"3C:DF:I:PRS:cdfhi:l:m:p:r:st:z:")) != -1)
switch(c) {
case '3':
@@ -496,15 +487,6 @@ main(int argc, char *argv[])
rodent.baudrate = 9600;
break;
- case 'w':
- i = atoi(optarg);
- if ((i <= 0) || (i > MOUSE_MAXBUTTON)) {
- warnx("invalid argument `%s'", optarg);
- usage();
- }
- rodent.wmode = 1 << (i - 1);
- break;
-
case 'z':
if (strcmp(optarg, "x") == 0)
rodent.zmap = MOUSE_XAXIS;
@@ -812,9 +794,9 @@ static void
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n",
- "usage: moused [-3DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
- " [-C threshold] [-m N=M] [-w N] [-z N] [-t <mousetype>] -p <port>",
- " moused [-d] -i <info> -p <port>");
+ "usage: moused [-3DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate] [-C threshold]",
+ " [-m N=M] [-z N] [-t <mousetype>] -p <port>",
+ " moused [-d] -i -p <port>");
exit(1);
}
@@ -884,7 +866,6 @@ static unsigned char proto[][7] = {
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x33, 0x00 }, /* ThinkingMouse */
{ 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* sysmouse */
{ 0x40, 0x40, 0x40, 0x00, 3, ~0x23, 0x00 }, /* X10 MouseRem */
- { 0x80, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* KIDSPAD */
#if notyet
{ 0xf8, 0x80, 0x00, 0x00, 5, ~0x2f, 0x10 }, /* Mariqua */
#endif
@@ -1266,8 +1247,6 @@ r_protocol(u_char rBuf, mousestatus_t *act)
static unsigned char pBuf[8];
debug("received char 0x%x",(int)rBuf);
- if (rodent.rtype == MOUSE_PROTO_KIDSPAD)
- return kidspad(rBuf, act) ;
/*
* Hack for resyncing: We check here for a package that is:
@@ -1641,12 +1620,6 @@ r_map(mousestatus_t *act1, mousestatus_t *act2)
lbuttons = 0;
act2->obutton = act2->button;
- if (pbuttons & rodent.wmode) {
- pbuttons &= ~rodent.wmode;
- act1->dz = act1->dy;
- act1->dx = 0;
- act1->dy = 0;
- }
act2->dx = act1->dx;
act2->dy = act1->dy;
act2->dz = act1->dz;
@@ -1897,7 +1870,7 @@ pnpwakeup1(void)
* The PnP COM device spec. dictates that the mouse must set DSR
* in response to DTR (by hardware or by software) and that if DSR is
* not asserted, the host computer should think that there is no device
- * at this serial port. But some mice just don't do that...
+ * at this serial port. But there are some mice just don't do that...
*/
ioctl(rodent.mfd, TIOCMGET, &i);
debug("modem status 0%o", i);
@@ -1927,29 +1900,29 @@ pnpwakeup1(void)
if (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
debug("pnpwakeup1(): valid response in first phase.");
return TRUE;
- }
+ } else {
- /* port setup, 2nd phase (2.1.5) */
- i = TIOCM_DTR | TIOCM_RTS; /* DTR = 0, RTS = 0 */
- ioctl(rodent.mfd, TIOCMBIC, &i);
- usleep(240000);
+ /* port setup, 2nd phase (2.1.5) */
+ i = TIOCM_DTR | TIOCM_RTS; /* DTR = 0, RTS = 0 */
+ ioctl(rodent.mfd, TIOCMBIC, &i);
+ usleep(240000);
- /* wait for respose, 2nd phase (2.1.6) */
- i = FREAD;
- ioctl(rodent.mfd, TIOCFLUSH, &i);
- i = TIOCM_DTR | TIOCM_RTS; /* DTR = 1, RTS = 1 */
- ioctl(rodent.mfd, TIOCMBIS, &i);
+ /* wait for respose, 2nd phase (2.1.6) */
+ i = FREAD;
+ ioctl(rodent.mfd, TIOCFLUSH, &i);
+ i = TIOCM_DTR | TIOCM_RTS; /* DTR = 1, RTS = 1 */
+ ioctl(rodent.mfd, TIOCMBIS, &i);
- /* try to read something */
- FD_ZERO(&fds);
- FD_SET(rodent.mfd, &fds);
- timeout.tv_sec = 0;
- timeout.tv_usec = 240000;
- if (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
- debug("pnpwakeup1(): valid response in second phase.");
- return TRUE;
+ /* try to read something */
+ FD_ZERO(&fds);
+ FD_SET(rodent.mfd, &fds);
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 240000;
+ if (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
+ debug("pnpwakeup1(): valid response in second phase.");
+ return TRUE;
+ }
}
-
return FALSE;
}
@@ -1963,7 +1936,7 @@ pnpwakeup2(void)
/*
* This is a simplified procedure; it simply toggles RTS.
*/
- debug("alternate probe...");
+ debug("PnP COM device rev 0.9 probe...");
ioctl(rodent.mfd, TIOCMGET, &i);
i |= TIOCM_DTR; /* DTR = 1 */
@@ -1988,7 +1961,6 @@ pnpwakeup2(void)
debug("pnpwakeup2(): valid response.");
return TRUE;
}
-
return FALSE;
}
@@ -2221,8 +2193,7 @@ pnpproto(pnpid_t *id)
int i, j;
if (id->nclass > 0)
- if ( strncmp(id->class, "MOUSE", id->nclass) != 0 &&
- strncmp(id->class, "TABLET", id->nclass) != 0)
+ if (strncmp(id->class, "MOUSE", id->nclass) != 0)
/* this is not a mouse! */
return NULL;
@@ -2278,97 +2249,6 @@ gettokenname(symtab_t *tab, int val)
return NULL;
}
-
-/*
- * code to read from the Genius Kidspad tablet.
-
-The tablet responds to the COM PnP protocol 1.0 with EISA-ID KYE0005,
-and to pre-pnp probes (RTS toggle) with 'T' (tablet ?)
-9600, 8 bit, parity odd.
-
-The tablet puts out 5 bytes. b0 (mask 0xb8, value 0xb8) contains
-the proximity, tip and button info:
- (byte0 & 0x1) true = tip pressed
- (byte0 & 0x2) true = button pressed
- (byte0 & 0x40) false = pen in proximity of tablet.
-
-The next 4 bytes are used for coordinates xl, xh, yl, yh (7 bits valid).
-
-Only absolute coordinates are returned, so we use the following approach:
-we store the last coordinates sent when the pen went out of the tablet,
-
-
- *
- */
-
-typedef enum {
- S_IDLE, S_PROXY, S_FIRST, S_DOWN, S_UP
-} k_status ;
-
-static int
-kidspad(u_char rxc, mousestatus_t *act)
-{
- static buf[5];
- static int buflen = 0, b_prev = 0 , x_prev = -1, y_prev = -1 ;
- static k_status status = S_IDLE ;
- static struct timeval old, now ;
- static int x_idle = -1, y_idle = -1 ;
-
- int deltat, x, y ;
-
- if (buflen > 0 && (rxc & 0x80) ) {
- fprintf(stderr, "invalid code %d 0x%x\n", buflen, rxc);
- buflen = 0 ;
- }
- if (buflen == 0 && (rxc & 0xb8) != 0xb8 ) {
- fprintf(stderr, "invalid code 0 0x%x\n", rxc);
- return 0 ; /* invalid code, no action */
- }
- buf[buflen++] = rxc ;
- if (buflen < 5)
- return 0 ;
-
- buflen = 0 ; /* for next time... */
-
- x = buf[1]+128*(buf[2] - 7) ;
- if (x < 0) x = 0 ;
- y = 28*128 - (buf[3] + 128* (buf[4] - 7)) ;
- if (y < 0) y = 0 ;
-
- x /= 8 ;
- y /= 8 ;
-
- act->flags = 0 ;
- act->obutton = act->button ;
- act->dx = act->dy = act->dz = 0 ;
- gettimeofday(&now, NULL);
- if ( buf[0] & 0x40 ) /* pen went out of reach */
- status = S_IDLE ;
- else if (status == S_IDLE) { /* pen is newly near the tablet */
- act->flags |= MOUSE_POSCHANGED ; /* force update */
- status = S_PROXY ;
- x_prev = x ;
- y_prev = y ;
- }
- old = now ;
- act->dx = x - x_prev ;
- act->dy = y - y_prev ;
- if (act->dx || act->dy)
- act->flags |= MOUSE_POSCHANGED ;
- x_prev = x ;
- y_prev = y ;
- if (b_prev != 0 && b_prev != buf[0]) { /* possibly record button change */
- act->button = 0 ;
- if ( buf[0] & 0x01 ) /* tip pressed */
- act->button |= MOUSE_BUTTON1DOWN ;
- if ( buf[0] & 0x02 ) /* button pressed */
- act->button |= MOUSE_BUTTON2DOWN ;
- act->flags |= MOUSE_BUTTONSCHANGED ;
- }
- b_prev = buf[0] ;
- return act->flags ;
-}
-
static void
mremote_serversetup()
{
diff --git a/usr.sbin/mrouted/RELEASE b/usr.sbin/mrouted/RELEASE
index 979065011f28..7dff93789cce 100644
--- a/usr.sbin/mrouted/RELEASE
+++ b/usr.sbin/mrouted/RELEASE
@@ -1,188 +1,21 @@
-README-3.9-beta3.mrouted,v 1.1.2.1 1998/03/01 03:00:20 fenner Exp
+Id: README-3.8.mrouted,v 3.8 1995/11/29 22:23:02 fenner Rel
IP Multicast Extensions for BSD-Derived Unix Systems
- Multicast Routing Daemon
- Release 3.9-beta3
- February 28, 1998
+ Release 3.8
+ November 29, 1995
available from parcftp.xerox.com,
- file pub/net-research/ipmulti/beta-test/mrouted3.9-beta3.tar.Z
- binaries:
- pub/net-research/ipmulti/beta-test/mrouted3.9-beta3-sparc-sunos41x.tar.Z
- pub/net-research/ipmulti/beta-test/mrouted3.9-beta3-sparc-solaris2.tar.Z
- pub/net-research/ipmulti/beta-test/mrouted3.9-beta3-i386-freebsd22.tar.Z
- pub/net-research/ipmulti/beta-test/mrouted3.9-beta3-alpha-osf1.tar.Z
- pub/net-research/ipmulti/beta-test/mrouted3.9-beta3-sgi-irix6.tar.Z
+ file pub/net-research/ipmulti/mrouted3.8.tar.Z
+ binaries pub/net-research/ipmulti/mrouted3.8-sparc-sunos41x.tar.Z
+ pub/net-research/ipmulti/mrouted3.8-sparc-solaris2.tar.Z
+ pub/net-research/ipmulti/mrouted3.8-i386-bsd.tar.Z
+ pub/net-research/ipmulti/mrouted3.8-alpha-osf1.tar.Z
+ pub/net-research/ipmulti/mrouted3.8-sgi-irix.tar.Z
+ pub/net-research/ipmulti/mrouted3.8-hp-hpux.tar.Z
-Note: The 3.9 release is mrouted-only, and will run on top of a 3.5 kernel.
-It is a drop-in replacement for mrouted 3.5, 3.6, 3.7 or 3.8.
-
-NOTE WELL: This is a beta-test release of mrouted. The basic
-functionality has been extensively tested in CAIRN and other
-testbeds, but it is expected to have bugs. Please report bugs to Bill
-Fenner <fenner@parc.xerox.com>.
-
-
-The 3.9-beta3 release fixes the following bugs:
- o There was a bug handling routing updates which caused random black
- holes.
-
- o There was a race condition in the timer handlers causing free'd memory
- to sometimes get touched.
-
- o "allow_nonpruners" wasn't allowed in the configuration file (and almost
- nobody noticed! - probably a good sign)
-
- o When a prune times out and the source has been active "recently",
- mrouted now waits for further traffic instead of triggering a new
- prune.
-
- o mrouted now ignores unreachable routes when making a routing decision
- (previously it would blackhole, now it can find a less-specific)
-
-The 3.9-beta3 release has the following new features:
- o A "blaster" keyword for mrouted.conf, to turn on handling of routers
- (mostly ciscos) which overwhelm the socket buffers by blasting the
- whole routing table at once.
-
- o A "notransit" keyword; routes learned on a "notransit" vif will not be
- readvertised onto another "notransit" vif.
-
- o The 500kbps default rate limit on tunnels has been removed.
-
- o An ICMP listener which logs ICMP errors which appear to be in response to
- tunnel packets that we sent.
-
- o A tunnel traffic encapsulator, which encapsulates control traffic
- inside the tunnel instead of unicasting it "beside" the tunnel.
- This is turned off by default; use "beside off" to turn it on.
-
- o A "force_leaf" flag to ignore any potential neighbors on a given interface.
-
-
-=========
-3.9-beta2
-June 11, 1997
-
-The 3.9-beta2 release fixes the following bugs:
- o There was a bug in 3.9-beta1's raw socket buffer processing that
- would cause an immediate lockup on startup on some systems.
-
- o RSRR would not clear out the group membership information if
- further notification of changes to this route entry was not possible.
-
-There is no need to upgrade to 3.9-beta2 if you are not experiencing
-one of the aforementioned bugs.
-
-=========
-3.9-beta1
-June 6, 1997
-
-The 3.9-beta1 release has the following known bugs:
-
- o The startup message doesn't print properly if you have too many
- interfaces.
-
-The 3.9-beta1 release fixes the following bugs:
-
- o mrouted did not properly keep track of subordinates, and would not
- time out subordinateness. This caused 2 major problems:
- 1. pruning did not happen when there were equal-cost paths to
- the same multi-access link
- 2. subordinateness which did not get cancelled by a non-poisoned
- route (e.g. in the face of route filtering) did not time out,
- causing traffic to continue to flow.
-
- o mrouted's IGMPv2 processing when it is not the querier now
- conforms to draft-ietf-idmr-igmp-v2-06.txt Thanks to Lorenzo
- VICISANO <L.Vicisano@cs.ucl.ac.uk> for finding a problem.
-
- o mrouted is much more careful about forgetting prunes; 3.8
- would forget prunes whenever any route change ocurred.
-
-The 3.9-beta1 release has the following new features:
-
- o Longer prune lifetimes (2 hours) by default. Prune lifetimes may
- be configured per-vif, with the "prune_lifetime N" mrouted.conf
- configuration file entry (where N is in seconds). This helps to
- work around the black holes caused on restart when you have a Cisco
- upstream which does not handle genid's; if this is your situation
- the recommended value is 300.
-
- o mrouted's behavior of flooding new routes by default at startup
- in order to speed healing of paths during startup can be turned off
- per-vif or globally with the "noflood" configuration option.
- Turning this option off means you are likely to experience
- black holes for a minute or two when you restart a router. The
- default is to flood for a minute or two until mrouted is able to
- learn subordinate relationships.
-
- o mrouted now retransmits prunes by default on point-to-point links.
- prune retransmission can be turned on or off per vif via the
- "rexmit_prunes [on|off]" mrouted.conf command. Prune retransmission
- helps on lossy links, and also helps when a router has forgotten
- about a prune (e.g. if it is out of memory and needs to shed state,
- or due to a bug).
-
- o The new "passive" mode causes mrouted to not actively send probes
- looking for neighbors. This allows a dialup link to become quiescent
- if there is no DVMRP neighbor on the other end. Configuring
- "passive" on both ends of a link will cause it to never come up.
-
- o mrouted defaults to not peering with DVMRP routers that do not
- prune. Use the "allow_nonpruners" mrouted.conf option on a vif
- on which you want to allow such peerings.
-
- o mrouted now allows route filtering. mrouted.conf syntax:
- accept 13/8
-
- accepts all routes matching 13/8 (e.g. accepts
- 13.2.116/22). If you want to accept only exactly
- 13/8, use
-
- accept 13/8 exact
-
- deny 10/8 64/2 130/8 exact 172/8 exact
-
- denies some common MBone martians
-
- Only "accept" or "deny" is allowed, no combinations.
-
- Add "bidir" to apply the filter to output too, otherwise
- it's input only.
-
- Expected usage:
- - Providers filter routes that customers send them
- - Martian removal
- - Topology modification (e.g. don't let the existence of
- private tunnel foo out into the world).
-
-
- o mrouted now malloc's the buffer it uses for SIOCGIFCONF, to allow
- for more interfaces. Thanks to Danny Mitzel
-
- o mrouted now ignores multiple entries for a single interface
- name (temporary hack until mrouted understands interface aliases)
-
- o mrouted's "-d" flag has been modified to accept the names of the
- systems which you would like to debug.
- packet, prunes, routes, peers, cache, timeout, interface,
- membership, traceroute, igmp
-
- o mrouted now times neighbors out fater, and fully detects and
- ignores routes from one-way peerings.
-
- o mrouted's route processing has been sped up, especially at startup.
-
- o mrouted uses the biggest SO_RCVBUF the operating system allows
- (up to 256Kbytes)
-
- o mrouted uses TOS 0xc0 ("Internet Control") for DVMRP messages.
-
-===========
-Release 3.8
-November 29, 1995
+Note: The 3.8 release is mrouted-only, and will run on top of a 3.5 kernel.
+It is a drop-in replacement for mrouted 3.5, 3.6 or 3.7 .
The 3.8 release fixes the following bugs:
diff --git a/usr.sbin/mrouted/VERSION b/usr.sbin/mrouted/VERSION
deleted file mode 100644
index a0ba149f7950..000000000000
--- a/usr.sbin/mrouted/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-3.9-beta3+IOS12
diff --git a/usr.sbin/mrouted/callout.c b/usr.sbin/mrouted/callout.c
index 673973fdedfd..7de8bafe399f 100644
--- a/usr.sbin/mrouted/callout.c
+++ b/usr.sbin/mrouted/callout.c
@@ -5,14 +5,11 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
- *
- *
- * callout.c,v 3.8.4.8 1998/01/06 01:58:45 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: callout.c,v 1.10 1998/01/16 07:17:41 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include "defs.h"
@@ -21,11 +18,13 @@ static const char rcsid[] =
static int id = 0;
static struct timeout_q *Q = 0; /* pointer to the beginning of timeout queue */
+static int in_callout = 0;
+
struct timeout_q {
struct timeout_q *next; /* next event */
int id;
cfunc_t func; /* function to call */
- void *data; /* func's data */
+ char *data; /* func's data */
int time; /* time offset to next event*/
};
@@ -41,64 +40,47 @@ callout_init()
Q = (struct timeout_q *) 0;
}
-void
-free_all_callouts()
-{
- struct timeout_q *p;
-
- while (Q) {
- p = Q;
- Q = Q->next;
- free(p);
- }
-}
-
/*
- * elapsed_time seconds have passed; perform all the events that should
- * happen.
+ * signal handler for SIGALARM that is called once every second
*/
void
-age_callout_queue(elapsed_time)
- int elapsed_time;
+age_callout_queue()
{
struct timeout_q *ptr;
- int i = 0;
+
+ if (in_callout)
+ return;
- for (ptr = Q; ptr; ptr = Q, i++) {
- if (ptr->time > elapsed_time) {
- ptr->time -= elapsed_time;
- return;
- } else {
- elapsed_time -= ptr->time;
+ in_callout = 1;
+ ptr = Q;
+
+ while (ptr) {
+ if (!ptr->time) {
+ /* timeout has happened */
Q = Q->next;
- IF_DEBUG(DEBUG_TIMEOUT)
- log(LOG_DEBUG, 0, "about to call timeout %d (#%d)", ptr->id, i);
+
+ in_callout = 0;
if (ptr->func)
ptr->func(ptr->data);
+ in_callout = 1;
+
free(ptr);
+ ptr = Q;
}
- }
-}
-
-/*
- * Return in how many seconds age_callout_queue() would like to be called.
- * Return -1 if there are no events pending.
- */
-int
-timer_nextTimer()
-{
- if (Q) {
- if (Q->time < 0) {
- log(LOG_WARNING, 0, "timer_nextTimer top of queue says %d",
- Q->time);
- return 0;
+ else {
+ ptr->time --;
+#ifdef IGMP_DEBUG
+ log(LOG_DEBUG,0,"[callout, age_callout_queue] -- time (%d)", ptr->time);
+#endif /* IGMP_DEBUG */
+ in_callout = 0; return;
}
- return Q->time;
}
- return -1;
+ in_callout = 0;
+ return;
}
+
/*
* sets the timer
*/
@@ -106,15 +88,20 @@ int
timer_setTimer(delay, action, data)
int delay; /* number of units for timeout */
cfunc_t action; /* function to be called on timeout */
- void *data; /* what to call the timeout function with */
+ char *data; /* what to call the timeout function with */
{
struct timeout_q *ptr, *node, *prev;
- int i = 0;
+
+ if (in_callout)
+ return -1;
+
+ in_callout = 1;
/* create a node */
node = (struct timeout_q *)malloc(sizeof(struct timeout_q));
if (node == 0) {
log(LOG_WARNING, 0, "Malloc Failed in timer_settimer\n");
+ in_callout = 0;
return -1;
}
node->func = action;
@@ -144,8 +131,7 @@ timer_setTimer(delay, action, data)
prev->next = node;
ptr->time -= node->time;
print_Q();
- IF_DEBUG(DEBUG_TIMEOUT)
- log(LOG_DEBUG, 0, "created timeout %d (#%d)", node->id, i);
+ in_callout = 0;
return node->id;
} else {
/* keep moving */
@@ -154,46 +140,29 @@ timer_setTimer(delay, action, data)
prev = ptr;
ptr = ptr->next;
}
- i++;
}
prev->next = node;
}
print_Q();
- IF_DEBUG(DEBUG_TIMEOUT)
- log(LOG_DEBUG, 0, "created timeout %d (#%d)", node->id, i);
+ in_callout = 0;
return node->id;
}
-/* returns the time until the timer is scheduled */
-int
-timer_leftTimer(timer_id)
- int timer_id;
-{
- struct timeout_q *ptr;
- int left = 0;
-
- if (!timer_id)
- return -1;
-
- for (ptr = Q; ptr; ptr = ptr->next) {
- left += ptr->time;
- if (ptr->id == timer_id)
- return left;
- }
- return -1;
-}
-/* clears the associated timer. Returns 1 if succeeded. */
-int
+/* clears the associated timer */
+void
timer_clearTimer(timer_id)
int timer_id;
{
struct timeout_q *ptr, *prev;
- int i = 0;
+ if (in_callout)
+ return;
if (!timer_id)
- return 0;
+ return;
+ in_callout = 1;
+
prev = ptr = Q;
/*
@@ -216,22 +185,17 @@ timer_clearTimer(timer_id)
if (ptr->next != 0)
(ptr->next)->time += ptr->time;
- if (ptr->data)
- free(ptr->data);
- IF_DEBUG(DEBUG_TIMEOUT)
- log(LOG_DEBUG, 0, "deleted timer %d (#%d)", ptr->id, i);
+ free(ptr->data);
free(ptr);
print_Q();
- return 1;
+ in_callout = 0;
+ return;
}
prev = ptr;
ptr = ptr->next;
- i++;
}
- IF_DEBUG(DEBUG_TIMEOUT)
- log(LOG_DEBUG, 0, "failed to delete timer %d (#%d)", timer_id, i);
print_Q();
- return 0;
+ in_callout = 0;
}
#ifdef IGMP_DEBUG
@@ -243,8 +207,22 @@ print_Q()
{
struct timeout_q *ptr;
- IF_DEBUG(DEBUG_TIMEOUT)
- for (ptr = Q; ptr; ptr = ptr->next)
- log(LOG_DEBUG, 0, "(%d,%d) ", ptr->id, ptr->time);
+ for(ptr = Q; ptr; ptr = ptr->next)
+ log(LOG_DEBUG,0,"(%d,%d) ", ptr->id, ptr->time);
}
#endif /* IGMP_DEBUG */
+int
+secs_remaining( timer_id)
+ int timer_id;
+{
+ struct timeout_q *ptr;
+ int left=0;
+
+ for (ptr = Q; ptr && ptr->id != timer_id; ptr = ptr->next)
+ left += ptr->time;
+
+ if (!ptr) /* not found */
+ return 0;
+
+ return left + ptr->time;
+}
diff --git a/usr.sbin/mrouted/cfparse.y b/usr.sbin/mrouted/cfparse.y
index 14e206e4f6ff..e5a1dc9b9f5f 100644
--- a/usr.sbin/mrouted/cfparse.y
+++ b/usr.sbin/mrouted/cfparse.y
@@ -4,8 +4,7 @@
*
* Written by Bill Fenner, NRL, 1994
*
- * $Id: cfparse.y,v 1.8 1998/06/09 05:01:27 imp Exp $
- * cfparse.y,v 3.8.4.30 1998/03/01 01:48:58 fenner Exp
+ * $Id: cfparse.y,v 1.7 1997/02/22 16:06:48 peter Exp $
*/
#include <stdio.h>
#ifdef __STDC__
@@ -30,23 +29,19 @@ int yyparse __P((void));
static FILE *f;
+extern int udp_socket;
char *configfilename = _PATH_MROUTED_CONF;
extern int cache_lifetime;
-extern int prune_lifetime;
-
-/* imported from config.c, with slight memory leak */
-extern struct ifconf ifc;
-
-int allow_black_holes = 0;
+extern int max_prune_lifetime;
static int lineno;
+static struct ifreq ifbuf[32];
+static struct ifconf ifc;
static struct uvif *v;
-static int order, state;
-static int noflood = 0;
-static int rexmit = VIFF_REXMIT_PRUNES;
+static int order;
struct addrmask {
u_int32 addr;
@@ -71,17 +66,12 @@ int numbounds = 0; /* Number of named boundaries */
char *ptr;
struct addrmask addrmask;
u_int32 addr;
- struct vf_element *filterelem;
};
-%token CACHE_LIFETIME PRUNE_LIFETIME PRUNING BLACK_HOLE NOFLOOD
+%token CACHE_LIFETIME PRUNING
%token PHYINT TUNNEL NAME
-%token DISABLE IGMPV1 SRCRT BESIDE
+%token DISABLE IGMPV1 SRCRT
%token METRIC THRESHOLD RATE_LIMIT BOUNDARY NETMASK ALTNET ADVERT_METRIC
-%token FILTER ACCEPT DENY EXACT BIDIR REXMIT_PRUNES REXMIT_PRUNES2
-%token PASSIVE ALLOW_NONPRUNERS
-%token NOTRANSIT BLASTER FORCE_LEAF
-%token PRUNE_LIFETIME2 NOFLOOD2
%token SYSNAM SYSCONTACT SYSVERSION SYSLOCATION
%token <num> BOOLEAN
%token <num> NUMBER
@@ -91,7 +81,6 @@ int numbounds = 0; /* Number of named boundaries */
%type <addr> interface addrname
%type <addrmask> bound boundary addrmask
-%type <filterelem> filter filtlist filtelement filtelem
%start conf
@@ -109,8 +98,6 @@ stmt : error
vifi_t vifi;
- state++;
-
if (order)
fatal("phyints must appear before tunnels");
@@ -140,9 +127,12 @@ stmt : error
fatal("Tunnel local address %s is not mine",
inet_fmt($2, s1));
- if (((ntohl($2) & IN_CLASSA_NET) >> IN_CLASSA_NSHIFT) ==
- IN_LOOPBACKNET)
- fatal("Tunnel local address %s is a loopback address",
+ strncpy(ffr.ifr_name, ifr->ifr_name, IFNAMSIZ);
+ ffr.ifr_name[IFNAMSIZ-1]='\0';
+ if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ffr)<0)
+ fatal("ioctl SIOCGIFFLAGS on %s",ffr.ifr_name);
+ if (ffr.ifr_flags & IFF_LOOPBACK)
+ fatal("Tunnel local address %s is a loopback interface",
inet_fmt($2, s1));
if (ifconfaddr(&ifc, $3) != 0)
@@ -158,26 +148,30 @@ stmt : error
inet_fmt($3, s1));
} else if (!(v->uv_flags & VIFF_DISABLED)) {
if (($3 & v->uv_subnetmask) == v->uv_subnet)
- fatal("Unnecessary tunnel to %s, same subnet as vif %d (%s)",
- inet_fmt($3,s1), vifi, v->uv_name);
+ fatal("Unnecessary tunnel to %s",
+ inet_fmt($3,s1));
}
if (numvifs == MAXVIFS)
fatal("too many vifs");
- strncpy(ffr.ifr_name, ifr->ifr_name, IFNAMSIZ);
- if (ioctl(udp_socket, SIOCGIFFLAGS, (char *)&ffr)<0)
- fatal("ioctl SIOCGIFFLAGS on %s", ffr.ifr_name);
-
v = &uvifs[numvifs];
- zero_vif(v, 1);
- v->uv_flags = VIFF_TUNNEL | rexmit | noflood;
- v->uv_flags |= VIFF_OTUNNEL; /*XXX*/
+ v->uv_flags = VIFF_TUNNEL;
+ v->uv_metric = DEFAULT_METRIC;
+ v->uv_admetric = 0;
+ v->uv_rate_limit= DEFAULT_TUN_RATE_LIMIT;
+ v->uv_threshold = DEFAULT_THRESHOLD;
v->uv_lcl_addr = $2;
v->uv_rmt_addr = $3;
- v->uv_dst_addr = $3;
+ v->uv_subnet = 0;
+ v->uv_subnetmask= 0;
+ v->uv_subnetbcast= 0;
strncpy(v->uv_name, ffr.ifr_name, IFNAMSIZ);
v->uv_name[IFNAMSIZ-1]='\0';
+ v->uv_groups = NULL;
+ v->uv_neighbors = NULL;
+ v->uv_acl = NULL;
+ v->uv_addrs = NULL;
if (!(ffr.ifr_flags & IFF_UP)) {
v->uv_flags |= VIFF_DOWN;
@@ -186,101 +180,17 @@ stmt : error
}
tunnelmods
{
+ log(LOG_INFO, 0,
+ "installing tunnel from %s to %s as vif #%u - rate=%d",
+ inet_fmt($2, s1), inet_fmt($3, s2),
+ numvifs, v->uv_rate_limit);
- if (!(v->uv_flags & VIFF_OTUNNEL)) {
- init_ipip_on_vif(v);
- }
-
- log(LOG_INFO, 0,
- "installing tunnel from %s to %s as vif #%u - rate=%d",
- inet_fmt($2, s1), inet_fmt($3, s2),
- numvifs, v->uv_rate_limit);
-
- ++numvifs;
-
+ ++numvifs;
}
- | CACHE_LIFETIME NUMBER {
-
- if ($2 < MIN_CACHE_LIFETIME) {
- warn("cache_lifetime %d must be at least %d",
- $2, MIN_CACHE_LIFETIME);
- } else {
- cache_lifetime = $2;
- }
-
- }
- | PRUNE_LIFETIME NUMBER {
-
- if ($2 < MIN_PRUNE_LIFETIME) {
- warn("prune_lifetime %d must be at least %d",
- $2, MIN_PRUNE_LIFETIME);
- } else {
- prune_lifetime = $2;
- }
-
- }
- | PRUNING BOOLEAN {
-
- if ($2 != 1) {
- warn("Disabling pruning is no longer supported");
- }
-
- }
- | BLACK_HOLE {
-#ifdef ALLOW_BLACK_HOLES
- allow_black_holes = 1;
-#endif
- }
- /*
- * Turn off initial flooding (until subordinateness is learned
- * via route exchange) on all phyints and set the default for
- * all further tunnels.
- */
- | NOFLOOD {
-
- vifi_t vifi;
-
- noflood = VIFF_NOFLOOD;
- for (vifi = 0, v = uvifs;
- vifi < numvifs;
- ++vifi, ++v)
- v->uv_flags |= VIFF_NOFLOOD;
-
- }
- /*
- * Turn on prune retransmission on all interfaces.
- * Tunnels default to retransmitting, so this just
- * needs to turn on phyints.
- */
- | REXMIT_PRUNES {
-
- vifi_t vifi;
-
- for (vifi = 0, v = uvifs;
- vifi < numvifs;
- ++vifi, ++v)
- v->uv_flags |= VIFF_REXMIT_PRUNES;
-
+ | PRUNING BOOLEAN { pruning = $2; }
+ | CACHE_LIFETIME NUMBER { cache_lifetime = $2;
+ max_prune_lifetime = cache_lifetime * 2;
}
- /*
- * If true, do as above. If false, no need to turn
- * it off for phyints since they default to not
- * rexmit; need to set flag to not rexmit on tunnels.
- */
- | REXMIT_PRUNES BOOLEAN {
-
- if ($2) {
- vifi_t vifi;
-
- for (vifi = 0, v = uvifs;
- vifi < numvifs;
- ++vifi, ++v)
- v->uv_flags |= VIFF_REXMIT_PRUNES;
- } else {
- rexmit = 0;
- }
-
- }
| NAME STRING boundary { if (numbounds >= MAXBOUNDS) {
fatal("Too many named boundaries (max %d)", MAXBOUNDS);
}
@@ -316,16 +226,6 @@ tunnelmods : /* empty */
;
tunnelmod : mod
- | BESIDE { v->uv_flags |= VIFF_OTUNNEL; }
- | BESIDE BOOLEAN {
-
- if ($2) {
- v->uv_flags |= VIFF_OTUNNEL;
- } else {
- v->uv_flags &= ~VIFF_OTUNNEL;
- }
-
- }
| SRCRT { fatal("Source-route tunnels not supported"); }
;
@@ -377,20 +277,6 @@ ifmod : mod
warn("Expected address after altnet keyword, ignored");
}
- | FORCE_LEAF {
-
- v->uv_flags |= VIFF_FORCE_LEAF;
-
- }
- | FORCE_LEAF BOOLEAN {
-
- if ($2) {
- v->uv_flags |= VIFF_FORCE_LEAF;
- } else {
- v->uv_flags &= ~VIFF_FORCE_LEAF;
- }
-
- }
;
mod : THRESHOLD NUMBER { if ($2 < 1 || $2 > 255)
@@ -450,122 +336,6 @@ mod : THRESHOLD NUMBER { if ($2 < 1 || $2 > 255)
warn("Expected boundary spec after boundary keyword, ignored");
}
- | REXMIT_PRUNES2 {
-
- v->uv_flags |= VIFF_REXMIT_PRUNES;
-
- }
- | REXMIT_PRUNES2 BOOLEAN {
-
- if ($2) {
- v->uv_flags |= VIFF_REXMIT_PRUNES;
- } else {
- v->uv_flags &= ~VIFF_REXMIT_PRUNES;
- }
-
- }
- | PASSIVE {
-
- v->uv_flags |= VIFF_PASSIVE;
-
- }
- | NOFLOOD2 {
-
- v->uv_flags |= VIFF_NOFLOOD;
-
- }
- | NOTRANSIT {
-
- v->uv_flags |= VIFF_NOTRANSIT;
-
- }
- | BLASTER {
-
- v->uv_flags |= VIFF_BLASTER;
- blaster_alloc(v - uvifs);
-
- }
- | ALLOW_NONPRUNERS {
-
- v->uv_flags |= VIFF_ALLOW_NONPRUNERS;
-
- }
- | PRUNE_LIFETIME2 NUMBER {
-
- if ($2 < MIN_PRUNE_LIFETIME) {
- warn("prune_lifetime %d must be at least %d",
- $2, MIN_PRUNE_LIFETIME);
- } else {
- v->uv_prune_lifetime = $2;
- }
-
- }
- | ACCEPT filter {
-
- if (v->uv_filter == NULL) {
- struct vif_filter *v_filter;
-
- v_filter = (struct vif_filter *)malloc(sizeof(struct vif_filter));
- if (v_filter == NULL)
- fatal("out of memory");
- v_filter->vf_flags = 0;
- v_filter->vf_type = VFT_ACCEPT;
- v_filter->vf_filter = $2;
- v->uv_filter = v_filter;
- } else if (v->uv_filter->vf_type != VFT_ACCEPT) {
- fatal("can't accept and deny");
- } else {
- struct vf_element *p;
-
- p = v->uv_filter->vf_filter;
- while (p->vfe_next)
- p = p->vfe_next;
- p->vfe_next = $2;
- }
-
- }
- | ACCEPT {
-
- warn("Expected filter spec after accept keyword, ignored");
-
- }
- | DENY filter {
-
- if (v->uv_filter == NULL) {
- struct vif_filter *v_filter;
-
- v_filter = (struct vif_filter *)malloc(sizeof(struct vif_filter));
- if (v_filter == NULL)
- fatal("out of memory");
- v_filter->vf_flags = 0;
- v_filter->vf_type = VFT_DENY;
- v_filter->vf_filter = $2;
- v->uv_filter = v_filter;
- } else if (v->uv_filter->vf_type != VFT_DENY) {
- fatal("can't accept and deny");
- } else {
- struct vf_element *p;
-
- p = v->uv_filter->vf_filter;
- while (p->vfe_next)
- p = p->vfe_next;
- p->vfe_next = $2;
- }
-
- }
- | DENY {
-
- warn("Expected filter spec after deny keyword, ignored");
-
- }
- | BIDIR {
-
- if (v->uv_filter == NULL) {
- fatal("bidir goes after filters");
- }
- v->uv_filter->vf_flags |= VFF_BIDIR;
-
- }
;
interface : ADDR { $$ = $1; }
@@ -608,9 +378,6 @@ bound : boundary { $$ = $1; }
boundary : ADDRMASK {
-#ifdef ALLOW_BLACK_HOLES
- if (!allow_black_holes)
-#endif
if ((ntohl($1.addr) & 0xff000000) != 0xef000000) {
fatal("Boundaries must be 239.x.x.x, not %s/%d",
inet_fmt($1.addr, s1), $1.mask);
@@ -623,35 +390,6 @@ boundary : ADDRMASK {
addrmask : ADDRMASK { $$ = $1; }
| ADDR { $$.addr = $1; $$.mask = 0; }
;
-
-filter : filtlist { $$ = $1; }
- | STRING { fatal("named filters no implemented yet"); }
- ;
-
-filtlist : filtelement { $$ = $1; }
- | filtelement filtlist { $1->vfe_next = $2; $$ = $1; }
- ;
-
-filtelement : filtelem { $$ = $1; }
- | filtelem EXACT { $1->vfe_flags |= VFEF_EXACT; $$ = $1; }
- ;
-
-filtelem : ADDRMASK {
-
- struct vf_element *vfe;
-
- vfe = (struct vf_element *)malloc(sizeof(struct vf_element));
- if (vfe == NULL)
- fatal("out of memory");
-
- vfe->vfe_addr = $1.addr;
- VAL_TO_MASK(vfe->vfe_mask, $1.mask);
- vfe->vfe_flags = 0;
- vfe->vfe_next = NULL;
-
- $$ = vfe;
-
- }
%%
#ifdef __STDC__
static void
@@ -717,6 +455,7 @@ next_word()
{
static char buf[1024];
static char *p=NULL;
+ extern FILE *f;
char *q;
while (1) {
@@ -755,75 +494,47 @@ next_word()
}
}
-/*
- * List of keywords. Must have an empty record at the end to terminate
- * list. If a second value is specified, the first is used at the beginning
- * of the file and the second is used while parsing interfaces (e.g. after
- * the first "phyint" or "tunnel" keyword).
- */
-static struct keyword {
- char *word;
- int val1;
- int val2;
-} words[] = {
- { "cache_lifetime", CACHE_LIFETIME },
- { "prune_lifetime", PRUNE_LIFETIME, PRUNE_LIFETIME2 },
- { "pruning", PRUNING },
- { "phyint", PHYINT },
- { "tunnel", TUNNEL },
- { "disable", DISABLE },
- { "metric", METRIC },
- { "advert_metric", ADVERT_METRIC },
- { "threshold", THRESHOLD },
- { "rate_limit", RATE_LIMIT },
- { "force_leaf", FORCE_LEAF },
- { "srcrt", SRCRT },
- { "sourceroute", SRCRT },
- { "boundary", BOUNDARY },
- { "netmask", NETMASK },
- { "igmpv1", IGMPV1 },
- { "altnet", ALTNET },
- { "name", NAME },
- { "accept", ACCEPT },
- { "deny", DENY },
- { "exact", EXACT },
- { "bidir", BIDIR },
- { "allow_nonpruners", ALLOW_NONPRUNERS },
-#ifdef ALLOW_BLACK_HOLES
- { "allow_black_holes", BLACK_HOLE },
-#endif
- { "noflood", NOFLOOD, NOFLOOD2},
- { "notransit", NOTRANSIT },
- { "blaster", BLASTER },
- { "rexmit_prunes", REXMIT_PRUNES, REXMIT_PRUNES2 },
- { "passive", PASSIVE },
- { "beside", BESIDE },
-#ifdef SNMP
- { "sysName", SYSNAM },
- { "sysContact", SYSCONTACT },
- { "sysVersion", SYSVERSION },
- { "sysLocation", SYSLOCATION },
-#endif
- { NULL, 0 }
-};
-
-
static int
yylex()
{
int n;
u_int32 addr;
char *q;
- struct keyword *w;
if ((q = next_word()) == NULL) {
return 0;
}
- for (w = words; w->word; w++)
- if (!strcmp(q, w->word))
- return (state && w->val2) ? w->val2 : w->val1;
-
+ if (!strcmp(q,"cache_lifetime"))
+ return CACHE_LIFETIME;
+ if (!strcmp(q,"pruning"))
+ return PRUNING;
+ if (!strcmp(q,"phyint"))
+ return PHYINT;
+ if (!strcmp(q,"tunnel"))
+ return TUNNEL;
+ if (!strcmp(q,"disable"))
+ return DISABLE;
+ if (!strcmp(q,"metric"))
+ return METRIC;
+ if (!strcmp(q,"advert_metric"))
+ return ADVERT_METRIC;
+ if (!strcmp(q,"threshold"))
+ return THRESHOLD;
+ if (!strcmp(q,"rate_limit"))
+ return RATE_LIMIT;
+ if (!strcmp(q,"srcrt") || !strcmp(q,"sourceroute"))
+ return SRCRT;
+ if (!strcmp(q,"boundary"))
+ return BOUNDARY;
+ if (!strcmp(q,"netmask"))
+ return NETMASK;
+ if (!strcmp(q,"igmpv1"))
+ return IGMPV1;
+ if (!strcmp(q,"altnet"))
+ return ALTNET;
+ if (!strcmp(q,"name"))
+ return NAME;
if (!strcmp(q,"on") || !strcmp(q,"yes")) {
yylval.num = 1;
return BOOLEAN;
@@ -861,6 +572,14 @@ yylex()
return NUMBER;
}
#ifdef SNMP
+ if (!strcmp(q,"sysName"))
+ return SYSNAM;
+ if (!strcmp(q,"sysContact"))
+ return SYSCONTACT;
+ if (!strcmp(q,"sysVersion"))
+ return SYSVERSION;
+ if (!strcmp(q,"sysLocation"))
+ return SYSLOCATION;
if (*q=='"') {
if (q[ strlen(q)-1 ]=='"')
q[ strlen(q)-1 ]='\0'; /* trash trailing quote */
@@ -875,8 +594,9 @@ yylex()
void
config_vifs_from_file()
{
+ extern FILE *f;
+
order = 0;
- state = 0;
numbounds = 0;
lineno = 0;
@@ -886,6 +606,11 @@ config_vifs_from_file()
return;
}
+ ifc.ifc_buf = (char *)ifbuf;
+ ifc.ifc_len = sizeof(ifbuf);
+ if (ioctl(udp_socket, SIOCGIFCONF, (char *)&ifc) < 0)
+ log(LOG_ERR, errno, "ioctl SIOCGIFCONF");
+
yyparse();
fclose(f);
@@ -918,7 +643,7 @@ ifconfaddr(ifcp, a)
if (ifrp->ifr_addr.sa_family == AF_INET &&
((struct sockaddr_in *)&ifrp->ifr_addr)->sin_addr.s_addr == a)
return (ifrp);
-#ifdef HAVE_SA_LEN
+#if (defined(BSD) && (BSD >= 199006))
n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
if (n < sizeof(*ifrp))
++ifrp;
diff --git a/usr.sbin/mrouted/config.c b/usr.sbin/mrouted/config.c
index 544199e40e23..61f43eba6361 100644
--- a/usr.sbin/mrouted/config.c
+++ b/usr.sbin/mrouted/config.c
@@ -5,21 +5,15 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
- *
- *
- * config.c,v 3.8.4.10 1998/01/06 01:57:41 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: config.c,v 1.12 1998/06/09 05:01:29 imp Exp $";
+ "$Id: config.c,v 1.11 1998/01/16 07:17:41 charnier Exp $";
#endif /* not lint */
#include "defs.h"
-
-struct ifconf ifc;
-
/*
* Query the kernel to find network interfaces that are multicast-capable
* and install them in the uvifs array.
@@ -27,48 +21,28 @@ struct ifconf ifc;
void
config_vifs_from_kernel()
{
+ struct ifreq ifbuf[32];
struct ifreq *ifrp, *ifend;
+ struct ifconf ifc;
register struct uvif *v;
register vifi_t vifi;
int n;
u_int32 addr, mask, subnet;
short flags;
- int num_ifreq = 32;
-
- ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
- ifc.ifc_buf = malloc(ifc.ifc_len);
- while (ifc.ifc_buf) {
- if (ioctl(udp_socket, SIOCGIFCONF, (char *)&ifc) < 0)
- log(LOG_ERR, errno, "ioctl SIOCGIFCONF");
-
- /*
- * If the buffer was large enough to hold all the addresses
- * then break out, otherwise increase the buffer size and
- * try again.
- *
- * The only way to know that we definitely had enough space
- * is to know that there was enough space for at least one
- * more struct ifreq. ???
- */
- if ((num_ifreq * sizeof(struct ifreq)) >=
- ifc.ifc_len + sizeof(struct ifreq))
- break;
- num_ifreq *= 2;
- ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
- ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
- }
- if (ifc.ifc_buf == NULL)
- log(LOG_ERR, 0, "config_vifs_from_kernel: ran out of memory");
+ ifc.ifc_buf = (char *)ifbuf;
+ ifc.ifc_len = sizeof(ifbuf);
+ if (ioctl(udp_socket, SIOCGIFCONF, (char *)&ifc) < 0)
+ log(LOG_ERR, errno, "ioctl SIOCGIFCONF");
- ifrp = (struct ifreq *)ifc.ifc_buf;
- ifend = (struct ifreq *)(ifc.ifc_buf + ifc.ifc_len);
+ ifrp = (struct ifreq *)ifbuf;
+ ifend = (struct ifreq *)((char *)ifbuf + ifc.ifc_len);
/*
* Loop through all of the interfaces.
*/
for (; ifrp < ifend; ifrp = (struct ifreq *)((char *)ifrp + n)) {
struct ifreq ifr;
-#ifdef HAVE_SA_LEN
+#if BSD >= 199006
n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
if (n < sizeof(*ifrp))
n = sizeof(*ifrp);
@@ -123,12 +97,6 @@ config_vifs_from_kernel()
* one already installed in the uvifs array.
*/
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
- if (strcmp(v->uv_name, ifr.ifr_name) == 0) {
- log(LOG_DEBUG, 0, "skipping %s (%s on subnet %s) (alias for vif#%u?)",
- v->uv_name, inet_fmt(addr, s1),
- inet_fmts(subnet, mask, s2), vifi);
- break;
- }
if ((addr & v->uv_subnetmask) == v->uv_subnet ||
(v->uv_subnet & mask) == subnet) {
log(LOG_WARNING, 0, "ignoring %s, same subnet as %s",
@@ -146,16 +114,22 @@ config_vifs_from_kernel()
continue;
}
v = &uvifs[numvifs];
- zero_vif(v, 0);
+ v->uv_flags = 0;
+ v->uv_metric = DEFAULT_METRIC;
+ v->uv_admetric = 0;
+ v->uv_rate_limit = DEFAULT_PHY_RATE_LIMIT;
+ v->uv_threshold = DEFAULT_THRESHOLD;
v->uv_lcl_addr = addr;
+ v->uv_rmt_addr = 0;
v->uv_subnet = subnet;
v->uv_subnetmask = mask;
v->uv_subnetbcast = subnet | ~mask;
strncpy(v->uv_name, ifr.ifr_name, IFNAMSIZ);
v->uv_name[IFNAMSIZ-1] = '\0';
-
- if (flags & IFF_POINTOPOINT)
- v->uv_flags |= VIFF_REXMIT_PRUNES;
+ v->uv_groups = NULL;
+ v->uv_neighbors = NULL;
+ v->uv_acl = NULL;
+ v->uv_addrs = NULL;
log(LOG_INFO,0,"installing %s (%s on subnet %s) as vif #%u - rate=%d",
v->uv_name, inet_fmt(addr, s1), inet_fmts(subnet, mask, s2),
diff --git a/usr.sbin/mrouted/defs.h b/usr.sbin/mrouted/defs.h
index 00a8b5ba8eeb..6d11925594c6 100644
--- a/usr.sbin/mrouted/defs.h
+++ b/usr.sbin/mrouted/defs.h
@@ -7,8 +7,7 @@
* Leland Stanford Junior University.
*
*
- * $Id: defs.h,v 1.10 1997/02/22 16:06:51 peter Exp $
- * defs.h,v 3.8.4.15 1998/03/01 02:51:42 fenner Exp
+ * $Id$
*/
@@ -27,11 +26,7 @@
#ifdef SYSV
#include <sys/sockio.h>
#endif
-#ifdef _AIX
-#include <time.h>
-#endif
#include <sys/time.h>
-#include <sys/uio.h>
#include <net/if.h>
#define rtentry kern_rtentry /* XXX !!! UGH */
#include <net/route.h>
@@ -39,16 +34,7 @@
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
#include <netinet/igmp.h>
-#ifdef __FreeBSD__ /* sigh */
-#include <osreldate.h>
-#if __FreeBSD_version >= 220000
-#define rtentry kernel_rtentry
-#include <net/route.h>
-#undef rtentry
-#endif
-#endif
#include <netinet/ip_mroute.h>
#ifdef RSRR
#include <sys/un.h>
@@ -69,7 +55,6 @@ typedef void (*cfunc_t) __P((void *));
typedef void (*ihfunc_t) __P((int, fd_set *));
#include "dvmrp.h"
-#include "igmpv2.h"
#include "vif.h"
#include "route.h"
#include "prune.h"
@@ -89,17 +74,21 @@ typedef void (*ihfunc_t) __P((int, fd_set *));
#define TIMER_INTERVAL ROUTE_MAX_REPORT_DELAY
+#define VENDOR_CODE 1 /* Get a new vendor code if you make significant
+ * changes to mrouted. */
+
#define PROTOCOL_VERSION 3 /* increment when packet format/content changes */
-#define MROUTED_VERSION 9 /* not in DVMRP packets at all */
-#define DVMRP_CONSTANT 0x000eff00 /* constant portion of 'group' field */
+#define MROUTED_VERSION 8 /* increment on local changes or bug fixes, */
+ /* reset to 0 whever PROTOCOL_VERSION increments */
-#define MROUTED_LEVEL (DVMRP_CONSTANT | PROTOCOL_VERSION)
+#define MROUTED_LEVEL ((MROUTED_VERSION << 8) | PROTOCOL_VERSION | \
+ ((NF_PRUNE | NF_GENID | NF_MTRACE) << 16) | \
+ (VENDOR_CODE << 24))
/* for IGMP 'group' field of DVMRP messages */
#define LEAF_FLAGS (( vifs_with_neighbors == 1 ) ? 0x010000 : 0)
/* more for IGMP 'group' field of DVMRP messages */
-
#define DEL_RTE_GROUP 0
#define DEL_ALL_ROUTES 1
/* for Deleting kernel table entries */
@@ -123,10 +112,7 @@ typedef void (*ihfunc_t) __P((int, fd_set *));
#define bcopy(a, b, c) memcpy(b, a, c)
#define bzero(s, n) memset((s), 0, (n))
#define setlinebuf(s) setvbuf(s, NULL, _IOLBF, 0)
-#endif
-
-#if defined(_AIX) || (defined(BSD) && (BSD >= 199103))
-#define HAVE_SA_LEN
+#define signal(s,f) sigset(s,f)
#endif
/*
@@ -144,27 +130,10 @@ extern u_int32 allrtrs_group;
extern u_int32 dvmrp_group;
extern u_int32 dvmrp_genid;
-#define IF_DEBUG(l) if (debug && debug & (l))
-
-#define DEBUG_PKT 0x0001
-#define DEBUG_PRUNE 0x0002
-#define DEBUG_ROUTE 0x0004
-#define DEBUG_PEER 0x0008
-#define DEBUG_CACHE 0x0010
-#define DEBUG_TIMEOUT 0x0020
-#define DEBUG_IF 0x0040
-#define DEBUG_MEMBER 0x0080
-#define DEBUG_TRACE 0x0100
-#define DEBUG_IGMP 0x0200
-#define DEBUG_RTDETAIL 0x0400
-#define DEBUG_KERN 0x0800
-#define DEBUG_RSRR 0x1000
-#define DEBUG_ICMP 0x2000
-
-#define DEFAULT_DEBUG 0x02de /* default if "-d" given without value */
+#define DEFAULT_DEBUG 2 /* default if "-d" given without value */
extern int debug;
-extern int did_final_init;
+extern u_char pruning;
extern int routes_changed;
extern int delay_change_reports;
@@ -199,129 +168,86 @@ extern char * sys_errlist[];
#ifndef IGMP_PIM
#define IGMP_PIM 0x14
#endif
-#ifndef IPPROTO_IPIP
-#define IPPROTO_IPIP 4
-#endif
-/*
- * The original multicast releases defined
- * IGMP_HOST_{MEMBERSHIP_QUERY,MEMBERSHIP_REPORT,NEW_MEMBERSHIP_REPORT
- * ,LEAVE_MESSAGE}. Later releases removed the HOST and inserted
- * the IGMP version number. NetBSD inserted the version number in
- * a different way. mrouted uses the new names, so we #define them
- * to the old ones if needed.
- */
-#if !defined(IGMP_MEMBERSHIP_QUERY) && defined(IGMP_HOST_MEMBERSHIP_QUERY)
+#ifndef IGMP_MEMBERSHIP_QUERY
#define IGMP_MEMBERSHIP_QUERY IGMP_HOST_MEMBERSHIP_QUERY
-#define IGMP_V2_LEAVE_GROUP IGMP_HOST_LEAVE_MESSAGE
-#endif
-#ifndef IGMP_V1_MEMBERSHIP_REPORT
-#ifdef IGMP_HOST_MEMBERSHIP_REPORT
#define IGMP_V1_MEMBERSHIP_REPORT IGMP_HOST_MEMBERSHIP_REPORT
#define IGMP_V2_MEMBERSHIP_REPORT IGMP_HOST_NEW_MEMBERSHIP_REPORT
-#endif
-#ifdef IGMP_v1_HOST_MEMBERSHIP_REPORT
-#define IGMP_V1_MEMBERSHIP_REPORT IGMP_v1_HOST_MEMBERSHIP_REPORT
-#define IGMP_V2_MEMBERSHIP_REPORT IGMP_v2_HOST_MEMBERSHIP_REPORT
-#endif
+#define IGMP_V2_LEAVE_GROUP IGMP_HOST_LEAVE_MESSAGE
#endif
-/*
- * NetBSD also renamed the mtrace types.
- */
-#if !defined(IGMP_MTRACE_RESP) && defined(IGMP_MTRACE_REPLY)
-#define IGMP_MTRACE_RESP IGMP_MTRACE_REPLY
-#define IGMP_MTRACE IGMP_MTRACE_QUERY
-#endif
/* main.c */
-extern char * scaletime __P((u_long));
extern void log __P((int, int, char *, ...));
-extern int register_input_handler __P((int, ihfunc_t));
+extern int register_input_handler __P((int fd, ihfunc_t func));
/* igmp.c */
extern void init_igmp __P((void));
-extern void accept_igmp __P((int));
-extern void build_igmp __P((u_int32, u_int32, int, int, u_int32,
- int));
-extern void send_igmp __P((u_int32, u_int32, int, int, u_int32,
- int));
-extern char * igmp_packet_kind __P((u_int, u_int));
-extern int igmp_debug_kind __P((u_int, u_int));
-
-/* icmp.c */
-extern void init_icmp __P((void));
-
-/* ipip.c */
-extern void init_ipip __P((void));
-extern void init_ipip_on_vif __P((struct uvif *));
-extern void send_ipip __P((u_int32, u_int32, int, int, u_int32,
- int, struct uvif *));
+extern void accept_igmp __P((int recvlen));
+extern void send_igmp __P((u_int32 src, u_int32 dst, int type,
+ int code, u_int32 group,
+ int datalen));
/* callout.c */
extern void callout_init __P((void));
-extern void free_all_callouts __P((void));
-extern void age_callout_queue __P((int));
-extern int timer_nextTimer __P((void));
-extern int timer_setTimer __P((int, cfunc_t, void *));
-extern int timer_clearTimer __P((int));
-extern int timer_leftTimer __P((int));
+extern void age_callout_queue __P((void));
+extern int timer_setTimer __P((int delay, cfunc_t action,
+ char *data));
+extern void timer_clearTimer __P((int timer_id));
/* route.c */
extern void init_routes __P((void));
extern void start_route_updates __P((void));
-extern void update_route __P((u_int32, u_int32, u_int, u_int32,
- vifi_t, struct listaddr *));
+extern void update_route __P((u_int32 origin, u_int32 mask,
+ u_int metric, u_int32 src,
+ vifi_t vifi));
extern void age_routes __P((void));
extern void expire_all_routes __P((void));
extern void free_all_routes __P((void));
-extern void accept_probe __P((u_int32, u_int32, char *, int,
- u_int32));
-extern void accept_report __P((u_int32, u_int32, char *, int,
- u_int32));
+extern void accept_probe __P((u_int32 src, u_int32 dst,
+ char *p, int datalen,
+ u_int32 level));
+extern void accept_report __P((u_int32 src, u_int32 dst,
+ char *p, int datalen,
+ u_int32 level));
extern struct rtentry * determine_route __P((u_int32 src));
-extern void report __P((int, vifi_t, u_int32));
-extern void report_to_all_neighbors __P((int));
+extern void report __P((int which_routes, vifi_t vifi,
+ u_int32 dst));
+extern void report_to_all_neighbors __P((int which_routes));
extern int report_next_chunk __P((void));
-extern void blaster_alloc __P((vifi_t));
-extern void add_vif_to_routes __P((vifi_t));
-extern void delete_vif_from_routes __P((vifi_t));
-extern void add_neighbor_to_routes __P((vifi_t, int));
-extern void delete_neighbor_from_routes __P((u_int32,
- vifi_t, int));
+extern void add_vif_to_routes __P((vifi_t vifi));
+extern void delete_vif_from_routes __P((vifi_t vifi));
+extern void delete_neighbor_from_routes __P((u_int32 addr,
+ vifi_t vifi));
extern void dump_routes __P((FILE *fp));
+extern void start_route_updates __P((void));
/* vif.c */
extern void init_vifs __P((void));
-extern void zero_vif __P((struct uvif *, int));
-extern void init_installvifs __P((void));
extern void check_vif_state __P((void));
-extern void send_on_vif __P((struct uvif *, u_int32, int, int));
-extern vifi_t find_vif __P((u_int32, u_int32));
+extern vifi_t find_vif __P((u_int32 src, u_int32 dst));
extern void age_vifs __P((void));
-extern void dump_vifs __P((FILE *));
+extern void dump_vifs __P((FILE *fp));
extern void stop_all_vifs __P((void));
-extern struct listaddr *neighbor_info __P((vifi_t, u_int32));
-extern void accept_group_report __P((u_int32, u_int32,
- u_int32, int));
+extern struct listaddr *neighbor_info __P((vifi_t vifi, u_int32 addr));
+extern void accept_group_report __P((u_int32 src, u_int32 dst,
+ u_int32 group, int r_type));
extern void query_groups __P((void));
extern void probe_for_neighbors __P((void));
-extern struct listaddr *update_neighbor __P((vifi_t, u_int32, int, char *, int,
- u_int32));
-extern void accept_neighbor_request __P((u_int32, u_int32));
-extern void accept_neighbor_request2 __P((u_int32, u_int32));
-extern void accept_info_request __P((u_int32, u_int32,
- u_char *, int));
-extern void accept_info_reply __P((u_int32, u_int32,
- u_char *, int));
-extern void accept_neighbors __P((u_int32, u_int32,
- u_char *, int, u_int32));
-extern void accept_neighbors2 __P((u_int32, u_int32,
- u_char *, int, u_int32));
-extern void accept_leave_message __P((u_int32, u_int32,
- u_int32));
-extern void accept_membership_query __P((u_int32, u_int32,
- u_int32, int));
+extern int update_neighbor __P((vifi_t vifi, u_int32 addr,
+ int msgtype, char *p, int datalen,
+ u_int32 level));
+extern void accept_neighbor_request __P((u_int32 src, u_int32 dst));
+extern void accept_neighbor_request2 __P((u_int32 src,
+ u_int32 dst));
+extern void accept_neighbors __P((u_int32 src, u_int32 dst,
+ u_char *p, int datalen, u_int32 level));
+extern void accept_neighbors2 __P((u_int32 src, u_int32 dst,
+ u_char *p, int datalen, u_int32 level));
+extern void accept_leave_message __P((u_int32 src, u_int32 dst,
+ u_int32 group));
+extern void accept_membership_query __P((u_int32 src, u_int32 dst,
+ u_int32 group, int tmo));
/* config.c */
extern void config_vifs_from_kernel __P((void));
@@ -330,84 +256,75 @@ extern void config_vifs_from_kernel __P((void));
extern void config_vifs_from_file __P((void));
/* inet.c */
-extern int inet_valid_host __P((u_int32));
-extern int inet_valid_mask __P((u_int32));
-extern int inet_valid_subnet __P((u_int32, u_int32));
-extern char * inet_fmt __P((u_int32, char *));
-extern char * inet_fmts __P((u_int32, u_int32, char *));
-extern u_int32 inet_parse __P((char *, int));
-extern int inet_cksum __P((u_short *, u_int));
+extern int inet_valid_host __P((u_int32 naddr));
+extern int inet_valid_subnet __P((u_int32 nsubnet, u_int32 nmask));
+extern char * inet_fmt __P((u_int32 addr, char *s));
+extern char * inet_fmts __P((u_int32 addr, u_int32 mask, char *s));
+extern u_int32 inet_parse __P((char *s, int n));
+extern int inet_cksum __P((u_short *addr, u_int len));
/* prune.c */
extern unsigned kroutes;
-extern void determine_forwvifs __P((struct gtable *));
-extern void send_prune_or_graft __P((struct gtable *));
-extern void add_table_entry __P((u_int32, u_int32));
-extern void del_table_entry __P((struct rtentry *,
- u_int32, u_int));
-extern void update_table_entry __P((struct rtentry *, u_int32));
-extern int find_src_grp __P((u_int32, u_int32, u_int32));
+extern void add_table_entry __P((u_int32 origin, u_int32 mcastgrp));
+extern void del_table_entry __P((struct rtentry *r,
+ u_int32 mcastgrp, u_int del_flag));
+extern void update_table_entry __P((struct rtentry *r));
extern void init_ktable __P((void));
-extern void steal_sources __P((struct rtentry *));
-extern void reset_neighbor_state __P((vifi_t, u_int32));
-extern int grplst_mem __P((vifi_t, u_int32));
+extern void accept_prune __P((u_int32 src, u_int32 dst, char *p,
+ int datalen));
+extern void steal_sources __P((struct rtentry *rt));
+extern void reset_neighbor_state __P((vifi_t vifi, u_int32 addr));
+extern int grplst_mem __P((vifi_t vifi, u_int32 mcastgrp));
+extern int scoped_addr __P((vifi_t vifi, u_int32 addr));
extern void free_all_prunes __P((void));
extern void age_table_entry __P((void));
-extern void dump_cache __P((FILE *));
-extern void update_lclgrp __P((vifi_t, u_int32));
-extern void delete_lclgrp __P((vifi_t, u_int32));
-extern void chkgrp_graft __P((vifi_t, u_int32));
-extern void accept_prune __P((u_int32, u_int32, char *, int));
-extern void accept_graft __P((u_int32, u_int32, char *, int));
-extern void accept_g_ack __P((u_int32, u_int32, char *, int));
+extern void dump_cache __P((FILE *fp2));
+extern void update_lclgrp __P((vifi_t vifi, u_int32 mcastgrp));
+extern void delete_lclgrp __P((vifi_t vifi, u_int32 mcastgrp));
+extern void chkgrp_graft __P((vifi_t vifi, u_int32 mcastgrp));
+extern void accept_graft __P((u_int32 src, u_int32 dst, char *p,
+ int datalen));
+extern void accept_g_ack __P((u_int32 src, u_int32 dst, char *p,
+ int datalen));
/* u_int is promoted u_char */
-extern void accept_mtrace __P((u_int32, u_int32,
- u_int32, char *, u_int, int));
+extern void accept_mtrace __P((u_int32 src, u_int32 dst,
+ u_int32 group, char *data, u_int no,
+ int datalen));
/* kern.c */
-extern void k_set_rcvbuf __P((int, int));
-extern void k_hdr_include __P((int));
-extern void k_set_ttl __P((int));
-extern void k_set_loop __P((int));
-extern void k_set_if __P((u_int32));
-extern void k_join __P((u_int32, u_int32));
-extern void k_leave __P((u_int32, u_int32));
+extern void k_set_rcvbuf __P((int bufsize));
+extern void k_hdr_include __P((int bool));
+extern void k_set_ttl __P((int t));
+extern void k_set_loop __P((int l));
+extern void k_set_if __P((u_int32 ifa));
+extern void k_join __P((u_int32 grp, u_int32 ifa));
+extern void k_leave __P((u_int32 grp, u_int32 ifa));
extern void k_init_dvmrp __P((void));
extern void k_stop_dvmrp __P((void));
-extern void k_add_vif __P((vifi_t, struct uvif *));
-extern void k_del_vif __P((vifi_t));
-extern void k_add_rg __P((u_int32, struct gtable *));
-extern int k_del_rg __P((u_int32, struct gtable *));
+extern void k_add_vif __P((vifi_t vifi, struct uvif *v));
+extern void k_del_vif __P((vifi_t vifi));
+extern void k_add_rg __P((u_int32 origin, struct gtable *g));
+extern int k_del_rg __P((u_int32 origin, struct gtable *g));
extern int k_get_version __P((void));
#ifdef SNMP
/* prune.c */
-extern struct gtable * find_grp __P((u_int32));
-extern struct stable * find_grp_src __P((struct gtable *, u_int32));
-extern int next_grp_src_mask __P((struct gtable **,
- struct stable **, u_int32,
- u_int32, u_int32));
-extern void refresh_sg __P((struct sioc_sg_req *, struct gtable *,
- struct stable *));
-extern int next_child __P((struct gtable **, struct stable **,
- u_int32, u_int32, u_int32,
- vifi_t *));
-
-/* route.c */
-extern struct rtentry * snmp_find_route __P((u_int32, u_int32));
-extern int next_route __P((struct rtentry **, u_int32, u_int32));
-extern int next_route_child __P((struct rtentry **,
- u_int32, u_int32, vifi_t *));
+extern struct rtentry * snmp_find_route __P(());
+extern struct gtable * find_grp __P(());
+extern struct stable * find_grp_src __P(());
#endif
#ifdef RSRR
/* prune.c */
extern struct gtable *kernel_table;
extern struct gtable *gtp;
+extern int find_src_grp __P((u_int32 src, u_int32 mask,
+ u_int32 grp));
/* rsrr.c */
extern void rsrr_init __P((void));
+extern void rsrr_read __P((int f, fd_set *rfd));
extern void rsrr_clean __P((void));
-extern void rsrr_cache_send __P((struct gtable *, int));
-extern void rsrr_cache_clean __P((struct gtable *));
+extern void rsrr_cache_send __P((struct gtable *gt, int notify));
+extern void rsrr_cache_clean __P((struct gtable *gt));
#endif /* RSRR */
diff --git a/usr.sbin/mrouted/dvmrp.h b/usr.sbin/mrouted/dvmrp.h
index a7aee84c3d0c..53b8d2fcded6 100644
--- a/usr.sbin/mrouted/dvmrp.h
+++ b/usr.sbin/mrouted/dvmrp.h
@@ -7,8 +7,7 @@
* Leland Stanford Junior University.
*
*
- * $Id: dvmrp.h,v 1.7 1997/02/22 16:06:52 peter Exp $
- * dvmrp.h,v 3.8.4.5 1997/11/18 23:25:57 fenner Exp
+ * $Id$
*/
/*
@@ -153,8 +152,13 @@
#define LEAF_CONFIRMATION_TIME 200 /* time to consider subnet a leaf */
#define NEIGHBOR_PROBE_INTERVAL 10 /* periodic neighbor probe interval */
-#define NEIGHBOR_EXPIRE_TIME 30 /* time to consider neighbor gone */
-#define OLD_NEIGHBOR_EXPIRE_TIME 140 /* time to consider neighbor gone */
+#define NEIGHBOR_EXPIRE_TIME 140 /* time to consider neighbor gone */
+
+#define GROUP_QUERY_INTERVAL 125 /* periodic group query interval */
+#define GROUP_EXPIRE_TIME 270 /* time to consider group gone */
+#define LEAVE_EXPIRE_TIME 3 /* " " after receiving a leave */
+/* Note: LEAVE_EXPIRE_TIME should ideally be shorter, but the resolution of
+ * the timer in mrouted doesn't allow us to make it any shorter. */
#define UNREACHABLE 32 /* "infinity" metric, must be <= 64 */
#define DEFAULT_METRIC 1 /* default subnet/tunnel metric */
@@ -162,11 +166,9 @@
#define MAX_RATE_LIMIT 100000 /* max rate limit */
#define DEFAULT_PHY_RATE_LIMIT 0 /* default phyint rate limit */
-#define DEFAULT_TUN_RATE_LIMIT 0 /* default tunnel rate limit */
+#define DEFAULT_TUN_RATE_LIMIT 500 /* default tunnel rate limit */
#define DEFAULT_CACHE_LIFETIME 300 /* kernel route entry discard time */
-#define MIN_CACHE_LIFETIME 60 /* minimum allowed cache lifetime */
-#define AVERAGE_PRUNE_LIFETIME 7200 /* average lifetime of prunes sent */
-#define MIN_PRUNE_LIFETIME 120 /* minimum allowed prune lifetime */
#define GRAFT_TIMEOUT_VAL 5 /* retransmission time for grafts */
-#define PRUNE_REXMIT_VAL 3 /* initial time for prune rexmission*/
+
+#define OLD_AGE_THRESHOLD 2
diff --git a/usr.sbin/mrouted/icmp.c b/usr.sbin/mrouted/icmp.c
deleted file mode 100644
index 72efa0ac745b..000000000000
--- a/usr.sbin/mrouted/icmp.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * The mrouted program is covered by the license in the accompanying file
- * named "LICENSE". Use of the mrouted program represents acceptance of
- * the terms and conditions listed in that file.
- *
- * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
- * Leland Stanford Junior University.
- *
- *
- * icmp.c,v 3.8.4.2 1998/01/06 01:57:42 fenner Exp
- */
-
-#include "defs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#) $Id: \
-icmp.c,v 3.8.4.2 1998/01/06 01:57:42 fenner Exp $";
-#endif
-
-static int icmp_socket;
-
-static void icmp_handler __P((int, fd_set *));
-static char * icmp_name __P((struct icmp *));
-
-void
-init_icmp()
-{
- if ((icmp_socket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
- log(LOG_ERR, errno, "ICMP socket");
-
- register_input_handler(icmp_socket, icmp_handler);
-
- IF_DEBUG(DEBUG_ICMP)
- log(LOG_DEBUG, 0, "registering icmp socket fd %d\n", icmp_socket);
-}
-
-static void
-icmp_handler(fd, rfds)
- int fd;
- fd_set *rfds;
-{
- u_char icmp_buf[RECV_BUF_SIZE];
- struct sockaddr_in from;
- int fromlen, recvlen, iphdrlen, ipdatalen;
- struct icmp *icmp;
- struct ip *ip;
- vifi_t i;
- struct uvif *v;
- u_int32 src;
-
- fromlen = sizeof(from);
- recvlen = recvfrom(icmp_socket, icmp_buf, RECV_BUF_SIZE, 0,
- (struct sockaddr *)&from, &fromlen);
- if (recvlen < 0) {
- if (errno != EINTR)
- log(LOG_WARNING, errno, "icmp_socket recvfrom");
- return;
- }
- ip = (struct ip *)icmp_buf;
- iphdrlen = ip->ip_hl << 2;
-#ifdef RAW_INPUT_IS_RAW
- ipdatalen = ntohs(ip->ip_len) - iphdrlen;
-#else
- ipdatalen = ip->ip_len;
-#endif
- if (iphdrlen + ipdatalen != recvlen) {
- IF_DEBUG(DEBUG_ICMP)
- log(LOG_DEBUG, 0, "hdr %d data %d != rcv %d", iphdrlen, ipdatalen, recvlen);
- /* Malformed ICMP, just return. */
- return;
- }
- if (ipdatalen < ICMP_MINLEN + sizeof(struct ip)) {
- /* Not enough data for us to be interested in it. */
- return;
- }
- src = ip->ip_src.s_addr;
- icmp = (struct icmp *)(icmp_buf + iphdrlen);
- IF_DEBUG(DEBUG_ICMP)
- log(LOG_DEBUG, 0, "got ICMP type %d from %s",
- icmp->icmp_type, inet_fmt(src, s1));
- /*
- * Eventually:
- * have registry of ICMP listeners, by type, code and ICMP_ID
- * (and maybe fields of the original packet too -- maybe need a
- * generalized packet filter!) to allow ping and traceroute
- * from the monitoring tool.
- */
- switch (icmp->icmp_type) {
- case ICMP_UNREACH:
- case ICMP_TIMXCEED:
- /* Look at returned packet to see if it's us sending on a tunnel */
- ip = &icmp->icmp_ip;
- if (ip->ip_p != IPPROTO_IGMP && ip->ip_p != IPPROTO_IPIP)
- return;
- for (v = uvifs, i = 0; i < numvifs; v++, i++) {
- if (ip->ip_src.s_addr == v->uv_lcl_addr &&
- ip->ip_dst.s_addr == v->uv_dst_addr) {
- char *p;
- int n;
- /*
- * I sent this packet on this vif.
- */
- n = ++v->uv_icmp_warn;
- while (n && !(n & 1))
- n >>= 1;
- if (n == 1 && ((p = icmp_name(icmp)) != NULL))
- log(LOG_WARNING, 0, "Received ICMP %s from %s %s %s on vif %d",
- p, inet_fmt(src, s1), "for traffic sent to",
- inet_fmt(ip->ip_dst.s_addr, s2),
- i);
-
- break;
- }
- }
- break;
- }
-}
-
-/*
- * Return NULL for ICMP informational messages.
- * Return string describing the error for ICMP errors.
- */
-static char *
-icmp_name(icmp)
- struct icmp *icmp;
-{
- static char retval[30];
-
- switch (icmp->icmp_type) {
- case ICMP_UNREACH:
- switch (icmp->icmp_code) {
- case ICMP_UNREACH_NET:
- return "network unreachable";
- case ICMP_UNREACH_HOST:
- return "host unreachable";
- case ICMP_UNREACH_PROTOCOL:
- return "protocol unreachable";
- case ICMP_UNREACH_PORT:
- return "port unreachable";
- case ICMP_UNREACH_NEEDFRAG:
- return "needs fragmentation";
- case ICMP_UNREACH_SRCFAIL:
- return "source route failed";
-#ifndef ICMP_UNREACH_NET_UNKNOWN
-#define ICMP_UNREACH_NET_UNKNOWN 6
-#endif
- case ICMP_UNREACH_NET_UNKNOWN:
- return "network unknown";
-#ifndef ICMP_UNREACH_HOST_UNKNOWN
-#define ICMP_UNREACH_HOST_UNKNOWN 7
-#endif
- case ICMP_UNREACH_HOST_UNKNOWN:
- return "host unknown";
-#ifndef ICMP_UNREACH_ISOLATED
-#define ICMP_UNREACH_ISOLATED 8
-#endif
- case ICMP_UNREACH_ISOLATED:
- return "source host isolated";
-#ifndef ICMP_UNREACH_NET_PROHIB
-#define ICMP_UNREACH_NET_PROHIB 9
-#endif
- case ICMP_UNREACH_NET_PROHIB:
- return "network access prohibited";
-#ifndef ICMP_UNREACH_HOST_PROHIB
-#define ICMP_UNREACH_HOST_PROHIB 10
-#endif
- case ICMP_UNREACH_HOST_PROHIB:
- return "host access prohibited";
-#ifndef ICMP_UNREACH_TOSNET
-#define ICMP_UNREACH_TOSNET 11
-#endif
- case ICMP_UNREACH_TOSNET:
- return "bad TOS for net";
-#ifndef ICMP_UNREACH_TOSHOST
-#define ICMP_UNREACH_TOSHOST 12
-#endif
- case ICMP_UNREACH_TOSHOST:
- return "bad TOS for host";
-#ifndef ICMP_UNREACH_FILTER_PROHIB
-#define ICMP_UNREACH_FILTER_PROHIB 13
-#endif
- case ICMP_UNREACH_FILTER_PROHIB:
- return "prohibited by filter";
-#ifndef ICMP_UNREACH_HOST_PRECEDENCE
-#define ICMP_UNREACH_HOST_PRECEDENCE 14
-#endif
- case ICMP_UNREACH_HOST_PRECEDENCE:
- return "host precedence violation";
-#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
-#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
-#endif
- case ICMP_UNREACH_PRECEDENCE_CUTOFF:
- return "precedence cutoff";
- default:
- sprintf(retval, "unreachable code %d", icmp->icmp_code);
- return retval;
- }
- case ICMP_SOURCEQUENCH:
- return "source quench";
- case ICMP_REDIRECT:
- return NULL; /* XXX */
- case ICMP_TIMXCEED:
- switch (icmp->icmp_code) {
- case ICMP_TIMXCEED_INTRANS:
- return "time exceeded in transit";
- case ICMP_TIMXCEED_REASS:
- return "time exceeded in reassembly";
- default:
- sprintf(retval, "time exceeded code %d", icmp->icmp_code);
- return retval;
- }
- case ICMP_PARAMPROB:
- switch (icmp->icmp_code) {
-#ifndef ICMP_PARAMPROB_OPTABSENT
-#define ICMP_PARAMPROB_OPTABSENT 1
-#endif
- case ICMP_PARAMPROB_OPTABSENT:
- return "required option absent";
- default:
- sprintf(retval, "parameter problem code %d", icmp->icmp_code);
- return retval;
- }
- }
- return NULL;
-}
diff --git a/usr.sbin/mrouted/igmp.c b/usr.sbin/mrouted/igmp.c
index 5feab13e0a41..203bd267fa8f 100644
--- a/usr.sbin/mrouted/igmp.c
+++ b/usr.sbin/mrouted/igmp.c
@@ -5,14 +5,11 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
- *
- *
- * igmp.c,v 3.8.4.19 1998/01/06 01:57:43 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: igmp.c,v 1.14 1998/01/16 07:17:41 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include "defs.h"
@@ -29,9 +26,27 @@ u_int32 dvmrp_group; /* DVMRP grp addr in net order */
u_int32 dvmrp_genid; /* IGMP generation id */
/*
+ * Private variables
+ */
+static char router_alert[4]; /* Router Alert IP Option */
+#ifndef IPOPT_RA
+#define IPOPT_RA 148
+#endif
+#ifdef SUNOS5
+static char no_op[4]; /* Null IP Option */
+static int ip_addlen = 0; /* Workaround for Option bug #2*/
+#endif
+#define SEND_RA(x) (((x) == IGMP_MEMBERSHIP_QUERY) || \
+ ((x) == IGMP_V1_MEMBERSHIP_REPORT) || \
+ ((x) == IGMP_V2_MEMBERSHIP_REPORT) || \
+ ((x) == IGMP_V2_LEAVE_GROUP) || \
+ ((x) == IGMP_MTRACE))
+
+/*
* Local function definitions.
*/
/* u_char promoted to u_int */
+static char * packet_kind __P((u_int type, u_int code));
static int igmp_log_level __P((u_int type, u_int code));
/*
@@ -42,6 +57,9 @@ void
init_igmp()
{
struct ip *ip;
+#ifdef SUNOS5
+ u_int32 localhost = htonl(0x7f000001);
+#endif
recv_buf = malloc(RECV_BUF_SIZE);
send_buf = malloc(RECV_BUF_SIZE);
@@ -50,27 +68,82 @@ init_igmp()
log(LOG_ERR, errno, "IGMP socket");
k_hdr_include(TRUE); /* include IP header when sending */
- k_set_rcvbuf(256*1024,48*1024); /* lots of input buffering */
+ k_set_rcvbuf(48*1024); /* lots of input buffering */
k_set_ttl(1); /* restrict multicasts to one hop */
k_set_loop(FALSE); /* disable multicast loopback */
ip = (struct ip *)send_buf;
- bzero(ip, sizeof(struct ip));
- /*
- * Fields zeroed that aren't filled in later:
- * - IP ID (let the kernel fill it in)
- * - Offset (we don't send fragments)
- * - Checksum (let the kernel fill it in)
- */
- ip->ip_v = IPVERSION;
ip->ip_hl = sizeof(struct ip) >> 2;
- ip->ip_tos = 0xc0; /* Internet Control */
- ip->ip_ttl = MAXTTL; /* applies to unicasts only */
+ ip->ip_v = IPVERSION;
+ ip->ip_tos = 0;
+ ip->ip_off = 0;
ip->ip_p = IPPROTO_IGMP;
+ ip->ip_ttl = MAXTTL; /* applies to unicasts only */
allhosts_group = htonl(INADDR_ALLHOSTS_GROUP);
dvmrp_group = htonl(INADDR_DVMRP_GROUP);
allrtrs_group = htonl(INADDR_ALLRTRS_GROUP);
+
+ router_alert[0] = IPOPT_RA; /* Router Alert */
+ router_alert[1] = 4; /* 4 bytes */
+ router_alert[2] = 0;
+ router_alert[3] = 0;
+
+#ifdef SUNOS5
+ no_op[0] = IPOPT_NOP;
+ no_op[1] = IPOPT_NOP;
+ no_op[2] = IPOPT_NOP;
+ no_op[3] = IPOPT_NOP;
+
+ setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS, no_op, sizeof(no_op));
+ /*
+ * Check if the kernel adds the options length to the packet
+ * length. Send myself an IGMP packet of type 0 (illegal),
+ * with 4 IPOPT_NOP options, my PID (for collision detection)
+ * and 4 bytes of zero (so that the checksum works whether
+ * the 4 bytes of zero get truncated or not).
+ */
+ bzero(send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN, 8);
+ *(int *)(send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN) = getpid();
+ send_igmp(localhost, localhost, 0, 0, 0, 8);
+ while (1) {
+ int recvlen, dummy = 0;
+
+ recvlen = recvfrom(igmp_socket, recv_buf, RECV_BUF_SIZE,
+ 0, NULL, &dummy);
+ /* 8 == 4 bytes of options and 4 bytes of PID */
+ if (recvlen >= MIN_IP_HEADER_LEN + IGMP_MINLEN + 8) {
+ struct ip *ip = (struct ip *)recv_buf;
+ struct igmp *igmp;
+ int *p;
+
+ if (ip->ip_hl != 6 ||
+ ip->ip_p != IPPROTO_IGMP ||
+ ip->ip_src.s_addr != localhost ||
+ ip->ip_dst.s_addr != localhost)
+ continue;
+
+ igmp = (struct igmp *)(recv_buf + (ip->ip_hl << 2));
+ if (igmp->igmp_group.s_addr != 0)
+ continue;
+ if (igmp->igmp_type != 0 || igmp->igmp_code != 0)
+ continue;
+
+ p = (int *)((char *)igmp + IGMP_MINLEN);
+ if (*p != getpid())
+ continue;
+
+ if (ip->ip_len == IGMP_MINLEN + 4)
+ ip_addlen = 4;
+ else if (ip->ip_len == IGMP_MINLEN + 8)
+ ip_addlen = 0;
+ else
+ log(LOG_ERR, 0, "while checking for Solaris bug: Sent %d bytes and got back %d!", IGMP_MINLEN + 8, ip->ip_len);
+
+ break;
+ }
+ }
+#endif
}
#define PIM_QUERY 0
@@ -82,33 +155,29 @@ init_igmp()
#define PIM_GRAFT 6
#define PIM_GRAFT_ACK 7
-char *
-igmp_packet_kind(type, code)
+static char *
+packet_kind(type, code)
u_int type, code;
{
- static char unknown[20];
-
switch (type) {
- case IGMP_MEMBERSHIP_QUERY: return "membership query ";
- case IGMP_V1_MEMBERSHIP_REPORT: return "V1 member report ";
- case IGMP_V2_MEMBERSHIP_REPORT: return "V2 member report ";
- case IGMP_V2_LEAVE_GROUP: return "leave message ";
+ case IGMP_HOST_MEMBERSHIP_QUERY: return "membership query ";
+ case IGMP_HOST_MEMBERSHIP_REPORT: return "V1 member report ";
+ case IGMP_HOST_NEW_MEMBERSHIP_REPORT: return "V2 member report ";
+ case IGMP_HOST_LEAVE_MESSAGE: return "leave message ";
case IGMP_DVMRP:
switch (code) {
- case DVMRP_PROBE: return "neighbor probe ";
- case DVMRP_REPORT: return "route report ";
- case DVMRP_ASK_NEIGHBORS: return "neighbor request ";
- case DVMRP_NEIGHBORS: return "neighbor list ";
- case DVMRP_ASK_NEIGHBORS2: return "neighbor request 2";
- case DVMRP_NEIGHBORS2: return "neighbor list 2 ";
+ case DVMRP_PROBE: return "neighbor probe ";
+ case DVMRP_REPORT: return "route report ";
+ case DVMRP_ASK_NEIGHBORS: return "neighbor request ";
+ case DVMRP_NEIGHBORS: return "neighbor list ";
+ case DVMRP_ASK_NEIGHBORS2: return "neighbor request 2";
+ case DVMRP_NEIGHBORS2: return "neighbor list 2 ";
case DVMRP_PRUNE: return "prune message ";
case DVMRP_GRAFT: return "graft message ";
case DVMRP_GRAFT_ACK: return "graft message ack ";
case DVMRP_INFO_REQUEST: return "info request ";
case DVMRP_INFO_REPLY: return "info reply ";
- default:
- sprintf(unknown, "unknown DVMRP %3d ", code);
- return unknown;
+ default: return "unknown DVMRP msg ";
}
case IGMP_PIM:
switch (code) {
@@ -120,57 +189,11 @@ igmp_packet_kind(type, code)
case PIM_ASSERT: return "PIM Assert ";
case PIM_GRAFT: return "PIM Graft ";
case PIM_GRAFT_ACK: return "PIM Graft-Ack ";
- default:
- sprintf(unknown, "unknown PIM msg%3d", code);
- return unknown;
+ default: return "unknown PIM msg ";
}
case IGMP_MTRACE: return "IGMP trace query ";
case IGMP_MTRACE_RESP: return "IGMP trace reply ";
- default:
- sprintf(unknown, "unk: 0x%02x/0x%02x ", type, code);
- return unknown;
- }
-}
-
-int
-igmp_debug_kind(type, code)
- u_int type, code;
-{
- switch (type) {
- case IGMP_MEMBERSHIP_QUERY: return DEBUG_IGMP;
- case IGMP_V1_MEMBERSHIP_REPORT: return DEBUG_IGMP;
- case IGMP_V2_MEMBERSHIP_REPORT: return DEBUG_IGMP;
- case IGMP_V2_LEAVE_GROUP: return DEBUG_IGMP;
- case IGMP_DVMRP:
- switch (code) {
- case DVMRP_PROBE: return DEBUG_PEER;
- case DVMRP_REPORT: return DEBUG_ROUTE;
- case DVMRP_ASK_NEIGHBORS: return 0;
- case DVMRP_NEIGHBORS: return 0;
- case DVMRP_ASK_NEIGHBORS2: return 0;
- case DVMRP_NEIGHBORS2: return 0;
- case DVMRP_PRUNE: return DEBUG_PRUNE;
- case DVMRP_GRAFT: return DEBUG_PRUNE;
- case DVMRP_GRAFT_ACK: return DEBUG_PRUNE;
- case DVMRP_INFO_REQUEST: return 0;
- case DVMRP_INFO_REPLY: return 0;
- default: return 0;
- }
- case IGMP_PIM:
- switch (code) {
- case PIM_QUERY: return 0;
- case PIM_REGISTER: return 0;
- case PIM_REGISTER_STOP: return 0;
- case PIM_JOIN_PRUNE: return 0;
- case PIM_RP_REACHABLE: return 0;
- case PIM_ASSERT: return 0;
- case PIM_GRAFT: return 0;
- case PIM_GRAFT_ACK: return 0;
- default: return 0;
- }
- case IGMP_MTRACE: return DEBUG_TRACE;
- case IGMP_MTRACE_RESP: return DEBUG_TRACE;
- default: return DEBUG_IGMP;
+ default: return "unknown IGMP msg ";
}
}
@@ -211,11 +234,7 @@ accept_igmp(recvlen)
}
iphdrlen = ip->ip_hl << 2;
-#ifdef RAW_INPUT_IS_RAW
- ipdatalen = ntohs(ip->ip_len) - iphdrlen;
-#else
ipdatalen = ip->ip_len;
-#endif
if (iphdrlen + ipdatalen != recvlen) {
log(LOG_WARNING, 0,
"received packet from %s shorter (%u bytes) than hdr+data length (%u+%u)",
@@ -233,23 +252,22 @@ accept_igmp(recvlen)
return;
}
- IF_DEBUG(DEBUG_PKT|igmp_debug_kind(igmp->igmp_type, igmp->igmp_code))
log(LOG_DEBUG, 0, "RECV %s from %-15s to %s",
- igmp_packet_kind(igmp->igmp_type, igmp->igmp_code),
+ packet_kind(igmp->igmp_type, igmp->igmp_code),
inet_fmt(src, s1), inet_fmt(dst, s2));
switch (igmp->igmp_type) {
- case IGMP_MEMBERSHIP_QUERY:
+ case IGMP_HOST_MEMBERSHIP_QUERY:
accept_membership_query(src, dst, group, igmp->igmp_code);
return;
- case IGMP_V1_MEMBERSHIP_REPORT:
- case IGMP_V2_MEMBERSHIP_REPORT:
+ case IGMP_HOST_MEMBERSHIP_REPORT:
+ case IGMP_HOST_NEW_MEMBERSHIP_REPORT:
accept_group_report(src, dst, group, igmp->igmp_type);
return;
- case IGMP_V2_LEAVE_GROUP:
+ case IGMP_HOST_LEAVE_MESSAGE:
accept_leave_message(src, dst, group);
return;
@@ -360,31 +378,32 @@ igmp_log_level(type, code)
/*
* Construct an IGMP message in the output packet buffer. The caller may
- * have already placed data in that buffer, of length 'datalen'.
+ * have already placed data in that buffer, of length 'datalen'. Then send
+ * the message from the interface with IP address 'src' to destination 'dst'.
*/
void
-build_igmp(src, dst, type, code, group, datalen)
+send_igmp(src, dst, type, code, group, datalen)
u_int32 src, dst;
int type, code;
u_int32 group;
int datalen;
{
+ struct sockaddr_in sdst;
struct ip *ip;
struct igmp *igmp;
- extern int curttl;
+ int setloop = 0;
+ static int raset = 0;
+ int sendra = 0;
+ int sendlen;
ip = (struct ip *)send_buf;
ip->ip_src.s_addr = src;
ip->ip_dst.s_addr = dst;
ip->ip_len = MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen;
-#ifdef RAW_OUTPUT_IS_RAW
- ip->ip_len = htons(ip->ip_len);
+ sendlen = ip->ip_len;
+#ifdef SUNOS5
+ ip->ip_len += ip_addlen;
#endif
- if (IN_MULTICAST(ntohl(dst))) {
- ip->ip_ttl = curttl;
- } else {
- ip->ip_ttl = MAXTTL;
- }
igmp = (struct igmp *)(send_buf + MIN_IP_HEADER_LEN);
igmp->igmp_type = type;
@@ -393,24 +412,6 @@ build_igmp(src, dst, type, code, group, datalen)
igmp->igmp_cksum = 0;
igmp->igmp_cksum = inet_cksum((u_short *)igmp,
IGMP_MINLEN + datalen);
-}
-
-/*
- * Call build_igmp() to build an IGMP message in the output packet buffer.
- * Then send the message from the interface with IP address 'src' to
- * destination 'dst'.
- */
-void
-send_igmp(src, dst, type, code, group, datalen)
- u_int32 src, dst;
- int type, code;
- u_int32 group;
- int datalen;
-{
- struct sockaddr_in sdst;
- int setloop = 0;
-
- build_igmp(src, dst, type, code, group, datalen);
if (IN_MULTICAST(ntohl(dst))) {
k_set_if(src);
@@ -418,16 +419,36 @@ send_igmp(src, dst, type, code, group, datalen)
setloop = 1;
k_set_loop(TRUE);
}
+ if (SEND_RA(type))
+ sendra = 1;
+ }
+
+ if (sendra && !raset) {
+ setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS,
+ router_alert, sizeof(router_alert));
+ raset = 1;
+ } else if (!sendra && raset) {
+#ifdef SUNOS5
+ /*
+ * SunOS5 < 5.6 cannot properly reset the IP_OPTIONS "socket"
+ * option. Instead, set up a string of 4 no-op's.
+ */
+ setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS,
+ no_op, sizeof(no_op));
+#else
+ setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS,
+ NULL, 0);
+#endif
+ raset = 0;
}
bzero(&sdst, sizeof(sdst));
sdst.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
+#if (defined(BSD) && (BSD >= 199103))
sdst.sin_len = sizeof(sdst);
#endif
sdst.sin_addr.s_addr = dst;
- if (sendto(igmp_socket, send_buf,
- MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen, 0,
+ if (sendto(igmp_socket, send_buf, sendlen, 0,
(struct sockaddr *)&sdst, sizeof(sdst)) < 0) {
if (errno == ENETDOWN)
check_vif_state();
@@ -440,8 +461,7 @@ send_igmp(src, dst, type, code, group, datalen)
if (setloop)
k_set_loop(FALSE);
- IF_DEBUG(DEBUG_PKT|igmp_debug_kind(type, code))
log(LOG_DEBUG, 0, "SENT %s from %-15s to %s",
- igmp_packet_kind(type, code), src == INADDR_ANY ? "INADDR_ANY" :
+ packet_kind(type, code), src == INADDR_ANY ? "INADDR_ANY" :
inet_fmt(src, s1), inet_fmt(dst, s2));
}
diff --git a/usr.sbin/mrouted/igmpv2.h b/usr.sbin/mrouted/igmpv2.h
deleted file mode 100644
index 5f5ae27e68e8..000000000000
--- a/usr.sbin/mrouted/igmpv2.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The mrouted program is covered by the license in the accompanying file
- * named "LICENSE". Use of the mrouted program represents acceptance of
- * the terms and conditions listed in that file.
- *
- * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
- * Leland Stanford Junior University.
- *
- *
- * igmpv2.h,v 3.8.4.1 1997/11/18 23:25:58 fenner Exp
- */
-
-/*
- * Constants for IGMP Version 2. Several of these, especially the
- * robustness variable, should be variables and not constants.
- */
-#define IGMP_ROBUSTNESS_VARIABLE 2
-#define IGMP_QUERY_INTERVAL 125
-#define IGMP_QUERY_RESPONSE_INTERVAL 10
-#define IGMP_GROUP_MEMBERSHIP_INTERVAL (IGMP_ROBUSTNESS_VARIABLE * \
- IGMP_QUERY_INTERVAL + \
- IGMP_QUERY_RESPONSE_INTERVAL)
-#define IGMP_OTHER_QUERIER_PRESENT_INTERVAL (IGMP_ROBUSTNESS_VARIABLE * \
- IGMP_QUERY_INTERVAL + \
- IGMP_QUERY_RESPONSE_INTERVAL / 2)
- /* Round to the nearest TIMER_INTERVAL */
-#define IGMP_STARTUP_QUERY_INTERVAL (((IGMP_QUERY_INTERVAL / 4) \
- / TIMER_INTERVAL) * TIMER_INTERVAL)
-#define IGMP_STARTUP_QUERY_COUNT IGMP_ROBUSTNESS_VARIABLE
-#define IGMP_LAST_MEMBER_QUERY_INTERVAL 1
-#define IGMP_LAST_MEMBER_QUERY_COUNT IGMP_ROBUSTNESS_VARIABLE
-
-/*
- * OLD_AGE_THRESHOLD is the number of IGMP_QUERY_INTERVAL's to remember the
- * presence of an IGMPv1 group member. According to the IGMPv2 specification,
- * routers remember this presence for [Robustness Variable] * [Query Interval] +
- * [Query Response Interval]. However, OLD_AGE_THRESHOLD is in units of
- * [Query Interval], so doesn't have sufficient resolution to represent
- * [Query Response Interval]. When the timer mechanism gets an efficient
- * method of refreshing timers, this should get fixed.
- */
-#define OLD_AGE_THRESHOLD IGMP_ROBUSTNESS_VARIABLE
diff --git a/usr.sbin/mrouted/inet.c b/usr.sbin/mrouted/inet.c
index fb101616a8e7..5af7218e0bde 100644
--- a/usr.sbin/mrouted/inet.c
+++ b/usr.sbin/mrouted/inet.c
@@ -5,14 +5,11 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
- *
- *
- * inet.c,v 3.8.4.2 1998/01/06 01:57:44 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: inet.c,v 1.9 1998/01/16 07:17:42 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include "defs.h"
diff --git a/usr.sbin/mrouted/ipip.c b/usr.sbin/mrouted/ipip.c
deleted file mode 100644
index 6e88d932d3b4..000000000000
--- a/usr.sbin/mrouted/ipip.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * The mrouted program is covered by the license in the accompanying file
- * named "LICENSE". Use of the mrouted program represents acceptance of
- * the terms and conditions listed in that file.
- *
- * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
- * Leland Stanford Junior University.
- *
- *
- * ipip.c,v 3.8.4.6 1998/01/06 01:57:45 fenner Exp
- */
-
-
-#include "defs.h"
-
-#ifndef lint
-static char rcsid[] = "@(#) $Id: \
-ipip.c,v 3.8.4.6 1998/01/06 01:57:45 fenner Exp $";
-#endif
-
-/*
- * Exported variables.
- */
-#ifdef notyet
-int raw_socket; /* socket for raw network I/O */
-#endif
-/*
- *XXX For now, we just use the IGMP socket to send packets.
- * This is legal in BSD, because the protocol # is not checked
- * on raw sockets. The k_* interfaces need to gain a socket
- * argument so that we can call them on the raw_socket also.
- */
-#define raw_socket igmp_socket
-
-/*
- * Private variables.
- */
-static int rawid = 0;
-
-/*
- * Open and initialize the raw socket.
- */
-void
-init_ipip()
-{
-#ifdef notyet
- if ((raw_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
- log(LOG_ERR, errno, "Raw IP socket");
-#endif
-}
-
-/*
- * Allocate and fill in static IP header for encapsulating on a tunnel.
- */
-void
-init_ipip_on_vif(v)
- struct uvif *v;
-{
- struct ip *ip;
-
- ip = v->uv_encap_hdr = (struct ip *)malloc(sizeof(struct ip));
- if (ip == NULL)
- log(LOG_ERR, 0, "out of memory");
- bzero(ip, sizeof(struct ip));
- /*
- * Fields zeroed that aren't filled in later:
- * - IP ID (let the kernel fill it in)
- * - Offset (we don't send fragments)
- * - Checksum (let the kernel fill it in)
- */
- ip->ip_v = IPVERSION;
- ip->ip_hl = sizeof(struct ip) >> 2;
- ip->ip_tos = 0xc0; /* Internet Control */
- ip->ip_ttl = MAXTTL; /* applies to unicasts only */
- ip->ip_p = IPPROTO_IPIP;
- ip->ip_src.s_addr = v->uv_lcl_addr;
- ip->ip_dst.s_addr = v->uv_rmt_addr;
-}
-
-/*
- * Call build_igmp() to build an IGMP message in the output packet buffer.
- * Then fill in the fields of the IP packet that build_igmp() left for the
- * kernel to fill in, and encapsulate the original packet with the
- * pre-created ip header for this vif.
- */
-void
-send_ipip(src, dst, type, code, group, datalen, v)
- u_int32 src, dst;
- int type, code;
- u_int32 group;
- int datalen;
- struct uvif *v;
-{
- struct msghdr msg;
- struct iovec iov[2];
- struct sockaddr_in sdst;
- struct ip *ip;
-
- build_igmp(src, dst, type, code, group, datalen);
- ip = (struct ip *)send_buf;
-#ifndef RAW_OUTPUT_IS_RAW
- ip->ip_len = htons(ip->ip_len);
-#endif
- ip->ip_id = htons(rawid++);
- ip->ip_sum = 0;
- ip->ip_sum = inet_cksum((u_short *)ip, ip->ip_hl << 2);
-
- ip = v->uv_encap_hdr;
- ip->ip_len = 2 * MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen;
-#ifdef RAW_OUTPUT_IS_RAW
- ip->ip_len = htons(ip->ip_len);
-#endif
-
- bzero(&sdst, sizeof(sdst));
- sdst.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
- sdst.sin_len = sizeof(sdst);
-#endif
- sdst.sin_addr = ip->ip_dst;
-
- iov[0].iov_base = (caddr_t)v->uv_encap_hdr;
- iov[0].iov_len = sizeof(struct ip);
- iov[1].iov_base = (caddr_t)send_buf;
- iov[1].iov_len = MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen;
-
- bzero(&msg, sizeof(msg));
- msg.msg_name = (caddr_t)&sdst;
- msg.msg_namelen = sizeof(sdst);
- msg.msg_iov = iov;
- msg.msg_iovlen = 2;
- if (sendmsg(raw_socket, &msg, 0) < 0) {
- if (errno == ENETDOWN)
- check_vif_state();
- else
- log(LOG_WARNING, errno,
- "sendmsg to %s on %s",
- inet_fmt(sdst.sin_addr.s_addr, s1), inet_fmt(src, s2));
- }
-
- IF_DEBUG(DEBUG_PKT|igmp_debug_kind(type, code))
- log(LOG_DEBUG, 0, "SENT %s from %-15s to %s encaped to %s",
- igmp_packet_kind(type, code), src == INADDR_ANY ? "INADDR_ANY" :
- inet_fmt(src, s1), inet_fmt(dst, s2),
- inet_fmt(sdst.sin_addr.s_addr, s3));
-}
diff --git a/usr.sbin/mrouted/kern.c b/usr.sbin/mrouted/kern.c
index af8d007eb8dc..5f29949f515c 100644
--- a/usr.sbin/mrouted/kern.c
+++ b/usr.sbin/mrouted/kern.c
@@ -5,59 +5,21 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
- *
- *
- * kern.c,v 3.8.4.10 1998/01/06 02:00:51 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: kern.c,v 1.10 1998/01/16 07:17:42 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include "defs.h"
-int curttl = 0;
-
-void k_set_rcvbuf(bufsize, minsize)
+void k_set_rcvbuf(bufsize)
int bufsize;
- int minsize;
{
- int delta = bufsize / 2;
- int iter = 0;
-
- /*
- * Set the socket buffer. If we can't set it as large as we
- * want, search around to try to find the highest acceptable
- * value. The highest acceptable value being smaller than
- * minsize is a fatal error.
- */
if (setsockopt(igmp_socket, SOL_SOCKET, SO_RCVBUF,
- (char *)&bufsize, sizeof(bufsize)) < 0) {
- bufsize -= delta;
- while (1) {
- iter++;
- if (delta > 1)
- delta /= 2;
-
- if (setsockopt(igmp_socket, SOL_SOCKET, SO_RCVBUF,
- (char *)&bufsize, sizeof(bufsize)) < 0) {
- bufsize -= delta;
- } else {
- if (delta < 1024)
- break;
- bufsize += delta;
- }
- }
- if (bufsize < minsize) {
- log(LOG_ERR, 0, "OS-allowed buffer size %u < app min %u",
- bufsize, minsize);
- /*NOTREACHED*/
- }
- }
- IF_DEBUG(DEBUG_KERN)
- log(LOG_DEBUG, 0, "Got %d byte buffer size in %d iterations",
- bufsize, iter);
+ (char *)&bufsize, sizeof(bufsize)) < 0)
+ log(LOG_ERR, errno, "setsockopt SO_RCVBUF %u", bufsize);
}
@@ -75,15 +37,12 @@ void k_hdr_include(bool)
void k_set_ttl(t)
int t;
{
-#ifndef RAW_OUTPUT_IS_RAW
u_char ttl;
ttl = t;
if (setsockopt(igmp_socket, IPPROTO_IP, IP_MULTICAST_TTL,
(char *)&ttl, sizeof(ttl)) < 0)
log(LOG_ERR, errno, "setsockopt IP_MULTICAST_TTL %u", ttl);
-#endif
- curttl = t;
}
@@ -182,7 +141,7 @@ void k_add_vif(vifi, v)
if (setsockopt(igmp_socket, IPPROTO_IP, MRT_ADD_VIF,
(char *)&vc, sizeof(vc)) < 0)
- log(LOG_ERR, errno, "setsockopt MRT_ADD_VIF on vif %d", vifi);
+ log(LOG_ERR, errno, "setsockopt MRT_ADD_VIF");
}
@@ -224,8 +183,7 @@ void k_add_rg(origin, g)
#ifdef DEBUG_MFC
md_log(MD_ADD_FAIL, origin, g->gt_mcastgrp);
#endif
- log(LOG_WARNING, errno, "setsockopt MRT_ADD_MFC",
- inet_fmt(origin, s1), inet_fmt(g->gt_mcastgrp, s2));
+ log(LOG_WARNING, errno, "setsockopt MRT_ADD_MFC");
}
}
@@ -256,8 +214,7 @@ int k_del_rg(origin, g)
#ifdef DEBUG_MFC
md_log(MD_DEL_FAIL, origin, g->gt_mcastgrp);
#endif
- log(LOG_WARNING, errno, "setsockopt MRT_DEL_MFC of (%s %s)",
- inet_fmt(origin, s1), inet_fmt(g->gt_mcastgrp, s2));
+ log(LOG_WARNING, errno, "setsockopt MRT_DEL_MFC");
}
return retval;
@@ -282,63 +239,3 @@ int k_get_version()
return vers;
#endif
}
-
-#if 0
-/*
- * Get packet counters
- */
-int
-k_get_vif_count(vifi, icount, ocount, ibytes, obytes)
- vifi_t vifi;
- int *icount, *ocount, *ibytes, *obytes;
-{
- struct sioc_vif_req vreq;
- int retval = 0;
-
- vreq.vifi = vifi;
- if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&vreq) < 0) {
- log(LOG_WARNING, errno, "SIOCGETVIFCNT on vif %d", vifi);
- vreq.icount = vreq.ocount = vreq.ibytes =
- vreq.obytes = 0xffffffff;
- retval = 1;
- }
- if (icount)
- *icount = vreq.icount;
- if (ocount)
- *ocount = vreq.ocount;
- if (ibytes)
- *ibytes = vreq.ibytes;
- if (obytes)
- *obytes = vreq.obytes;
- return retval;
-}
-
-/*
- * Get counters for a desired source and group.
- */
-int
-k_get_sg_count(src, grp, pktcnt, bytecnt, wrong_if)
- u_int32 src;
- u_int32 grp;
- struct sg_count *retval;
-{
- struct sioc_sg_req sgreq;
- int retval = 0;
-
- sgreq.src.s_addr = src;
- sgreq.grp.s_addr = grp;
- if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sgreq) < 0) {
- log(LOG_WARNING, errno, "SIOCGETSGCNT on (%s %s)",
- inet_fmt(src, s1), inet_fmt(grp, s2));
- sgreq.pktcnt = sgreq.bytecnt = sgreq.wrong_if = 0xffffffff;
- return 1;
- }
- if (pktcnt)
- *pktcnt = sgreq.pktcnt;
- if (bytecnt)
- *bytecnt = sgreq.bytecnt;
- if (wrong_if)
- *wrong_if = sgreq.wrong_if;
- return retval;
-}
-#endif
diff --git a/usr.sbin/mrouted/main.c b/usr.sbin/mrouted/main.c
index 875ec97659b4..864d5cb77244 100644
--- a/usr.sbin/mrouted/main.c
+++ b/usr.sbin/mrouted/main.c
@@ -6,8 +6,6 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
- *
- * main.c,v 3.8.4.29 1998/03/01 01:49:00 fenner Exp
*/
/*
@@ -22,7 +20,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.14 1998/06/29 17:38:35 bde Exp $";
+ "$Id: main.c,v 1.13 1998/01/16 07:17:43 charnier Exp $";
#endif
#include <err.h>
@@ -46,21 +44,11 @@ static char dumpfilename[] = _PATH_MROUTED_DUMP;
static char cachefilename[] = _PATH_MROUTED_CACHE;
static char genidfilename[] = _PATH_MROUTED_GENID;
-static int haveterminal = 1;
-int did_final_init = 0;
-
-static int sighandled = 0;
-#define GOT_SIGINT 0x01
-#define GOT_SIGHUP 0x02
-#define GOT_SIGUSR1 0x04
-#define GOT_SIGUSR2 0x08
-
int cache_lifetime = DEFAULT_CACHE_LIFETIME;
-int prune_lifetime = AVERAGE_PRUNE_LIFETIME;
+int max_prune_lifetime = DEFAULT_CACHE_LIFETIME * 2;
int debug = 0;
-char *progname;
-time_t mrouted_init_time;
+u_char pruning = 1; /* Enable pruning by default */
#ifdef SNMP
#define NHANDLERS 34
@@ -74,48 +62,16 @@ static struct ihandler {
} ihandlers[NHANDLERS];
static int nhandlers = 0;
-static struct debugname {
- char *name;
- int level;
- int nchars;
-} debugnames[] = {
- { "packet", DEBUG_PKT, 2 },
- { "pkt", DEBUG_PKT, 3 },
- { "pruning", DEBUG_PRUNE, 1 },
- { "prunes", DEBUG_PRUNE, 1 },
- { "routing", DEBUG_ROUTE, 1 },
- { "routes", DEBUG_ROUTE, 1 },
- { "route_detail", DEBUG_RTDETAIL, 6 },
- { "rtdetail", DEBUG_RTDETAIL, 2 },
- { "peers", DEBUG_PEER, 2 },
- { "neighbors", DEBUG_PEER, 1 },
- { "cache", DEBUG_CACHE, 1 },
- { "timeout", DEBUG_TIMEOUT, 1 },
- { "callout", DEBUG_TIMEOUT, 2 },
- { "interface", DEBUG_IF, 2 },
- { "vif", DEBUG_IF, 1 },
- { "membership", DEBUG_MEMBER, 1 },
- { "groups", DEBUG_MEMBER, 1 },
- { "traceroute", DEBUG_TRACE, 2 },
- { "mtrace", DEBUG_TRACE, 2 },
- { "igmp", DEBUG_IGMP, 1 },
- { "icmp", DEBUG_ICMP, 2 },
- { "rsrr", DEBUG_RSRR, 2 },
- { "3", 0xffffffff, 1 } /* compat. */
-};
-
/*
* Forward declarations.
*/
-static void final_init __P((void *));
-static void fasttimer __P((void *));
-static void timer __P((void *));
-static void dump __P((void));
-static void dump_version __P((FILE *));
-static void fdump __P((void));
-static void cdump __P((void));
-static void restart __P((void));
-static void handler __P((int));
+static void fasttimer __P((int));
+static void done __P((int));
+static void dump __P((int));
+static void fdump __P((int));
+static void cdump __P((int));
+static void restart __P((int));
+static void timer __P((void));
static void cleanup __P((void));
static void resetlogging __P((void *));
static void usage __P((void));
@@ -143,15 +99,14 @@ main(argc, argv)
char *argv[];
{
register int recvlen;
+ register int omask;
int dummy;
FILE *fp;
- struct timeval tv, difftime, curtime, lasttime, *timeout;
+ struct timeval tv;
u_int32 prev_genid;
int vers;
fd_set rfds, readers;
- int nfds, n, i, secs;
- extern char todaysversion[];
- struct sigaction sa;
+ int nfds, n, i;
#ifdef SNMP
struct timeval timeout, *tvp = &timeout;
struct timeval sched, *svp = &sched, now, *nvp = &now;
@@ -163,53 +118,12 @@ main(argc, argv)
if (geteuid() != 0)
errx(1, "must be root");
- progname = strrchr(argv[0], '/');
- if (progname)
- progname++;
- else
- progname = argv[0];
-
argv++, argc--;
while (argc > 0 && *argv[0] == '-') {
if (strcmp(*argv, "-d") == 0) {
- if (argc > 1 && *(argv + 1)[0] != '-') {
- char *p,*q;
- int i, len;
- struct debugname *d;
-
+ if (argc > 1 && isdigit(*(argv + 1)[0])) {
argv++, argc--;
- debug = 0;
- p = *argv; q = NULL;
- while (p) {
- q = strchr(p, ',');
- if (q)
- *q++ = '\0';
- len = strlen(p);
- for (i = 0, d = debugnames;
- i < sizeof(debugnames) / sizeof(debugnames[0]);
- i++, d++)
- if (len >= d->nchars && strncmp(d->name, p, len) == 0)
- break;
- if (i == sizeof(debugnames) / sizeof(debugnames[0])) {
- int j = 0xffffffff;
- int k = 0;
- fprintf(stderr, "Valid debug levels: ");
- for (i = 0, d = debugnames;
- i < sizeof(debugnames) / sizeof(debugnames[0]);
- i++, d++) {
- if ((j & d->level) == d->level) {
- if (k++)
- putc(',', stderr);
- fputs(d->name, stderr);
- j &= ~d->level;
- }
- }
- putc('\n', stderr);
- usage();
- }
- debug |= d->level;
- p = q;
- }
+ debug = atoi(*argv);
} else
debug = DEFAULT_DEBUG;
} else if (strcmp(*argv, "-c") == 0) {
@@ -219,7 +133,7 @@ main(argc, argv)
} else
usage();
} else if (strcmp(*argv, "-p") == 0) {
- log(LOG_WARNING, 0, "disabling pruning is no longer supported");
+ pruning = 0;
#ifdef SNMP
} else if (strcmp(*argv, "-P") == 0) {
if (argc > 1 && isdigit(*(argv + 1)[0])) {
@@ -236,23 +150,36 @@ main(argc, argv)
if (argc > 0)
usage();
- if (debug != 0) {
- struct debugname *d;
- char c;
- int tmpd = debug;
+ if (debug == 0) {
+ /*
+ * Detach from the terminal
+ */
+ int t;
- fprintf(stderr, "debug level 0x%x ", debug);
- c = '(';
- for (d = debugnames; d < debugnames +
- sizeof(debugnames) / sizeof(debugnames[0]); d++) {
- if ((tmpd & d->level) == d->level) {
- tmpd &= ~d->level;
- fprintf(stderr, "%c%s", c, d->name);
- c = ',';
- }
+ if (fork()) exit(0);
+ (void)close(0);
+ (void)close(1);
+ (void)close(2);
+ (void)open("/", 0);
+ (void)dup2(0, 1);
+ (void)dup2(0, 2);
+#ifdef SYSV
+ (void)setpgrp();
+#else
+#ifdef TIOCNOTTY
+ t = open("/dev/tty", 2);
+ if (t >= 0) {
+ (void)ioctl(t, TIOCNOTTY, (char *)0);
+ (void)close(t);
}
- fprintf(stderr, ")\n");
+#else
+ if (setsid() < 0)
+ warn("setsid");
+#endif
+#endif
}
+ else
+ fprintf(stderr, "debug level %u\n", debug);
#ifdef LOG_DAEMON
(void)openlog("mrouted", LOG_PID, LOG_DAEMON);
@@ -260,9 +187,10 @@ main(argc, argv)
#else
(void)openlog("mrouted", LOG_PID);
#endif
- sprintf(versionstring, "mrouted version %s", todaysversion);
+ sprintf(versionstring, "mrouted version %d.%da",
+ PROTOCOL_VERSION, MROUTED_VERSION);
- log(LOG_DEBUG, 0, "%s starting", versionstring);
+ log(LOG_NOTICE, 0, "%s", versionstring);
#ifdef SYSV
srand48(time(NULL));
@@ -290,27 +218,14 @@ main(argc, argv)
(void) fclose(fp);
}
- /* Start up the log rate-limiter */
- resetlogging(NULL);
-
callout_init();
init_igmp();
- init_icmp();
- init_ipip();
init_routes();
init_ktable();
+ k_init_dvmrp(); /* enable DVMRP routing in kernel */
+
#ifndef OLD_KERNEL
- /*
- * Unfortunately, you can't k_get_version() unless you've
- * k_init_dvmrp()'d. Now that we want to move the
- * k_init_dvmrp() to later in the initialization sequence,
- * we have to do the disgusting hack of initializing,
- * getting the version, then stopping the kernel multicast
- * forwarding.
- */
- k_init_dvmrp();
vers = k_get_version();
- k_stop_dvmrp();
/*XXX
* This function must change whenever the kernel version changes
*/
@@ -341,14 +256,33 @@ main(argc, argv)
rsrr_init();
#endif /* RSRR */
- sa.sa_handler = handler;
- sa.sa_flags = 0; /* Interrupt system calls */
- sigemptyset(&sa.sa_mask);
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGUSR1, &sa, NULL);
- sigaction(SIGUSR2, &sa, NULL);
+#if defined(__STDC__) || defined(__GNUC__)
+ /*
+ * Allow cleanup if unexpected exit. Apparently some architectures
+ * have a kernel bug where closing the socket doesn't do an
+ * ip_mrouter_done(), so we attempt to do it on exit.
+ */
+ atexit(cleanup);
+#endif
+
+ if (debug)
+ fprintf(stderr, "pruning %s\n", pruning ? "on" : "off");
+
+ fp = fopen(pidfilename, "w");
+ if (fp != NULL) {
+ fprintf(fp, "%d\n", (int)getpid());
+ (void) fclose(fp);
+ }
+
+ (void)signal(SIGALRM, fasttimer);
+
+ (void)signal(SIGHUP, restart);
+ (void)signal(SIGTERM, done);
+ (void)signal(SIGINT, done);
+ (void)signal(SIGUSR1, fdump);
+ (void)signal(SIGUSR2, cdump);
+ if (debug != 0)
+ (void)signal(SIGQUIT, dump);
FD_ZERO(&readers);
FD_SET(igmp_socket, &readers);
@@ -359,82 +293,30 @@ main(argc, argv)
nfds = ihandlers[i].fd + 1;
}
- IF_DEBUG(DEBUG_IF)
- dump_vifs(stderr);
- IF_DEBUG(DEBUG_ROUTE)
- dump_routes(stderr);
-
- /* schedule first timer interrupt */
- timer_setTimer(1, fasttimer, NULL);
- timer_setTimer(TIMER_INTERVAL, timer, NULL);
-
- if (debug == 0) {
- /*
- * Detach from the terminal
- */
- int t;
+ /*
+ * Install the vifs in the kernel as late as possible in the
+ * initialization sequence.
+ */
+ init_installvifs();
- haveterminal = 0;
- if (fork()) exit(0);
- (void)close(0);
- (void)close(1);
- (void)close(2);
- (void)open("/", 0);
- (void)dup2(0, 1);
- (void)dup2(0, 2);
-#if defined(SYSV) || defined(linux)
- (void)setpgrp();
-#else
-#ifdef TIOCNOTTY
- t = open("/dev/tty", 2);
- if (t >= 0) {
- (void)ioctl(t, TIOCNOTTY, (char *)0);
- (void)close(t);
- }
-#else
- if (setsid() < 0)
- perror("setsid");
-#endif
-#endif
- }
+ if (debug >= 2) dump(0);
- fp = fopen(pidfilename, "w");
- if (fp != NULL) {
- fprintf(fp, "%d\n", (int)getpid());
- (void) fclose(fp);
- }
+ /* Start up the log rate-limiter */
+ resetlogging(NULL);
- /* XXX HACK
- * This will cause black holes for the first few seconds after startup,
- * since we are exchanging routes but not actually forwarding.
- * However, it eliminates much of the startup transient.
- *
- * It's possible that we can set a flag which says not to report any
- * routes (just accept reports) until this timer fires, and then
- * do a report_to_all_neighbors(ALL_ROUTES) immediately before
- * turning on DVMRP.
- */
- timer_setTimer(10, final_init, NULL);
+ (void)alarm(1); /* schedule first timer interrupt */
/*
* Main receive loop.
*/
dummy = 0;
- difftime.tv_usec = 0;
- gettimeofday(&curtime, NULL);
- lasttime = curtime;
for(;;) {
+#ifdef SYSV
+ sigset_t block, oblock;
+#endif
bcopy((char *)&readers, (char *)&rfds, sizeof(rfds));
- secs = timer_nextTimer();
- if (secs == -1)
- timeout = NULL;
- else {
- timeout = &tv;
- timeout->tv_sec = secs;
- timeout->tv_usec = 0;
- }
#ifdef SNMP
- THIS IS BROKEN
+ gettimeofday(nvp, 0);
if (nvp->tv_sec > svp->tv_sec
|| (nvp->tv_sec == svp->tv_sec && nvp->tv_usec > svp->tv_usec)){
alarmTimer(nvp);
@@ -457,98 +339,49 @@ main(argc, argv)
if (block == 1)
tvp = NULL; /* block without timeout */
if ((n = select(nfds, &rfds, NULL, NULL, tvp)) < 0)
+#else
+ if ((n = select(nfds, &rfds, NULL, NULL, NULL)) < 0)
#endif
- if (sighandled) {
- if (sighandled & GOT_SIGINT) {
- sighandled &= ~GOT_SIGINT;
- break;
- }
- if (sighandled & GOT_SIGHUP) {
- sighandled &= ~GOT_SIGHUP;
- restart();
- }
- if (sighandled & GOT_SIGUSR1) {
- sighandled &= ~GOT_SIGUSR1;
- fdump();
- }
- if (sighandled & GOT_SIGUSR2) {
- sighandled &= ~GOT_SIGUSR2;
- cdump();
- }
- }
- if ((n = select(nfds, &rfds, NULL, NULL, timeout)) < 0) {
- if (errno != EINTR)
+ {
+ if (errno != EINTR) /* SIGALRM is expected */
log(LOG_WARNING, errno, "select failed");
continue;
}
- if (n > 0) {
- if (FD_ISSET(igmp_socket, &rfds)) {
- recvlen = recvfrom(igmp_socket, recv_buf, RECV_BUF_SIZE,
- 0, NULL, &dummy);
- if (recvlen < 0) {
- if (errno != EINTR) log(LOG_ERR, errno, "recvfrom");
- continue;
- }
- accept_igmp(recvlen);
+ if (FD_ISSET(igmp_socket, &rfds)) {
+ recvlen = recvfrom(igmp_socket, recv_buf, RECV_BUF_SIZE,
+ 0, NULL, &dummy);
+ if (recvlen < 0) {
+ if (errno != EINTR) log(LOG_ERR, errno, "recvfrom");
+ continue;
}
+#ifdef SYSV
+ (void)sigemptyset(&block);
+ (void)sigaddset(&block, SIGALRM);
+ if (sigprocmask(SIG_BLOCK, &block, &oblock) < 0)
+ log(LOG_ERR, errno, "sigprocmask");
+#else
+ omask = sigblock(sigmask(SIGALRM));
+#endif
+ accept_igmp(recvlen);
+#ifdef SYSV
+ (void)sigprocmask(SIG_SETMASK, &oblock, (sigset_t *)NULL);
+#else
+ (void)sigsetmask(omask);
+#endif
+ }
- for (i = 0; i < nhandlers; i++) {
- if (FD_ISSET(ihandlers[i].fd, &rfds)) {
- (*ihandlers[i].func)(ihandlers[i].fd, &rfds);
- }
+ for (i = 0; i < nhandlers; i++) {
+ if (FD_ISSET(ihandlers[i].fd, &rfds)) {
+ (*ihandlers[i].func)(ihandlers[i].fd, &rfds);
}
}
#ifdef SNMP
- THIS IS BROKEN
snmp_read(&rfds);
snmp_timeout(); /* poll */
#endif
- /*
- * Handle timeout queue.
- *
- * If select + packet processing took more than 1 second,
- * or if there is a timeout pending, age the timeout queue.
- *
- * If not, collect usec in difftime to make sure that the
- * time doesn't drift too badly.
- *
- * If the timeout handlers took more than 1 second,
- * age the timeout queue again. XXX This introduces the
- * potential for infinite loops!
- */
- do {
- /*
- * If the select timed out, then there's no other
- * activity to account for and we don't need to
- * call gettimeofday.
- */
- if (n == 0) {
- curtime.tv_sec = lasttime.tv_sec + secs;
- curtime.tv_usec = lasttime.tv_usec;
- n = -1; /* don't do this next time through the loop */
- } else
- gettimeofday(&curtime, NULL);
- difftime.tv_sec = curtime.tv_sec - lasttime.tv_sec;
- difftime.tv_usec += curtime.tv_usec - lasttime.tv_usec;
- while (difftime.tv_usec > 1000000) {
- difftime.tv_sec++;
- difftime.tv_usec -= 1000000;
- }
- if (difftime.tv_usec < 0) {
- difftime.tv_sec--;
- difftime.tv_usec += 1000000;
- }
- lasttime = curtime;
- if (secs == 0 || difftime.tv_sec > 0)
- age_callout_queue(difftime.tv_sec);
- secs = -1;
- } while (difftime.tv_sec > 0);
}
- log(LOG_NOTICE, 0, "%s exiting", versionstring);
- cleanup();
- exit(0);
}
static void
@@ -559,28 +392,6 @@ usage()
exit(1);
}
-static void
-final_init(i)
- void *i;
-{
- char *s = (char *)i;
-
- log(LOG_NOTICE, 0, "%s%s", versionstring, s ? s : "");
- if (s)
- free(s);
-
- k_init_dvmrp(); /* enable DVMRP routing in kernel */
-
- /*
- * Install the vifs in the kernel as late as possible in the
- * initialization sequence.
- */
- init_installvifs();
-
- time(&mrouted_init_time);
- did_final_init = 1;
-}
-
/*
* routine invoked every second. Its main goal is to cycle through
* the routing table and send partial updates to all neighbors at a
@@ -590,7 +401,7 @@ final_init(i)
*/
static void
fasttimer(i)
- void *i;
+ int i;
{
static unsigned int tlast;
static unsigned int nsent;
@@ -619,8 +430,12 @@ fasttimer(i)
}
tlast = t;
}
+ if ((t % TIMER_INTERVAL) == 0)
+ timer();
- timer_setTimer(1, fasttimer, NULL);
+ age_callout_queue();/* Advance the timer for the callout queue
+ for groups */
+ alarm(1);
}
/*
@@ -640,7 +455,7 @@ fasttimer(i)
* avoid unwanted synchronization with other routers.
*/
-u_long virtual_time = 0;
+static u_long virtual_time = 0;
/*
@@ -649,14 +464,13 @@ u_long virtual_time = 0;
* virtual interface data structures.
*/
static void
-timer(i)
- void *i;
+timer()
{
age_routes(); /* Advance the timers in the route entries */
age_vifs(); /* Advance the timers for neighbors */
age_table_entry(); /* Advance the timers for the cache entries */
- if (virtual_time % IGMP_QUERY_INTERVAL == 0) {
+ if (virtual_time % GROUP_QUERY_INTERVAL == 0) {
/*
* Time to query the local group memberships on all subnets
* for which this router is the elected querier.
@@ -695,10 +509,21 @@ timer(i)
* Advance virtual time
*/
virtual_time += TIMER_INTERVAL;
- timer_setTimer(TIMER_INTERVAL, timer, NULL);
}
+/*
+ * On termination, let everyone know we're going away.
+ */
+static void
+done(i)
+ int i;
+{
+ log(LOG_NOTICE, 0, "%s exiting", versionstring);
+ cleanup();
+ _exit(1);
+}
+
static void
cleanup()
{
@@ -711,76 +536,34 @@ cleanup()
#endif /* RSRR */
expire_all_routes();
report_to_all_neighbors(ALL_ROUTES);
- if (did_final_init)
- k_stop_dvmrp();
+ k_stop_dvmrp();
}
}
-/*
- * Signal handler. Take note of the fact that the signal arrived
- * so that the main loop can take care of it.
- */
-static void
-handler(sig)
- int sig;
-{
- switch (sig) {
- case SIGINT:
- case SIGTERM:
- sighandled |= GOT_SIGINT;
- break;
-
- case SIGHUP:
- sighandled |= GOT_SIGHUP;
- break;
-
- case SIGUSR1:
- sighandled |= GOT_SIGUSR1;
- break;
-
- case SIGUSR2:
- sighandled |= GOT_SIGUSR2;
- break;
- }
-}
/*
* Dump internal data structures to stderr.
*/
static void
-dump()
+dump(i)
+ int i;
{
dump_vifs(stderr);
dump_routes(stderr);
}
-static void
-dump_version(fp)
- FILE *fp;
-{
- time_t t;
-
- time(&t);
- fprintf(fp, "%s ", versionstring);
- if (did_final_init)
- fprintf(fp, "up %s",
- scaletime(t - mrouted_init_time));
- else
- fprintf(fp, "(not yet initialized)");
- fprintf(fp, " %s\n", ctime(&t));
-}
/*
* Dump internal data structures to a file.
*/
static void
-fdump()
+fdump(i)
+ int i;
{
FILE *fp;
fp = fopen(dumpfilename, "w");
if (fp != NULL) {
- dump_version(fp);
dump_vifs(fp);
dump_routes(fp);
(void) fclose(fp);
@@ -792,13 +575,13 @@ fdump()
* Dump local cache contents to a file.
*/
static void
-cdump()
+cdump(i)
+ int i;
{
FILE *fp;
fp = fopen(cachefilename, "w");
if (fp != NULL) {
- dump_version(fp);
dump_cache(fp);
(void) fclose(fp);
}
@@ -809,42 +592,52 @@ cdump()
* Restart mrouted
*/
static void
-restart()
+restart(i)
+ int i;
{
- char *s;
+ register int omask;
+#ifdef SYSV
+ sigset_t block, oblock;
+#endif
- s = (char *)malloc(sizeof(" restart"));
- if (s == NULL)
- log(LOG_ERR, 0, "out of memory");
- strcpy(s, " restart");
+ log(LOG_NOTICE, 0, "%s restart", versionstring);
/*
* reset all the entries
*/
+#ifdef SYSV
+ (void)sigemptyset(&block);
+ (void)sigaddset(&block, SIGALRM);
+ if (sigprocmask(SIG_BLOCK, &block, &oblock) < 0)
+ log(LOG_ERR, errno, "sigprocmask");
+#else
+ omask = sigblock(sigmask(SIGALRM));
+#endif
free_all_prunes();
free_all_routes();
- free_all_callouts();
stop_all_vifs();
k_stop_dvmrp();
close(igmp_socket);
close(udp_socket);
- did_final_init = 0;
/*
* start processing again
*/
dvmrp_genid++;
+ pruning = 1;
init_igmp();
init_routes();
init_ktable();
init_vifs();
- /*XXX Schedule final_init() as main does? */
- final_init(s);
+ k_init_dvmrp(); /* enable DVMRP routing in kernel */
+ init_installvifs();
- /* schedule timer interrupts */
- timer_setTimer(1, fasttimer, NULL);
- timer_setTimer(TIMER_INTERVAL, timer, NULL);
+#ifdef SYSV
+ (void)sigprocmask(SIG_SETMASK, &oblock, (sigset_t *)NULL);
+#else
+ (void)sigsetmask(omask);
+#endif
}
#define LOG_MAX_MSGS 20 /* if > 20/minute then shut up for a while */
@@ -870,61 +663,6 @@ resetlogging(arg)
timer_setTimer(nxttime, resetlogging, narg);
}
-char *
-scaletime(t)
- u_long t;
-{
-#define SCALETIMEBUFLEN 20
- static char buf1[20];
- static char buf2[20];
- static char *buf = buf1;
- char *p;
-
- p = buf;
- if (buf == buf1)
- buf = buf2;
- else
- buf = buf1;
-
- /* XXX snprintf */
- sprintf(p, "%2ld:%02ld:%02ld", t / 3600, (t % 3600) / 60, t % 60);
- p[SCALETIMEBUFLEN - 1] = '\0';
- return p;
-}
-
-#ifdef RINGBUFFER
-#define NLOGMSGS 10000
-#define LOGMSGSIZE 200
-char *logmsg[NLOGMSGS];
-static int logmsgno = 0;
-
-void
-printringbuf()
-{
- FILE *f;
- int i;
-
- f = fopen("/var/tmp/mrouted.log", "a");
- if (f == NULL) {
- log(LOG_ERR, errno, "can't open /var/tmp/mrouted.log");
- /*NOTREACHED*/
- }
- fprintf(f, "--------------------------------------------\n");
-
- i = (logmsgno + 1) % NLOGMSGS;
-
- while (i != logmsgno) {
- if (*logmsg[i]) {
- fprintf(f, "%s\n", logmsg[i]);
- *logmsg[i] = '\0';
- }
- i = (i + 1) % NLOGMSGS;
- }
-
- fclose(f);
-}
-#endif
-
/*
* Log errors and other messages to the system log daemon and to stderr,
* according to the severity of the message and the current debug level.
@@ -937,12 +675,10 @@ log(int severity, int syserr, char *format, ...)
va_list ap;
static char fmt[211] = "warning - ";
char *msg;
+ char tbuf[20];
struct timeval now;
time_t now_sec;
struct tm *thyme;
-#ifdef RINGBUFFER
- static int ringbufinit = 0;
-#endif
va_start(ap, format);
#else
@@ -954,15 +690,12 @@ log(severity, syserr, format, va_alist)
va_dcl
{
va_list ap;
- static char fmt[311] = "warning - ";
+ static char fmt[211] = "warning - ";
char *msg;
char tbuf[20];
struct timeval now;
time_t now_sec;
struct tm *thyme;
-#ifdef RINGBUFFER
- static int ringbufinit = 0;
-#endif
va_start(ap);
#endif
@@ -970,68 +703,36 @@ log(severity, syserr, format, va_alist)
va_end(ap);
msg = (severity == LOG_WARNING) ? fmt : &fmt[10];
-#ifdef RINGBUFFER
- if (!ringbufinit) {
- int i;
+ switch (debug) {
+ case 0: break;
+ case 1: if (severity > LOG_NOTICE) break;
+ case 2: if (severity > LOG_INFO ) break;
+ default:
+ gettimeofday(&now,NULL);
+ now_sec = now.tv_sec;
+ thyme = localtime(&now_sec);
+ strftime(tbuf, sizeof(tbuf), "%X.%%03d ", thyme);
+ fprintf(stderr, tbuf, now.tv_usec / 1000);
+ fprintf(stderr, "%s", msg);
+ if (syserr == 0)
+ fprintf(stderr, "\n");
+ else if (syserr < sys_nerr)
+ fprintf(stderr, ": %s\n", sys_errlist[syserr]);
+ else
+ fprintf(stderr, ": errno %d\n", syserr);
+ }
- for (i = 0; i < NLOGMSGS; i++) {
- logmsg[i] = malloc(LOGMSGSIZE);
- if (logmsg[i] == 0) {
- syslog(LOG_ERR, "out of memory");
- exit(-1);
- }
- *logmsg[i] = 0;
+ if (severity <= LOG_NOTICE) {
+ if (log_nmsgs++ < LOG_MAX_MSGS) {
+ if (syserr != 0) {
+ errno = syserr;
+ syslog(severity, "%s: %m", msg);
+ } else
+ syslog(severity, "%s", msg);
}
- ringbufinit = 1;
- }
- gettimeofday(&now,NULL);
- now_sec = now.tv_sec;
- thyme = localtime(&now_sec);
- sprintf(logmsg[logmsgno++], "%02d:%02d:%02d.%03ld %s err %d",
- thyme->tm_hour, thyme->tm_min, thyme->tm_sec,
- now.tv_usec / 1000, msg, syserr);
- logmsgno %= NLOGMSGS;
- if (severity <= LOG_NOTICE)
-#endif
- /*
- * Log to stderr if we haven't forked yet and it's a warning or worse,
- * or if we're debugging.
- */
- if (haveterminal && (debug || severity <= LOG_WARNING)) {
- gettimeofday(&now,NULL);
- now_sec = now.tv_sec;
- thyme = localtime(&now_sec);
- if (!debug)
- fprintf(stderr, "%s: ", progname);
- fprintf(stderr, "%02d:%02d:%02d.%03ld %s", thyme->tm_hour,
- thyme->tm_min, thyme->tm_sec, now.tv_usec / 1000, msg);
- if (syserr == 0)
- fprintf(stderr, "\n");
- else if (syserr < sys_nerr)
- fprintf(stderr, ": %s\n", sys_errlist[syserr]);
- else
- fprintf(stderr, ": errno %d\n", syserr);
- }
- /*
- * Always log things that are worse than warnings, no matter what
- * the log_nmsgs rate limiter says.
- * Only count things worse than debugging in the rate limiter
- * (since if you put daemon.debug in syslog.conf you probably
- * actually want to log the debugging messages so they shouldn't
- * be rate-limited)
- */
- if ((severity < LOG_WARNING) || (log_nmsgs < LOG_MAX_MSGS)) {
- if (severity < LOG_DEBUG)
- log_nmsgs++;
- if (syserr != 0) {
- errno = syserr;
- syslog(severity, "%s: %m", msg);
- } else
- syslog(severity, "%s", msg);
+ if (severity <= LOG_ERR) exit(1);
}
-
- if (severity <= LOG_ERR) exit(-1);
}
#ifdef DEBUG_MFC
diff --git a/usr.sbin/mrouted/mapper.c b/usr.sbin/mrouted/mapper.c
index 0a5f33cfcd9c..e440bbcb9b30 100644
--- a/usr.sbin/mrouted/mapper.c
+++ b/usr.sbin/mrouted/mapper.c
@@ -1,7 +1,5 @@
/* Mapper for connections between MRouteD multicast routers.
* Written by Pavel Curtis <Pavel@PARC.Xerox.Com>
- *
- * mapper.c,v 3.8.4.3 1998/01/06 01:57:47 fenner Exp
*/
/*
@@ -23,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: mapper.c,v 1.13 1998/06/09 05:01:30 imp Exp $";
+ "$Id: mapper.c,v 1.12 1998/01/16 07:17:43 charnier Exp $";
#endif /* not lint */
#include <err.h>
@@ -912,7 +910,7 @@ int main(argc, argv)
int addrlen = sizeof(addr);
addr.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
+#if (defined(BSD) && (BSD >= 199103))
addr.sin_len = sizeof addr;
#endif
addr.sin_addr.s_addr = dvmrp_group;
diff --git a/usr.sbin/mrouted/mrinfo.c b/usr.sbin/mrouted/mrinfo.c
index ff8a7b85604c..b62249e080de 100644
--- a/usr.sbin/mrouted/mrinfo.c
+++ b/usr.sbin/mrouted/mrinfo.c
@@ -61,7 +61,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: mrinfo.c,v 1.15 1998/06/09 05:01:34 imp Exp $";
+ "$Id: mrinfo.c,v 1.14 1998/01/16 07:17:43 charnier Exp $";
/* original rcsid:
"@(#) Header: mrinfo.c,v 1.6 93/04/08 15:14:16 van Exp (LBL)";
*/
@@ -238,14 +238,13 @@ accept_neighbors2(src, dst, p, datalen, level)
u_char *ep = p + datalen;
u_int broken_cisco = ((level & 0xffff) == 0x020a); /* 10.2 */
/* well, only possibly_broken_cisco, but that's too long to type. */
- u_int majvers = level & 0xff;
- u_int minvers = (level >> 8) & 0xff;
- printf("%s (%s) [", inet_fmt(src, s1), inet_name(src));
- if (majvers == 3 && minvers == 0xff)
- printf("DVMRPv3 compliant");
- else
- printf("version %d.%d", majvers, minvers);
+ printf("%s (%s) [version %d.%d", inet_fmt(src, s1), inet_name(src),
+ level & 0xff, (level >> 8) & 0xff);
+ if ((level >> 16) & NF_LEAF) { printf (",leaf"); }
+ if ((level >> 16) & NF_PRUNE) { printf (",prune"); }
+ if ((level >> 16) & NF_GENID) { printf (",genid"); }
+ if ((level >> 16) & NF_MTRACE) { printf (",mtrace"); }
printf ("]:\n");
while (p < ep) {
@@ -398,7 +397,7 @@ main(argc, argv)
int addrlen = sizeof(addr);
addr.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
+#if (defined(BSD) && (BSD >= 199103))
addr.sin_len = sizeof addr;
#endif
addr.sin_addr.s_addr = target_addr;
@@ -491,11 +490,7 @@ main(argc, argv)
src = ip->ip_src.s_addr;
dst = ip->ip_dst.s_addr;
iphdrlen = ip->ip_hl << 2;
-#ifdef RAW_INPUT_IS_RAW
- ipdatalen = ntohs(ip->ip_len) - iphdrlen;
-#else
ipdatalen = ip->ip_len;
-#endif
if (iphdrlen + ipdatalen != recvlen) {
log(LOG_WARNING, 0,
"packet shorter (%u bytes) than hdr+data length (%u+%u)",
diff --git a/usr.sbin/mrouted/mrouted.8 b/usr.sbin/mrouted/mrouted.8
index 823ad87f1976..c30cd3b34a3d 100644
--- a/usr.sbin/mrouted/mrouted.8
+++ b/usr.sbin/mrouted/mrouted.8
@@ -1,5 +1,5 @@
.\"COPYRIGHT 1989 by The Board of Trustees of Leland Stanford Junior University.
-.\"$Id: mrouted.8,v 1.11 1998/08/31 16:41:08 wosch Exp $
+.\"$Id: mrouted.8,v 1.10 1997/09/30 06:15:10 charnier Exp $
.Dd May 8, 1995
.Dt MROUTED 8
.UC 5
@@ -34,17 +34,17 @@ routers that do not support IP multicasting,
.Nm
includes support for
"tunnels", which are virtual point-to-point links between pairs of
-multicast routers
+.Nm mrouted Ns s
located anywhere in an internet. IP multicast packets are encapsulated for
transmission through tunnels, so that they look like normal unicast datagrams
to intervening routers and subnets. The encapsulation
is added on entry to a tunnel, and stripped off
on exit from a tunnel.
-The packets are encapsulated using the IP-in-IP protocol
+By default, the packets are encapsulated using the IP-in-IP protocol
(IP protocol number 4).
Older versions of
.Nm
-tunneled using IP source routing, which puts a heavy load on some
+tunnel using IP source routing, which puts a heavy load on some
types of routers.
This version does not support IP source route tunnelling.
.Pp
@@ -81,42 +81,25 @@ option is given, or if the debug level is specified as 0,
.Nm
detaches from the invoking terminal. Otherwise, it remains attached to the
invoking terminal and responsive to signals from that terminal.
-Regardless of the debug level,
+If
+.Fl d
+is given with no argument, the debug level defaults to 2. Regardless of the
+debug level,
.Nm
always writes warning and error messages to the system
-log demon. The
-.Fl debug-level
-argument is a comma-seperated list of any of the following:
+log demon. Non-zero debug levels have the following effects:
.Bl -tag -width indent
-.It "packet"
-Display the type, source and destination of all packets sent or received.
-.It "pruning"
-Display more information about prunes sent or received.
-.It "routing"
-Display more information about routing update packets sent or received.
-.It "route_detail"
-Display routing updates in excruciating detail. This is generally way too
-much information.
-.It "neighbors"
-Display information about neighbor discovery.
-.It "cache"
-Display insertions, deletions and refreshes of entries in
-the kernel forwarding cache.
-.It "timeout"
-Debug timeouts and periodic processes.
-.It "interface"
-Display information about interfaces and their configuration.
-.It "membership"
-Display information about group memberships on physical interfaces.
-.It "traceroute"
-Display information about multicast traceroute requests
-passing through this router.
-.It "igmp"
-Display IGMP operation including group membership and querier election.
-.It "icmp"
-Monitor ICMP handling.
-.It "rsrr"
-Monitor RSRR operation.
+.It "level 1"
+all syslog'ed messages are also printed to stderr.
+.It "level 2"
+all level 1 messages plus notifications of "significant"
+events are printed to stderr.
+.It "level 3"
+all level 2 messages plus notifications of all packet
+arrivals and departures are printed to stderr.
+.El
+.It Fl p
+Disable pruning.
.El
.Pp
Upon startup,
@@ -127,246 +110,106 @@ writes its pid to the file
.Nm Mrouted
automatically configures itself to forward on all multicast-capable
interfaces, i.e., interfaces that have the IFF_MULTICAST flag set (excluding
-the loopback "interface"), and it finds other DVMRP routers directly reachable
+the loopback "interface"), and it finds other
+.Nm mrouted Ns s
+directly reachable
via those interfaces. To override the default configuration, or to add
-tunnel links to other multicast routers,
+tunnel links to other
+.Nm mrouted Ns s,
configuration commands may be placed in
.Pa /etc/mrouted.conf
(or an alternative file, specified by the
.Fl c
option).
+There are four types of configuration commands:
+.nf
+
+ phyint <local-addr> [disable] [metric <m>] [advert_metric <m>]
+ [threshold <t>] [rate_limit <b>]
+ [boundary (<boundary-name>|<scoped-addr>/<mask-len>)]
+ [altnet <network>/<mask-len>]
+
+ tunnel <local-addr> <remote-addr> [metric <m>] [advert_metric <m>]
+ [threshold <t>] [rate_limit <b>]
+ [boundary (<boundary-name>|<scoped-addr>/<mask-len>)]
+
+ cache_lifetime <ct>
+
+ name <boundary-name> <scoped-addr>/<mask-len>
+
+.fi
.Pp
The file format is free-form; whitespace (including newlines) is not
significant.
-The file begins with commands that apply to
-.IR mrouted 's
-overall operation or set defaults.
-.Bl -tag -width indent
-.It cache_lifetime Ar secs
-Specifies, in seconds, the lifetime of a multicast forwarding cache
-entry in the kernel. Multicast forwarding cache entries in the kernel
-are checked every
-.Ar secs
-seconds, and are refreshed if the source is still
-active or deleted if not. Care should be taken when setting this value,
-as a low value can keep the kernel cache small at the cost of "thrashing"
-the cache for periodic senders, but high values can cause the kernel
-cache to grow unacceptably large. The default is 300 seconds (5 minutes).
-.It prune_lifetime Ar secs
-Sepcifies, in seconds, the average lifetime of prunes that are sent towards
-parents. The actual lifetimes will be randomized in the range
-[.5\fIsecs\fP,1.5\fIsecs\fP]. The default is 7200 (2 hours). Smaller values
-cause less state to be kept both at this router and the parent, at the
-cost of more frequent broadcasts. However, some routers (e.g. mrouted <3.3
-and all currently known versions of cisco's IOS) do not use the
-DVMRP generation ID to determine that a neighbor has rebooted. Prunes
-sent towards these neighbors should be kept short, in order to shorten
-the time to recover from a reboot. For use in this situation, the
-prune_lifetime keyword may be specified on an interface as described
-below.
-.It noflood
-.Nm Mrouted
-uses a DVMRP optimization to prevent having to keep individual routing tables
-for each neighbor; part of this optimization is that
-.Nm
-assumes that it is the forwarder for each of its attached subnets on
-startup. This can cause duplicates for a short period (approximately
-one full route report interval), since both the router that just
-started up and the proper forwarder will be forwarding traffic. This
-behavior can be turned off with the noflood keyword;
-.Nm
-will not assume that it is the forwarder on startup.
-Turning on noflood can cause black holes on restart, which will generally
-last approximately one full route report interval.
-The noflood keyword can also be specified on individual interfaces.
-.It rexmit_prunes Ar [on|off]
-.Nm Mrouted 's
-default is to retransmit prunes on all point-to-point interfaces
-(including tunnels) but no multi-access interfaces. This option
-may be used to make the default on (or off) for all interfaces.
-The rexmit_prunes keyword can also be specified on individual interfaces.
-.It name Ar "boundary-name scoped-addr/mask-len"
-Associates
-.Ar boundary-name
-with the boundary described by
-.Ar scoped-addr/mask-len ,
-to help make interface configurations
-more readable and reduce repetition in the configuration file.
-.El
+The
+.Em boundary
+and
+.Em altnet
+options may be specified as many times as necessary.
.Pp
-The second section of the configuration file, which may optionally
-be empty, describes options that apply to physical interfaces.
-.Bl -tag -width indent
-.It phyint Ar "local-addr|ifname"
-The phyint command does nothing by itself; it is simply a place holder
-which interface-specific commands may follow. An interface address or
-name may be specified.
-.It disable
-Disables multicast forwarding on this interface. By default,
-.Nm
-discovers all locally attached multicast capable interfaces and forwards
-on all of them.
-.It netmask Ar netmask
-If the kernel's netmask does not accurately reflect
-the subnet (e.g. you're using proxy-ARP in lieu of IP subnetting), use the
-netmask command to describe the real netmask.
-.It altnet Ar network/mask-len
+The phyint command can be used to disable multicast routing on the physical
+interface identified by local IP address <local-addr>, or to associate a
+non-default metric or threshold with the specified physical interface.
+The local IP address <local-addr> may be replaced by the
+interface name (e.g le0).
If a phyint is attached to multiple IP subnets, describe each additional subnet
-with the altnet keyword. This command may be specified multiple times
-to describe multiple subnets.
-.It igmpv1
-If there are any IGMPv1 routers on the phyint, use the \fBigmpv1\fP
-keyword to force
-.Nm
-into IGMPv1 mode. All routers on the phyint
-must use the same version of IGMP.
-.It force_leaf
-Force
-.Nm
-to ignore other routers on this interface.
-mrouted will never send or accept neighbor probes or
-route reports on this interface.
-.El
+with the altnet keyword.
+Phyint commands must precede tunnel commands.
.Pp
-In addition, the common vif commands described later may all be used on
-a phyint.
+The tunnel command can be used to establish a tunnel link between local
+IP address <local-addr> and remote IP address <remote-addr>, and to associate
+a non-default metric or threshold with that tunnel.
+The local IP address <local-addr> may be replaced by the
+interface name (e.g. le0). The remote IP address <remote-addr> may
+be replaced by a host name, if and only if the host name has a single
+IP address associated with it.
+The tunnel must be set
+up in the
+.Pa mrouted.conf
+files of both routers before it can be used.
.Pp
-The third section of the configuration file, also optional, describes
-the configuration of any DVMRP tunnels this router might have.
-.Bl -tag -width indent
-.It tunnel Ar "local-addr|ifname" Ar "remote-addr|remote-hostname"
-This command establishes a DVMRP tunnel between this host (on the interface
-described by
-.Ar local-addr
-or
-.Ar ifname )
-and a remote host (identified by
-.Ar remote-addr
-or
-.Ar remote-hostname ).
-A remote hostname may only be used if
-it maps to a single IP address.
-A tunnel must be configured on both routers before it can be used.
-
-Be careful that the unicast route to the remote address goes out the
-interface specified by the
-.Ar "local-addr|ifname"
-argument. Some UNIX
-kernels rewrite the source address of
-.Nm mrouted 's
-packets on their way out to contain the address of the transmission
-interface. This is best assured via a static host route.
-.El
+The cache_lifetime is a value that determines the amount of time that a
+cached multicast route stays in kernel before timing out. The value of this
+entry should lie between 300 (5 min) and 86400 (1 day). It defaults to 300.
.Pp
-The common vif commands described below
-may all be used on tunnels or phyints.
-.Bl -tag -width indent
-.It metric Ar m
-The metric is the "cost" associated with receiving a datagram on the given
+You may assign names to boundaries to make configuration easier with
+the name keyword. The boundary option on phyint or tunnel commands
+can accept either a name or a boundary.
+.Pp
+The metric is the "cost" associated with sending a datagram on the given
interface or tunnel; it may be used to influence the choice of routes.
The metric defaults to 1. Metrics should be kept as small as possible,
-because DVMRP cannot route along paths with a sum of metrics greater
+because
+.Nm
+cannot route along paths with a sum of metrics greater
than 31.
-.It advert_metric Ar m
-The advert_metric is the "cost" associated with sending a datagram
+.Pp
+The advert_metric is the "cost" associated with receiving a datagram
on the given interface or tunnel; it may be used to influence the choice
of routes. The advert_metric defaults to 0. Note that the effective
metric of a link is one end's metric plus the other end's advert_metric.
-.It threshold Ar t
+.Pp
The threshold is the minimum IP time-to-live required for a multicast datagram
to be forwarded to the given interface or tunnel. It is used to control the
scope of multicast datagrams. (The TTL of forwarded packets is only compared
to the threshold, it is not decremented by the threshold. Every multicast
-router decrements the TTL by exactly 1.) The default threshold is 1.
-
-In general, all multicast routers
+router decrements the TTL by 1.) The default threshold is 1.
+.Pp
+In general, all
+.Nm mrouted Ns s
connected to a particular subnet or tunnel should
use the same metric and threshold for that subnet or tunnel.
-.It rate_limit Ar r
+.Pp
The rate_limit option allows the network administrator to specify a
certain bandwidth in Kbits/second which would be allocated to multicast
-traffic. It defaults 0 (unlimited).
-.It boundary Ar "boundary-name|scoped-addr/mask-len"
+traffic. It defaults to 500Kbps on tunnels, and 0 (unlimited) on physical
+interfaces.
+.Pp
The boundary option allows an interface
to be configured as an administrative boundary for the specified
scoped address. Packets belonging to this address will not
be forwarded on a scoped interface. The boundary option accepts either
-a name or a boundary spec. This command may be specified several times
-on an interface in order to describe multiple boundaries.
-.It passive
-No packets will be sent on this link or tunnel until we hear from the other
-end. This is useful for the "server" end of a tunnel that goes over
-a dial-on-demand link; configure the "server" end as passive and
-it will not send its periodic probes until it hears one from the other
-side, so will not keep the link up. If this option is specified on both
-ends of a tunnel, the tunnel will never come up.
-.It noflood
-As described above, but only applicable to this interface/tunnel.
-.It prune_lifetime Ar secs
-As described above, but only applicable to this interface/tunnel.
-.It rexmit_prunes Ar "[on|off]"
-As described above, but only applicable to this interface/tunnel.
-Recall that prune retransmission
-defaults to on on point-to-point links and tunnels, and off on
-multi-access links.
-.It allow_nonpruners
-By default,
-.Nm
-refuses to peer with DVMRP neighbors that
-do not claim to support pruning. This option allows such peerings
-on this interface.
-.It notransit
-A specialized case of route filtering; no route learned from an interface
-marked "notransit" will be advertised on another interface marked
-"notransit". Marking only a single interface "notransit" has no meaning.
-.It accept|deny Ar "(route/mask-len [exact])+" Op bidir
-The
-.Li accept
-and
-.Li deny
-commands allow rudimentary route filtering. The
-.Li accept
-command causes
-.Nm
-to accept only the listed routes on the configured interface; the
-.Li deny
-command causes
-.Nm
-to accept all but the listed routes.
-Only one of
-.Li accept
-or
-.Li deny
-commands may be used on a given interface.
-
-The list of routes follows the
-.Li accept
-or
-.Li deny
-keyword. If the keyword
-.Ar exact
-follows a route, then only that route is matched; otherwise, that route
-and any more specific route is matched. For example,
-.Li deny 0/0
-denys all routes, while
-.Li deny 0/0 exact
-denys only the default route. The default route may also be specified
-with the
-.Li default
-keyword.
-
-The
-.Ar bidir
-keyword enables bidirectional route filtering; the filter will be applied
-to routes on both output and input. Without the
-.Ar bidir
-keyword,
-.Li accept
-and
-.Li deny
-filters are only applied on input. Poison reverse routes are never
-filtered out.
-.El
+a name or a boundary spec.
.Pp
.Nm Mrouted
will not initiate execution if it has fewer than two enabled vifs,
@@ -375,7 +218,7 @@ interface or a tunnel. It will log a warning if all of its vifs are
tunnels; such an
.Nm
configuration would be better replaced by more
-direct tunnels (i.e. eliminate the middle man).
+direct tunnels (i.e., eliminate the middle man).
.Sh "EXAMPLE CONFIGURATION"
This is an example configuration for a mythical multicast router at a big
school.
@@ -447,17 +290,16 @@ upon startup.
.Sh EXAMPLE
The routing tables look like this:
.nf
-.ft C
Virtual Interface Table
Vif Local-Address Metric Thresh Flags
- 0 36.2.0.8 subnet: 36.2/16 1 1 querier
+ 0 36.2.0.8 subnet: 36.2 1 1 querier
groups: 224.0.2.1
224.0.0.4
pkts in: 3456
pkts out: 2322323
- 1 36.11.0.1 subnet: 36.11/16 1 1 querier
+ 1 36.11.0.1 subnet: 36.11 1 1 querier
groups: 224.0.2.1
224.0.1.0
224.0.0.4
@@ -465,9 +307,9 @@ Virtual Interface Table
pkts out: 3456
2 36.2.0.8 tunnel: 36.8.0.77 3 1
- peers: 36.8.0.77 (3.255)
- boundaries: 239.0.1/24
- : 239.1.2/24
+ peers: 36.8.0.77 (2.2)
+ boundaries: 239.0.1
+ : 239.1.2
pkts in: 34545433
pkts out: 234342
@@ -483,7 +325,6 @@ Multicast Routing Table (1136 entries)
.
.fi
-.Pp
In this example, there are four vifs connecting to two subnets and two
tunnels. The vif 3 tunnel is not in use (no peer address). The vif 0 and
vif 1 subnets have some groups present; tunnels never have any groups. This
@@ -511,7 +352,6 @@ are created and deleted by
.Pp
The cache tables look like this:
.nf
-.ft C
Multicast Routing Cache Table (147 entries)
Origin Mcast-group CTmr Age Ptmr IVif Forwvifs
@@ -526,14 +366,14 @@ Multicast Routing Cache Table (147 entries)
>198.106.194.22
.fi
-.Pp
Each entry is characterized by the origin subnet number and mask and the
destination multicast group.
.Pp
The 'CTmr' field indicates the lifetime
of the entry. The entry is deleted from the cache table
-(or refreshed, if traffic is flowing)
-when the timer decrements to zero. The 'Age' field is the time since
+when the timer decrements to zero.
+.Pp
+The 'Age' field is the time since
this cache entry was originally created. Since cache entries get refreshed
if traffic is flowing, routing entries can grow very old.
.Pp
@@ -551,7 +391,7 @@ indicated by a "P" after the vif number.
The Forwvifs field shows the
interfaces along which datagrams belonging to the source-group are
forwarded. A "p" indicates that no datagrams are being forwarded along
-that interface. An unlisted interface is a leaf subnet with no
+that interface. An unlisted interface is a leaf subnet with are no
members of the particular group on that subnet. A "b" on an interface
indicates that it is a boundary interface, i.e. traffic will not be
forwarded on the scoped address on that interface.
@@ -559,9 +399,6 @@ forwarded on the scoped address on that interface.
An additional line with a ">" as the first character is printed for
each source on the subnet. Note that there can be many sources in
one subnet.
-An additional line with a "<" as the first character is printed
-describing any prunes received from downstream dependent neighbors
-for this subnet and group.
.Sh FILES
.Bl -tag -width /var/tmp/mrouted.cache -compact
.It Pa /etc/mrouted.conf
diff --git a/usr.sbin/mrouted/mrouted.conf b/usr.sbin/mrouted/mrouted.conf
index d016f4823893..1e6924422233 100644
--- a/usr.sbin/mrouted/mrouted.conf
+++ b/usr.sbin/mrouted/mrouted.conf
@@ -1,5 +1,4 @@
-# $Id: mrouted.conf,v 1.7 1997/02/22 16:07:00 peter Exp $
-# mrouted.conf,v 3.8 1995/11/29 22:40:47 fenner Rel
+# $Id$
#
# This is the configuration file for "mrouted", an IP multicast router.
# mrouted looks for it in "/etc/mrouted.conf".
diff --git a/usr.sbin/mrouted/mrouted/Makefile b/usr.sbin/mrouted/mrouted/Makefile
index 1694495b4dc9..943781085edb 100644
--- a/usr.sbin/mrouted/mrouted/Makefile
+++ b/usr.sbin/mrouted/mrouted/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.10 1998/05/05 13:19:13 bde Exp $
+# $Id: Makefile,v 1.9 1998/05/04 19:54:56 bde Exp $
PROG= mrouted
@@ -9,13 +9,7 @@ YFLAGS=
DPADD= ${LIBMROUTED}
LDADD= ${LIBMROUTED}
-SRCS= config.c cfparse.y main.c route.c vif.c prune.c callout.c rsrr.c \
- ipip.c icmp.c vers.c
-CLEANFILES+= vers.c
+SRCS= config.c cfparse.y main.c route.c vif.c prune.c callout.c rsrr.c
MAN8= mrouted.8
-vers.c: $S/VERSION
- rm -f vers.c ; \
- sed 's/.*/char todaysversion[] = "&";/' $S/VERSION > vers.c
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/mrouted/mtrace.8 b/usr.sbin/mrouted/mtrace.8
index 4cfaf30bba5b..df58f5a7a3b0 100644
--- a/usr.sbin/mrouted/mtrace.8
+++ b/usr.sbin/mrouted/mtrace.8
@@ -29,7 +29,7 @@
.\" Copyright (c) 1988 The Regents of the University of California.
.\" All rights reserved.
.\"
-.\" mtrace.8,v 5.2 1998/12/04 04:48:16 fenner Exp
+.\" mtrace.8,v 5.1 1996/12/19 21:31:26 fenner Exp
.\"
.Dd May 8, 1995
.Dt MTRACE 8
@@ -80,7 +80,7 @@ host name or address. The default
.Ar receiver
is the host running mtrace, and the default
.Ar group
-is 0.0.0.0, which is sufficient if packet loss
+is "MBone Audio" (224.2.0.1), which is sufficient if packet loss
statistics for a particular multicast group are not needed. These two
optional parameters may be specified to test the path to some other
receiver in a particular group, subject to some constraints as
diff --git a/usr.sbin/mrouted/mtrace.c b/usr.sbin/mrouted/mtrace.c
index 0018aec81de6..1686451b7365 100644
--- a/usr.sbin/mrouted/mtrace.c
+++ b/usr.sbin/mrouted/mtrace.c
@@ -96,24 +96,11 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
- *
- * The mtrace program has been modified and improved by Xerox
- * Corporation. Xerox grants to LICENSEE a non-exclusive and
- * non-transferable license to use, copy, and modify the Xerox modified
- * and improved mrouted software on the same terms and conditions which
- * govern the license Stanford and ISI grant with respect to the mtrace
- * program. These terms and conditions are incorporated in this grant
- * by reference and shall be deemed to have been accepted by LICENSEE
- * to cover its relationship with Xerox Corporation with respect to any
- * use of the Xerox improved program.
- *
- * The mtrace program is COPYRIGHT 1998 by Xerox Corporation.
- *
*/
#ifndef lint
static const char rcsid[] =
- "$Id: mtrace.c,v 1.15 1998/06/29 17:51:39 bde Exp $";
+ "$Id: mtrace.c,v 1.14 1998/06/09 05:01:35 imp Exp $";
#endif
#include <ctype.h>
@@ -150,12 +137,13 @@ static const char rcsid[] =
#endif
typedef unsigned int u_int32; /* XXX */
+
#include "mtrace.h"
#define DEFAULT_TIMEOUT 3 /* How long to wait before retrying requests */
#define DEFAULT_RETRIES 3 /* How many times to try */
#define DEFAULT_EXTRAHOPS 3 /* How many hops past a non-responding rtr */
-#define MAXHOPS 60 /* Don't need more hops than this */
+#define MAXHOPS 32 /* Don't need more hops than max metric */
#define UNICAST_TTL 255 /* TTL for unicast response */
#define MULTICAST_TTL1 127 /* Default TTL for multicast query/response */
#define MULTICAST_TTL_INC 32 /* TTL increment for increase after timeout */
@@ -191,8 +179,7 @@ struct resp_buf {
#define resps u.t.r
#define ndata u.d
-char *names[MAXHOPS];
-
+char names[MAXHOPS][40];
/*
* In mrouted 3.3 and 3.4 (and in some Cisco IOS releases),
* cache entries can get deleted even if there is traffic
@@ -230,8 +217,6 @@ struct mtrace {
int nresp;
struct timeval last;
int bugs[MAXHOPS];
- char *names[MAXHOPS];
- int lastqid;
};
int timeout = DEFAULT_TIMEOUT;
@@ -248,16 +233,13 @@ int weak = FALSE;
int extrahops = DEFAULT_EXTRAHOPS;
int printstats = TRUE;
int sendopts = TRUE;
-int lossthresh = 0;
-int fflag = FALSE;
-int staticqid = 0;
u_int32 defgrp; /* Default group if not specified */
u_int32 query_cast; /* All routers multicast addr */
u_int32 resp_cast; /* Mtrace response multicast addr */
u_int32 lcl_addr = 0; /* This host address, in NET order */
-u_int32 dst_netmask = 0; /* netmask to go with qdst */
+u_int32 dst_netmask; /* netmask to go with qdst */
/*
* Query/response parameters, all initialized to zero and set later
@@ -292,14 +274,14 @@ char router_alert[4]; /* Router Alert IP Option */
#define IPOPT_RA 148
#endif
#ifdef SUNOS5
-char eol[4]; /* EOL IP Option */
+char no_op[4]; /* Null IP Option */
int ip_addlen = 0; /* Workaround for Option bug #2 */
#endif
/*
* max macro, with weird case to avoid conflicts
*/
-#define MaX(a,b) ((a) > (b) ? (a) : (b))
+#define MaX(a,b) (a) > (b) ? (a) : (b)
#ifndef __P
#ifdef __STDC__
@@ -309,10 +291,7 @@ int ip_addlen = 0; /* Workaround for Option bug #2 */
#endif
#endif
-typedef int (*callback_t) __P((int, u_char *, int, struct igmp *, int,
- struct sockaddr *, int *, struct timeval *));
-
-void init_igmp __P((void));
+void init_igmp __P(());
void send_igmp __P((u_int32 src, u_int32 dst, int type,
int code, u_int32 group,
int datalen));
@@ -332,21 +311,15 @@ u_int32 host_addr __P((char *name));
char * proto_type __P((u_int type));
char * flag_type __P((u_int type));
-u_int32 get_netmask __P((int s, u_int32 *dst));
+u_int32 get_netmask __P((int s, u_int32 dst));
int get_ttl __P((struct resp_buf *buf));
int t_diff __P((u_long a, u_long b));
-u_long byteswap __P((u_long v));
-int mtrace_callback __P((int, u_char *, int, struct igmp *,
- int, struct sockaddr *, int *,
- struct timeval *));
+u_long fixtime __P((u_long time, struct resp_buf *base));
int send_recv __P((u_int32 dst, int type, int code,
- int tries, struct resp_buf *save,
- callback_t callback));
-void passive_mode __P((void));
+ int tries, struct resp_buf *save));
char * print_host __P((u_int32 addr));
char * print_host2 __P((u_int32 addr1, u_int32 addr2));
-void print_trace __P((int idx, struct resp_buf *buf,
- char **names));
+void print_trace __P((int index, struct resp_buf *buf));
int what_kind __P((struct resp_buf *buf, char *why));
char * scale __P((int *hop));
void stat_line __P((struct tr_resp *r, struct tr_resp *s,
@@ -355,15 +328,10 @@ void fixup_stats __P((struct resp_buf *base,
struct resp_buf *prev,
struct resp_buf *new,
int *bugs));
-int check_thresh __P((int thresh,
- struct resp_buf *base,
- struct resp_buf *prev,
- struct resp_buf *new));
int print_stats __P((struct resp_buf *base,
struct resp_buf *prev,
struct resp_buf *new,
- int *bugs,
- char **names));
+ int *bugs));
int path_changed __P((struct resp_buf *base,
struct resp_buf *new));
void check_vif_state __P((void));
@@ -381,6 +349,9 @@ void
init_igmp()
{
struct ip *ip;
+#ifdef SUNOS5
+ u_int32 localhost = htonl(0x7f000001);
+#endif
recv_buf = (char *)malloc(RECV_BUF_SIZE);
if (recv_buf == 0)
@@ -414,20 +385,17 @@ init_igmp()
router_alert[1] = 4; /* 4 bytes */
router_alert[2] = 0;
router_alert[3] = 0;
-}
#ifdef SUNOS5
-void
-checkforsolarisbug()
-{
- u_int32 localhost = htonl(0x7f000001);
+ if (!sendopts)
+ return;
- eol[0] = IPOPT_EOL;
- eol[1] = IPOPT_EOL;
- eol[2] = IPOPT_EOL;
- eol[3] = IPOPT_EOL;
+ no_op[0] = IPOPT_EOL;
+ no_op[1] = IPOPT_EOL;
+ no_op[2] = IPOPT_EOL;
+ no_op[3] = IPOPT_EOL;
- setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS, eol, sizeof(eol));
+ setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS, no_op, sizeof(no_op));
/*
* Check if the kernel adds the options length to the packet
* length. Send myself an IGMP packet of type 0 (illegal),
@@ -465,9 +433,6 @@ checkforsolarisbug()
if (*p != getpid())
continue;
-#ifdef RAW_INPUT_IS_RAW
- ip->ip_len = ntohs(ip->ip_len);
-#endif
if (ip->ip_len == IGMP_MINLEN + 4)
ip_addlen = 4;
else if (ip->ip_len == IGMP_MINLEN + 8)
@@ -478,8 +443,8 @@ checkforsolarisbug()
break;
}
}
-}
#endif
+}
/*
* Construct an IGMP message in the output packet buffer. The caller may
@@ -509,9 +474,6 @@ send_igmp(src, dst, type, code, group, datalen)
#ifdef SUNOS5
ip->ip_len += ip_addlen;
#endif
-#ifdef RAW_OUTPUT_IS_RAW
- ip->ip_len = htons(ip->ip_len);
-#endif
igmp = (struct igmp *)(send_buf + MIN_IP_HEADER_LEN);
igmp->igmp_type = type;
@@ -537,10 +499,10 @@ send_igmp(src, dst, type, code, group, datalen)
#ifdef SUNOS5
/*
* SunOS5 < 5.6 cannot properly reset the IP_OPTIONS "socket"
- * option. Instead, set up a string of 4 EOL's.
+ * option. Instead, set up a string of 4 no-op's.
*/
setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS,
- eol, sizeof(eol));
+ no_op, sizeof(no_op));
#else
setsockopt(igmp_socket, IPPROTO_IP, IP_OPTIONS,
NULL, 0);
@@ -799,14 +761,10 @@ host_addr(name)
}
*op = '\0';
- if (dots <= 0)
- e = gethostbyname(name);
- if (e && (e->h_length == sizeof(addr))) {
+ if (dots <= 0) e = gethostbyname(name);
+ if (e && e->h_length == sizeof(addr))
memcpy((char *)&addr, e->h_addr_list[0], e->h_length);
- if (e->h_addr_list[1])
- fprintf(stderr, "Warning: %s has multiple addresses, using %s\n",
- name, inet_fmt(addr, s1));
- } else {
+ else {
addr = inet_addr(buf);
if (addr == -1 || (IN_MULTICAST(addr) && dots)) {
addr = 0;
@@ -838,14 +796,6 @@ proto_type(type)
return ("PIM/Static");
case PROTO_DVMRP_STATIC:
return ("DVMRP/Static");
- case PROTO_PIM_BGP4PLUS:
- return ("PIM/BGP4+");
- case PROTO_CBT_SPECIAL:
- return ("CBT/Special");
- case PROTO_CBT_STATIC:
- return ("CBT/Static");
- case PROTO_PIM_ASSERT:
- return ("PIM/Assert");
case 0:
return ("None");
default:
@@ -904,81 +854,31 @@ flag_type(type)
u_int32
get_netmask(s, dst)
int s;
- u_int32 *dst;
+ u_int32 dst;
{
- unsigned int n;
+ unsigned int i;
+ char ifbuf[5000];
struct ifconf ifc;
- struct ifreq *ifrp, *ifend;
+ struct ifreq *ifr;
u_int32 if_addr, if_mask;
u_int32 retval = 0xFFFFFFFF;
int found = FALSE;
- int num_ifreq = 32;
-
- ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
- ifc.ifc_buf = malloc(ifc.ifc_len);
- while (ifc.ifc_buf) {
- if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
- perror("ioctl SIOCGIFCONF");
- return retval;
- }
- /*
- * If the buffer was large enough to hold all the addresses
- * then break out, otherwise increase the buffer size and
- * try again.
- *
- * The only way to know that we definitely had enough space
- * is to know that there was enough space for at least one
- * more struct ifreq. ???
- */
- if ((num_ifreq * sizeof(struct ifreq)) >=
- ifc.ifc_len + sizeof(struct ifreq))
- break;
-
- num_ifreq *= 2;
- ifc.ifc_len = num_ifreq * sizeof(struct ifreq);
- ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
+ ifc.ifc_buf = ifbuf;
+ ifc.ifc_len = sizeof(ifbuf);
+ if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) {
+ warn("ioctl (SIOCGIFCONF)");
+ return (retval);
}
- if (ifc.ifc_buf == NULL) {
- fprintf(stderr, "getting interface list: ran out of memory");
- exit(1);
- }
-
- ifrp = (struct ifreq *)ifc.ifc_buf;
- ifend = (struct ifreq *)(ifc.ifc_buf + ifc.ifc_len);
- /*
- * Loop through all of the interfaces.
- */
- for (; ifrp < ifend && !found; ifrp = (struct ifreq *)((char *)ifrp + n)) {
-#if BSD >= 199006
- n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
- if (n < sizeof(*ifrp))
- n = sizeof(*ifrp);
-#else
- n = sizeof(*ifrp);
-#endif
- /*
- * Ignore any interface for an address family other than IP.
- */
- if (ifrp->ifr_addr.sa_family != AF_INET)
- continue;
-
- if_addr = ((struct sockaddr_in *)&(ifrp->ifr_addr))->sin_addr.s_addr;
- if (ioctl(s, SIOCGIFFLAGS, (char *)ifrp) < 0) {
- fprintf(stderr, "SIOCGIFFLAGS on ");
- perror(ifrp->ifr_name);
- continue;
- }
- if ((ifrp->ifr_flags & (IFF_MULTICAST|IFF_UP|IFF_LOOPBACK)) !=
- (IFF_MULTICAST|IFF_UP))
- continue;
- if (*dst == 0)
- *dst = if_addr;
- if (ioctl(s, SIOCGIFNETMASK, (char *)ifrp) >= 0) {
- if_mask = ((struct sockaddr_in *)&(ifrp->ifr_addr))->sin_addr.s_addr;
- if (if_mask != 0 && (*dst & if_mask) == (if_addr & if_mask)) {
+ i = ifc.ifc_len / sizeof(struct ifreq);
+ ifr = ifc.ifc_req;
+ for (; i > 0; i--, ifr++) {
+ if_addr = ((struct sockaddr_in *)&(ifr->ifr_addr))->sin_addr.s_addr;
+ if (ioctl(s, SIOCGIFNETMASK, (char *)ifr) >= 0) {
+ if_mask = ((struct sockaddr_in *)&(ifr->ifr_addr))->sin_addr.s_addr;
+ if ((dst & if_mask) == (if_addr & if_mask)) {
retval = if_mask;
- if (lcl_addr == 0) lcl_addr = if_addr; /* XXX what about aliases? */
+ if (lcl_addr == 0) lcl_addr = if_addr;
}
}
if (lcl_addr == if_addr) found = TRUE;
@@ -1032,161 +932,37 @@ t_diff(a, b)
}
/*
- * Swap bytes for poor little-endian machines that don't byte-swap
+ * Fixup for incorrect time format in 3.3 mrouted.
+ * This is possible because (JAN_1970 mod 64K) is quite close to 32K,
+ * so correct and incorrect times will be far apart.
*/
u_long
-byteswap(v)
- u_long v;
+fixtime(time, base)
+ u_long time;
+ struct resp_buf *base;
{
- return ((v << 24) | ((v & 0xff00) << 8) |
- ((v >> 8) & 0xff00) | (v >> 24));
+ if (abs((int)(time-base->qtime)) > 0x3FFFFFFF)
+ time = ((time & 0xFFFF0000) + (JAN_1970 << 16)) +
+ ((time & 0xFFFF) << 14) / 15625;
+ return (time);
}
-#if 0
/*
- * XXX incomplete - need private callback data, too?
- * XXX since dst doesn't get passed through?
+ * Swap bytes for poor little-endian machines that don't byte-swap
*/
-int
-neighbors_callback(tmo, buf, buflen, igmp, igmplen, addr, addrlen, ts)
- int tmo;
- u_char *buf;
- int buflen;
- struct igmp *igmp;
- int igmplen;
- struct sockaddr *addr;
- int *addrlen;
- struct timeval *ts;
-{
- int len;
- u_int32 dst;
- struct ip *ip = (struct ip *)buf;
-
- if (tmo)
- return 0;
-
- if (igmp->igmp_code != DVMRP_NEIGHBORS2)
- return 0;
- len = igmplen;
- /*
- * Accept DVMRP_NEIGHBORS2 response if it comes from the
- * address queried or if that address is one of the local
- * addresses in the response.
- */
- if (ip->ip_src.s_addr != dst) {
- u_int32 *p = (u_int32 *)(igmp + 1);
- u_int32 *ep = p + (len >> 2);
- while (p < ep) {
- u_int32 laddr = *p++;
- int n = ntohl(*p++) & 0xFF;
- if (laddr == dst) {
- ep = p + 1; /* ensure p < ep after loop */
- break;
- }
- p += n;
- }
- if (p >= ep)
- return 0;
- }
- return buflen;
-}
-#endif
-
-int
-mtrace_callback(tmo, buf, buflen, igmp, igmplen, addr, addrlen, ts)
- int tmo;
- u_char *buf;
- int buflen;
- struct igmp *igmp;
- int igmplen;
- struct sockaddr *addr;
- int *addrlen;
- struct timeval *ts;
+u_long
+byteswap(v)
+ u_long v;
{
- static u_char *savbuf = NULL;
- static int savbuflen;
- static struct sockaddr *savaddr;
- static int savaddrlen;
- static struct timeval savts;
-
- int len = (igmplen - QLEN) / RLEN;
- struct tr_resp *r = (struct tr_resp *)((struct tr_query *)(igmp + 1) + 1);
-
- if (tmo == 1) {
- /*
- * If we timed out with a packet saved, then return that packet.
- * send_recv won't send this same packet to the callback again.
- */
- if (savbuf) {
- bcopy(savbuf, buf, savbuflen);
- free(savbuf);
- savbuf = NULL;
- bcopy(savaddr, addr, savaddrlen);
- free(savaddr);
- *addrlen = savaddrlen;
- bcopy(&savts, ts, sizeof(savts));
- return savbuflen;
- }
- return 0;
- }
- if (savbuf) {
- free(savbuf);
- savbuf = NULL;
- free(savaddr);
- }
- /*
- * Check for IOS bug described in CSCdi68628, where a router that does
- * not have multicast enabled responds to an mtrace request with a 1-hop
- * error packet.
- * Heuristic is:
- * If there is only one hop reported in the packet,
- * And the protocol code is 0,
- * And there is no previous hop,
- * And the forwarding information is "Not Forwarding",
- * And the router is not on the same subnet as the destination of the
- * trace,
- * then drop this packet. The "#if 0"'d code saves it and returns
- * it on timeout, but timeouts are too common (e.g. routers with
- * limited unicast routing tables, etc).
- */
- if (len == 1 && r->tr_rproto == 0 && r->tr_rmtaddr == 0 &&
- r->tr_rflags == TR_NO_FWD) {
- u_int32 smask;
-
- VAL_TO_MASK(smask, r->tr_smask);
- if ((r->tr_outaddr & smask) != (qdst & smask)) {
-#if 0
- /* XXX should do this silently? */
- fprintf(stderr, "mtrace: probably IOS-buggy packet from %s\n",
- inet_fmt(((struct sockaddr_in *)addr)->sin_addr.s_addr, s1));
- /* Save the packet to return if a timeout occurs. */
- savbuf = (u_char *)malloc(buflen);
- if (savbuf != NULL) {
- bcopy(buf, savbuf, buflen);
- savbuflen = buflen;
- savaddr = (struct sockaddr *)malloc(*addrlen);
- if (savaddr != NULL) {
- bcopy(addr, savaddr, *addrlen);
- savaddrlen = *addrlen;
- bcopy(ts, &savts, sizeof(savts));
- } else {
- free(savbuf);
- savbuf = NULL;
- }
- }
-#endif
- return 0;
- }
- }
- return buflen;
+ return ((v << 24) | ((v & 0xff00) << 8) |
+ ((v >> 8) & 0xff00) | (v >> 24));
}
int
-send_recv(dst, type, code, tries, save, callback)
+send_recv(dst, type, code, tries, save)
u_int32 dst;
int type, code, tries;
struct resp_buf *save;
- callback_t callback;
{
fd_set fds;
struct timeval tq, tr, tv;
@@ -1224,31 +1000,28 @@ send_recv(dst, type, code, tries, save, callback)
*/
query = (struct tr_query *)(send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN);
query->tr_raddr = raddr ? raddr : unicast ? lcl_addr : resp_cast;
- TR_SETTTL(query->tr_rttlqid, rttl ? rttl :
- IN_MULTICAST(ntohl(query->tr_raddr)) ? get_ttl(save) : UNICAST_TTL);
+ query->tr_rttl = rttl ? rttl :
+ IN_MULTICAST(ntohl(query->tr_raddr)) ? get_ttl(save) : UNICAST_TTL;
query->tr_src = qsrc;
query->tr_dst = qdst;
for (i = tries ; i > 0; --i) {
- int oqid;
-
if (tries == nqueries && raddr == 0) {
if (i == (nqueries >> 1)) {
if (multicast && unicast) {
query->tr_raddr = resp_cast;
if (!rttl)
- TR_SETTTL(query->tr_rttlqid, get_ttl(save));
+ query->tr_rttl = get_ttl(save);
} else if (!multicast) {
query->tr_raddr = lcl_addr;
- TR_SETTTL(query->tr_rttlqid, UNICAST_TTL);
+ query->tr_rttl = UNICAST_TTL;
}
}
if (i < tries && IN_MULTICAST(ntohl(query->tr_raddr)) &&
rttl == 0) {
- TR_SETTTL(query->tr_rttlqid,
- TR_GETTTL(query->tr_rttlqid) + MULTICAST_TTL_INC);
- if (TR_GETTTL(query->tr_rttlqid) > MULTICAST_TTL_MAX)
- TR_SETTTL(query->tr_rttlqid, MULTICAST_TTL_MAX);
+ query->tr_rttl += MULTICAST_TTL_INC;
+ if (query->tr_rttl > MULTICAST_TTL_MAX)
+ query->tr_rttl = MULTICAST_TTL_MAX;
}
}
@@ -1256,14 +1029,10 @@ send_recv(dst, type, code, tries, save, callback)
* Change the qid for each request sent to avoid being confused
* by duplicate responses
*/
- oqid = TR_GETQID(query->tr_rttlqid);
- if (staticqid)
- TR_SETQID(query->tr_rttlqid, staticqid);
- else
#ifdef SYSV
- TR_SETQID(query->tr_rttlqid, ((u_int32)lrand48() >> 8));
+ query->tr_qid = ((u_int32)lrand48() >> 8);
#else
- TR_SETQID(query->tr_rttlqid, ((u_int32)random() >> 8));
+ query->tr_qid = ((u_int32)random() >> 8);
#endif
/*
@@ -1291,23 +1060,15 @@ send_recv(dst, type, code, tries, save, callback)
if (errno != EINTR) warn("select");
continue;
} else if (count == 0) {
- /*
- * Timed out. Notify the callback.
- */
- if (!callback || (recvlen = (callback)(1, recv_buf, 0, NULL, 0, (struct sockaddr *)&recvaddr, &socklen, &tr)) == 0) {
- printf("* ");
- fflush(stdout);
- break;
- }
- } else {
- /*
- * Data is available on the socket, so read it.
- */
- gettimeofday(&tr, 0);
- recvlen = recvfrom(igmp_socket, recv_buf, RECV_BUF_SIZE,
- 0, (struct sockaddr *)&recvaddr, &socklen);
+ printf("* ");
+ fflush(stdout);
+ break;
}
+ gettimeofday(&tr, 0);
+ recvlen = recvfrom(igmp_socket, recv_buf, RECV_BUF_SIZE,
+ 0, (struct sockaddr *)&recvaddr, &socklen);
+
if (recvlen <= 0) {
if (recvlen && errno != EINTR) warn("recvfrom");
continue;
@@ -1322,11 +1083,7 @@ send_recv(dst, type, code, tries, save, callback)
continue;
iphdrlen = ip->ip_hl << 2;
-#ifdef RAW_INPUT_IS_RAW
- ipdatalen = ntohs(ip->ip_len);
-#else
ipdatalen = ip->ip_len;
-#endif
if (iphdrlen + ipdatalen != recvlen) {
warnx("packet shorter (%u bytes) than hdr+data len (%u+%u)",
recvlen, iphdrlen, ipdatalen);
@@ -1383,14 +1140,9 @@ send_recv(dst, type, code, tries, save, callback)
* Ignore responses that don't match query.
*/
rquery = (struct tr_query *)(igmp + 1);
- if (rquery->tr_src != qsrc || rquery->tr_dst != qdst)
- continue;
- if (TR_GETQID(rquery->tr_rttlqid) !=
- TR_GETQID(query->tr_rttlqid)) {
- if (verbose && TR_GETQID(rquery->tr_rttlqid) == oqid)
- printf("[D]");
- continue;
- }
+ if (rquery->tr_qid != query->tr_qid) continue;
+ if (rquery->tr_src != qsrc) continue;
+ if (rquery->tr_dst != qdst) continue;
len = (igmpdatalen - QLEN)/RLEN;
r = (struct tr_resp *)(rquery+1) + len - 1;
@@ -1424,8 +1176,7 @@ send_recv(dst, type, code, tries, save, callback)
len, code);
}
rquery->tr_raddr = query->tr_raddr; /* Insure these are */
- TR_SETTTL(rquery->tr_rttlqid, TR_GETTTL(query->tr_rttlqid));
- /* as we sent them */
+ rquery->tr_rttl = query->tr_rttl; /* as we sent them */
break;
default:
@@ -1433,21 +1184,6 @@ send_recv(dst, type, code, tries, save, callback)
}
/*
- * We're pretty sure we want to use this packet now,
- * but if the caller gave a callback function, it might
- * want to handle it instead. Give the callback a chance,
- * unless the select timed out (in which case the only way
- * to get here is because the callback returned a packet).
- */
- if (callback && (count != 0) && ((callback)(0, recv_buf, recvlen, igmp, igmpdatalen, (struct sockaddr*)&recvaddr, &socklen, &tr)) == 0) {
- /*
- * The callback function didn't like this packet.
- * Go try receiving another one.
- */
- continue;
- }
-
- /*
* Most of the sanity checking done at this point.
* Return this packet we have been waiting for.
*/
@@ -1488,14 +1224,13 @@ passive_mode()
int socklen;
int ipdatalen, iphdrlen, igmpdatalen;
int len, recvlen;
- int qid;
u_int32 smask;
struct mtrace *remembered = NULL, *m, *n, **nn;
int pc = 0;
if (raddr) {
- if (IN_MULTICAST(ntohl(raddr))) k_join(raddr, lcl_addr);
- } else k_join(htonl(0xE0000120), lcl_addr);
+ if (IN_MULTICAST(ntohl(raddr))) k_join(raddr, INADDR_ANY);
+ } else k_join(htonl(0xE0000120), INADDR_ANY);
while (1) {
fflush(stdout); /* make sure previous trace is flushed */
@@ -1519,11 +1254,7 @@ passive_mode()
continue;
iphdrlen = ip->ip_hl << 2;
-#ifdef RAW_INPUT_IS_RAW
- ipdatalen = ntohs(ip->ip_len);
-#else
ipdatalen = ip->ip_len;
-#endif
if (iphdrlen + ipdatalen != recvlen) {
warnx("packet shorter (%u bytes) than hdr+data len (%u+%u)",
recvlen, iphdrlen, ipdatalen);
@@ -1577,10 +1308,8 @@ passive_mode()
for (nn = &remembered, n = *nn, m = 0; n; n = *nn) {
if ((n->base.qhdr.tr_src == base.qhdr.tr_src) &&
(n->base.qhdr.tr_dst == base.qhdr.tr_dst) &&
- (n->base.igmp.igmp_group.s_addr == igmp->igmp_group.s_addr)) {
+ (n->base.igmp.igmp_group.s_addr == igmp->igmp_group.s_addr))
m = n;
- m->last = tr;
- }
if (tr.tv_sec - n->last.tv_sec > 500) { /* XXX don't hardcode */
*nn = n->next;
free(n);
@@ -1589,6 +1318,9 @@ passive_mode()
}
}
+ if (m)
+ bcopy(&tr, &m->last, sizeof(tr));
+
tr_sec = tr.tv_sec;
now = localtime(&tr_sec);
strftime(timebuf, sizeof(timebuf) - 1, "%b %e %k:%M:%S", now);
@@ -1602,8 +1334,8 @@ passive_mode()
if (!IN_MULTICAST(base.qhdr.tr_raddr))
printf(", resp to %s", (len == 0 && recvaddr.sin_addr.s_addr == base.qhdr.tr_raddr) ? "same" : inet_fmt(base.qhdr.tr_raddr, s1));
else
- printf(", respttl %d", TR_GETTTL(base.qhdr.tr_rttlqid));
- printf(", qid %06x\n", qid = TR_GETQID(base.qhdr.tr_rttlqid));
+ printf(", respttl %d", base.qhdr.tr_rttl);
+ printf(", qid %06x\n", base.qhdr.tr_qid);
printf("packet from %s to %s\n",
inet_fmt(ip->ip_src.s_addr, s1),
inet_fmt(ip->ip_dst.s_addr, s2));
@@ -1632,15 +1364,11 @@ passive_mode()
!(pc = path_changed(&m->base, &base))) {
/*
* Some mtrace responders send multiple copies of the same
- * reply. Skip this packet if it's got the same query-id
- * as the last one.
+ * reply. Skip this packet if it's exactly the same as the
+ * last one.
*/
- if (m->lastqid == qid) {
- printf("Skipping duplicate reply\n");
+ if (bcmp((char *)&base.igmp, (char *)&m->prev->igmp, ipdatalen) == 0)
continue;
- }
-
- m->lastqid = qid;
++m->nresp;
@@ -1649,7 +1377,7 @@ passive_mode()
printf("Results after %d seconds:\n\n",
(int)((m->new->qtime - m->base.qtime) >> 16));
fixup_stats(&m->base, m->prev, m->new, m->bugs);
- print_stats(&m->base, m->prev, m->new, m->bugs, m->names);
+ print_stats(&m->base, m->prev, m->new, m->bugs);
m->prev = m->new;
m->new = &m->incr[(m->nresp & 1)];
@@ -1658,11 +1386,6 @@ passive_mode()
if (m == NULL) {
m = (struct mtrace *)malloc(sizeof(struct mtrace));
- if (m == NULL) {
- fprintf(stderr, "Out of memory!\n");
- continue;
- }
- bzero(m, sizeof(struct mtrace));
m->next = remembered;
remembered = m;
bcopy(&tr, &m->last, sizeof(tr));
@@ -1681,7 +1404,7 @@ passive_mode()
printf(" 0 ");
print_host(base.qhdr.tr_dst);
printf("\n");
- print_trace(1, &base, m->names);
+ print_trace(1, &base);
VAL_TO_MASK(smask, r->tr_smask);
if ((r->tr_inaddr & smask) == (base.qhdr.tr_src & smask)) {
printf("%3d ", -(base.len+1));
@@ -1732,10 +1455,9 @@ print_host2(addr1, addr2)
* Print responses as received (reverse path from dst to src)
*/
void
-print_trace(idx, buf, names)
- int idx;
+print_trace(index, buf)
+ int index;
struct resp_buf *buf;
- char **names;
{
struct tr_resp *r;
char *name;
@@ -1743,16 +1465,16 @@ print_trace(idx, buf, names)
int hop;
char *ms;
- i = abs(idx);
+ i = abs(index);
r = buf->resps + i - 1;
for (; i <= buf->len; ++i, ++r) {
- if (idx > 0) printf("%3d ", -i);
+ if (index > 0) printf("%3d ", -i);
name = print_host2(r->tr_outaddr, r->tr_inaddr);
if (r->tr_rflags != TR_NO_RTE)
printf(" %s thresh^ %d", proto_type(r->tr_rproto), r->tr_fttl);
if (verbose) {
- hop = t_diff(ntohl(r->tr_qarr), buf->qtime);
+ hop = t_diff(fixtime(ntohl(r->tr_qarr), &base), buf->qtime);
ms = scale(&hop);
printf(" %d%s", hop, ms);
}
@@ -1773,10 +1495,8 @@ print_trace(idx, buf, names)
}
}
printf("\n");
- if (names[i-1])
- free(names[i-1]);
- names[i-1]=malloc(strlen(name) + 1);
- strcpy(names[i-1], name);
+ memcpy(names[i-1], name, sizeof(names[0]) - 1);
+ names[i-1][sizeof(names[0])-1] = '\0';
}
}
@@ -1794,7 +1514,7 @@ what_kind(buf, why)
struct tr_resp *r = buf->resps + hops - 1;
u_int32 next = r->tr_rmtaddr;
- retval = send_recv(next, IGMP_DVMRP, DVMRP_ASK_NEIGHBORS2, 1, &incr[0], NULL);
+ retval = send_recv(next, IGMP_DVMRP, DVMRP_ASK_NEIGHBORS2, 1, &incr[0]);
print_host(next);
if (retval) {
u_int32 version = ntohl(incr[0].igmp.igmp_group.s_addr);
@@ -1861,7 +1581,9 @@ stat_line(r, s, have_next, rst)
int have_next;
int *rst;
{
- int timediff = (ntohl(s->tr_qarr) - ntohl(r->tr_qarr)) >> 16;
+ /* this may fail in passive statistics mode due to wrong "base". */
+ int timediff = (fixtime(ntohl(s->tr_qarr), &base) -
+ fixtime(ntohl(r->tr_qarr), &base)) >> 16;
int v_lost, v_pct;
int g_lost, g_pct;
int v_out = ntohl(s->tr_vifout) - ntohl(r->tr_vifout);
@@ -1872,21 +1594,14 @@ stat_line(r, s, have_next, rst)
int ghave = NEITHER;
int gmissing = NEITHER;
char whochar;
- int badtime = 0;
- if (timediff == 0) {
- badtime = 1;
- /* Might be 32 bits of int seconds instead of 16int+16frac */
- timediff = ntohl(s->tr_qarr) - ntohl(r->tr_qarr);
- if (timediff == 0 || abs(timediff - statint) > statint)
- timediff = 1;
- }
+ if (timediff == 0) timediff = 1;
v_pps = v_out / timediff;
g_pps = g_out / timediff;
-#define STATS_MISSING(x) ((x) == 0xFFFFFFFF)
+#define STATS_MISSING(x) ((x) == 0xFFFFFFFF || (x) == 0)
- if (!STATS_MISSING(s->tr_vifout) && !STATS_MISSING(r->tr_vifout))
+ if (v_out && !STATS_MISSING(s->tr_vifout) && !STATS_MISSING(r->tr_vifout))
vhave |= OUTS;
if (STATS_MISSING(s->tr_pktcnt) || STATS_MISSING(r->tr_pktcnt))
gmissing |= OUTS;
@@ -1904,19 +1619,6 @@ stat_line(r, s, have_next, rst)
}
/*
- * Stats can be missing for any number of reasons:
- * - The hop may not be capable of collecting stats
- * - Traffic may be getting dropped at the previous hop
- * and so this hop may not have any state
- *
- * We need a stronger heuristic to tell between these
- * two cases; in case 1 we don't want to print the stats
- * and in case 2 we want to print 100% loss. We used to
- * err on the side of not printing, which is less useful
- * than printing 100% loss and dealing with it.
- */
-#if 0
- /*
* If both hops report as missing, then it's likely that there's just
* no traffic flowing.
*
@@ -1924,30 +1626,22 @@ stat_line(r, s, have_next, rst)
*/
if (gmissing != BOTH)
ghave &= ~gmissing;
-#endif
whochar = have_next ? '^' : ' ';
switch (vhave) {
case BOTH:
v_lost = v_out - (ntohl(s->tr_vifin) - ntohl(r->tr_vifin));
- if (v_out) v_pct = v_lost * 100 / v_out;
+ if (v_out) v_pct = (v_lost * 100 + (v_out >> 1)) / v_out;
else v_pct = 0;
- if (-20 < v_pct && v_pct < 101 && v_out > 10)
- sprintf(v_str, "%3d%%", v_pct);
- else if (v_pct < -900 && v_out > 10)
- sprintf(v_str, "%3dx", (int)(-v_pct / 100. + 1.));
- else if (v_pct <= -20 && v_out > 10)
- sprintf(v_str, "%1.1fx", -v_pct / 100. + 1.);
- else
- memcpy(v_str, " -- ", 5);
+ if (-100 < v_pct && v_pct < 101 && v_out > 10)
+ sprintf(v_str, "%3d", v_pct);
+ else memcpy(v_str, " --", 4);
if (tunstats)
- printf("%6d/%-5d=%s", v_lost, v_out, v_str);
+ printf("%6d/%-5d=%s%%", v_lost, v_out, v_str);
else
printf(" ");
printf("%4d pps", v_pps);
- if (v_pps && badtime)
- printf("?");
break;
@@ -1963,17 +1657,15 @@ stat_line(r, s, have_next, rst)
else
printf(" %c", whochar);
printf("%4d pps", v_pps);
- if (v_pps && badtime)
- printf("?");
break;
case NEITHER:
if (ghave != NEITHER)
if (tunstats)
- printf(" ");
+ printf(" ");
else
- printf(" ");
+ printf(" ");
break;
}
@@ -1982,22 +1674,14 @@ stat_line(r, s, have_next, rst)
switch (ghave) {
case BOTH:
g_lost = g_out - (ntohl(s->tr_pktcnt) - ntohl(r->tr_pktcnt));
- if (g_out) g_pct = g_lost * 100 / g_out;
+ if (g_out) g_pct = (g_lost * 100 + (g_out >> 1))/ g_out;
else g_pct = 0;
- if (-20 < g_pct && g_pct < 101 && g_out > 10)
- sprintf(g_str, "%3d%%", g_pct);
- else if (g_pct < -900 && g_out > 10)
- sprintf(g_str, "%3dx", (int)(-g_pct / 100. + 1.));
- else if (g_pct <= -20 && g_out > 10)
- sprintf(g_str, "%1.1fx", -g_pct / 100. + 1.);
- else
- memcpy(g_str, " -- ", 5);
+ if (-100 < g_pct && g_pct < 101 && g_out > 10)
+ sprintf(g_str, "%3d", g_pct);
+ else memcpy(g_str, " --", 4);
- printf("%s%6d/%-5d=%s%4d pps",
+ printf("%s%6d/%-5d=%s%%%4d pps\n",
tunstats ? "" : " ", g_lost, g_out, g_str, g_pps);
- if (g_pps && badtime)
- printf("?");
- printf("\n");
break;
#if 0
@@ -2009,11 +1693,8 @@ stat_line(r, s, have_next, rst)
#endif
case OUTS:
- printf("%s ?/%-5d %4d pps",
+ printf("%s ?/%-5d %4d pps\n",
tunstats ? "" : " ", g_out, g_pps);
- if (badtime)
- printf("?");
- printf("\n");
break;
case INS:
@@ -2036,18 +1717,12 @@ stat_line(r, s, have_next, rst)
(long)(ntohl(s->tr_vifout) - ntohl(r->tr_vifout)));
printf("pkts: %ld ", (long)(ntohl(s->tr_pktcnt) - ntohl(r->tr_pktcnt)));
printf("time: %d\n", timediff);
- printf("\t\t\t\treset: %x hoptime: %lx\n", *rst, ntohl(s->tr_qarr));
}
}
/*
* A fixup to check if any pktcnt has been reset, and to fix the
* byteorder bugs in mrouted 3.6 on little-endian machines.
- *
- * XXX Since periodic traffic sources are likely to have their
- * pktcnt periodically reset, should we save old values when
- * the reset occurs to keep slightly better statistics over
- * the long term? (e.g. SAP)
*/
void
fixup_stats(base, prev, new, bugs)
@@ -2060,25 +1735,12 @@ fixup_stats(base, prev, new, bugs)
struct tr_resp *n = new->resps + rno;
int *r = bugs + rno;
int res;
- int cleanup = 0;
- /* Check for byte-swappers. Only check on the first trace,
- * since long-running traces can wrap around and falsely trigger. */
+ /* Check for byte-swappers */
while (--rno >= 0) {
-#ifdef TEST_ONLY
- u_int32 nvifout = ntohl(n->tr_vifout);
- u_int32 pvifout = ntohl(p->tr_vifout);
-#endif
--n; --p; --b;
-#ifdef TEST_ONLY /*XXX this is still buggy, so disable it for release */
if ((*r & BUG_SWAP) ||
- ((base == prev) &&
- (nvifout - pvifout) > (byteswap(nvifout) - byteswap(pvifout)))) {
- if (1 || debug > 2) {
- printf("ip %s swaps; b %08x p %08x n %08x\n",
- inet_fmt(n->tr_inaddr, s1),
- ntohl(b->tr_vifout), pvifout, nvifout);
- }
+ abs(ntohl(n->tr_vifout) - ntohl(p->tr_vifout)) > 100000) {
/* This host sends byteswapped reports; swap 'em */
if (!(*r & BUG_SWAP)) {
*r |= BUG_SWAP;
@@ -2093,7 +1755,6 @@ fixup_stats(base, prev, new, bugs)
n->tr_vifout = byteswap(n->tr_vifout);
n->tr_pktcnt = byteswap(n->tr_pktcnt);
}
-#endif
/*
* A missing parenthesis in mrouted 3.5-3.8's prune.c
* causes extremely bogus time diff's.
@@ -2124,32 +1785,10 @@ fixup_stats(base, prev, new, bugs)
while (--rno >= 0) {
--n; --p; --b; --r;
- /*
- * This hop has reset if:
- * - There were statistics in the base AND previous pass, AND
- * - There are less packets this time than the first time and
- * we didn't reset last time, OR
- * - There are less packets this time than last time, OR
- * - There are no statistics on this pass.
- *
- * The "and we didn't reset last time" is necessary in the
- * first branch of the OR because if the base is large and
- * we reset last time but the constant-resetter-avoidance
- * code kicked in so we delayed the copy of prev to base,
- * new could still be below base so we trigger the
- * constant-resetter code even though it was really only
- * a single reset.
- */
- res = ((b->tr_pktcnt != 0xFFFFFFFF) && (p->tr_pktcnt != 0xFFFFFFFF) &&
- ((!(*r & BUG_RESET) && ntohl(n->tr_pktcnt) < ntohl(b->tr_pktcnt)) ||
- (ntohl(n->tr_pktcnt) < ntohl(p->tr_pktcnt)) ||
- (n->tr_pktcnt == 0xFFFFFFFF)));
- if (debug > 2) {
- printf("\t\tip=%s, r=%d, res=%d\n", inet_fmt(b->tr_inaddr, s1), *r, res);
- if (res)
- printf("\t\tbase=%ld, prev=%ld, new=%ld\n", ntohl(b->tr_pktcnt),
- ntohl(p->tr_pktcnt), ntohl(n->tr_pktcnt));
- }
+ res = ((ntohl(n->tr_pktcnt) < ntohl(b->tr_pktcnt)) ||
+ (ntohl(n->tr_pktcnt) < ntohl(p->tr_pktcnt)));
+ if (debug > 2)
+ printf("\t\tr=%d, res=%d\n", *r, res);
if (*r & BUG_RESET) {
if (res || (*r & BUG_RESET2X)) {
/*
@@ -2169,68 +1808,29 @@ fixup_stats(base, prev, new, bugs)
* traffic was still active.
*/
*r &= ~BUG_RESET;
- cleanup = 1;
+ break;
}
} else
if (res)
*r |= BUG_RESET;
}
- if (cleanup == 0) return;
+ if (rno < 0) return;
- /*
- * If some hop reset its counters and didn't continue to
- * reset, then we pretend that the previous
- * trace was the first one.
- */
rno = base->len;
b = base->resps + rno;
p = prev->resps + rno;
while (--rno >= 0) (--b)->tr_pktcnt = (--p)->tr_pktcnt;
- base->qtime = prev->qtime;
- base->rtime = prev->rtime;
-}
-
-/*
- * Check per-source losses along path and compare with threshold.
- */
-int
-check_thresh(thresh, base, prev, new)
- int thresh;
- struct resp_buf *base, *prev, *new;
-{
- int rno = base->len - 1;
- struct tr_resp *b = base->resps + rno;
- struct tr_resp *p = prev->resps + rno;
- struct tr_resp *n = new->resps + rno;
- int g_out, g_lost;
-
- while (TRUE) {
- if ((n->tr_inaddr != b->tr_inaddr) ||
- (n->tr_outaddr != b->tr_outaddr) ||
- (n->tr_rmtaddr != b->tr_rmtaddr))
- return 1; /* Route changed */
-
- if (rno-- < 1) break;
- g_out = ntohl(n->tr_pktcnt) - ntohl(p->tr_pktcnt);
- b--; n--; p--;
- g_lost = g_out - (ntohl(n->tr_pktcnt) - ntohl(p->tr_pktcnt));
- if (g_out && ((g_lost * 100 + (g_out >> 1))/ g_out) > thresh) {
- return TRUE;
- }
- }
- return FALSE;
}
/*
* Print responses with statistics for forward path (from src to dst)
*/
int
-print_stats(base, prev, new, bugs, names)
+print_stats(base, prev, new, bugs)
struct resp_buf *base, *prev, *new;
int *bugs;
- char **names;
{
int rtt, hop;
char *ms;
@@ -2241,8 +1841,8 @@ print_stats(base, prev, new, bugs, names)
struct tr_resp *n = new->resps + rno;
int *r = bugs + rno;
u_long resptime = new->rtime;
- u_long qarrtime = ntohl(n->tr_qarr);
- u_int ttl = MaX(1, n->tr_fttl) + 1;
+ u_long qarrtime = fixtime(ntohl(n->tr_qarr), base);
+ u_int ttl = n->tr_fttl + 1;
int first = (base == prev);
VAL_TO_MASK(smask, b->tr_smask);
@@ -2278,12 +1878,6 @@ print_stats(base, prev, new, bugs, names)
else
printf("------- ---------------------\n");
}
- if ((b->tr_inaddr & smask) != (base->qhdr.tr_src & smask) &&
- b->tr_rmtaddr != 0) {
- printf("%-15s %-14s is the previous hop\n", inet_fmt(b->tr_rmtaddr, s1),
- inet_name(b->tr_rmtaddr));
- printf(" v ^\n");
- }
if (debug > 2) {
printf("\t\t\t\tv_in: %ld ", (long)ntohl(n->tr_vifin));
printf("v_out: %ld ", (long)ntohl(n->tr_vifout));
@@ -2297,7 +1891,7 @@ print_stats(base, prev, new, bugs, names)
(long)(ntohl(n->tr_vifout) - ntohl(b->tr_vifout)));
printf("pkts: %ld\n",
(long)(ntohl(n->tr_pktcnt) - ntohl(b->tr_pktcnt)));
- printf("\t\t\t\treset: %x hoptime: %lx\n", *r, (long)ntohl(n->tr_qarr));
+ printf("\t\t\t\treset: %x\n", *r);
}
while (TRUE) {
@@ -2319,7 +1913,7 @@ print_stats(base, prev, new, bugs, names)
stat_line(p, n, TRUE, r);
if (!first || verbose) {
resptime = qarrtime;
- qarrtime = ntohl((n-1)->tr_qarr);
+ qarrtime = fixtime(ntohl((n-1)->tr_qarr), base);
hop = t_diff(resptime, qarrtime);
ms = scale(&hop);
printf(" v | hop%5d%s", hop, ms);
@@ -2330,7 +1924,7 @@ print_stats(base, prev, new, bugs, names)
}
--b, --p, --n, --r;
- ttl = MaX(ttl, MaX(1, n->tr_fttl) + base->len - rno);
+ ttl = MaX(ttl, n->tr_fttl + base->len - rno);
}
printf(" %c \\__ ttl%5d ", (first && !verbose) ? 'v' : '|',
@@ -2345,8 +1939,9 @@ print_stats(base, prev, new, bugs, names)
else
stat_line(b, n, FALSE, r);
}
+ /* lcl_addr is 0 in passive mode, where we don't know the query source. */
printf("%-15s %s\n", inet_fmt(base->qhdr.tr_dst, s1),
- !passive ? inet_fmt(lcl_addr, s2) : " * * * ");
+ lcl_addr ? inet_fmt(lcl_addr, s2) : " * * * ");
printf(" Receiver Query Source\n\n");
return 0;
}
@@ -2401,19 +1996,10 @@ char *argv[];
int waittime;
int seed;
int hopbyhop;
- int i;
- int printed = 1;
if (geteuid() != 0)
errx(1, "must be root");
- /*
- * We might get spawned by vat with the audio device open.
- * Close everything but stdin, stdout, stderr.
- */
- for (i = 3; i < 255; i++)
- close(i);
-
init_igmp();
setuid(getuid());
@@ -2446,17 +2032,6 @@ char *argv[];
case 'U': /* Use unicast for response */
unicast = TRUE;
break;
- case 'L': /* Trace w/ loss threshold */
- if (arg && isdigit(*arg)) {
- lossthresh = atoi(arg);
- if (lossthresh < 0)
- lossthresh = 0;
- numstats = 3153600;
- if (arg == argv[0]) argv++, argc--;
- break;
- } else
- usage();
- break;
case 'O': /* Don't use IP options */
sendopts = FALSE;
break;
@@ -2464,16 +2039,6 @@ char *argv[];
printstats = FALSE;
numstats = 3153600;
break;
- case 'Q': /* (undoc.) always use this QID */
- if (arg && isdigit(*arg)) {
- staticqid = atoi(arg);
- if (staticqid < 0)
- staticqid = 0;
- if (arg == argv[0]) argv++, argc--;
- break;
- } else
- usage();
- break;
case 'T': /* Print confusing tunnel stats */
tunstats = TRUE;
break;
@@ -2481,27 +2046,20 @@ char *argv[];
weak = TRUE;
break;
case 'V': /* Print version and exit */
- /*
- * FreeBSD wants to have its own Id string, so
- * determination of the version number has to change.
- * XXX Note that this must be changed by hand on importing
- * XXX new versions!
- */
{
- char *r = strdup(rcsid);
- char *s = strchr(r, ',');
+ char *p = strchr(rcsid, ',');
- while (s && *(s+1) != 'v')
- s = strchr(s + 1, ',');
+ while (p && *(p+1) != 'v')
+ p = strchr(p + 1, ',');
- if (s) {
+ if (p) {
char *q;
- s += 3; /* , v sp */
- q = strchr(s, ' ');
+ p += 3; /* , v sp */
+ q = strchr(p, ' ');
if (q)
*q = '\0';
- fprintf(stderr, "mtrace version 5.2/%s\n", s);
+ fprintf(stderr, "mtrace version %s\n", p);
} else {
fprintf(stderr, "mtrace could not determine version number!?\n");
}
@@ -2531,16 +2089,6 @@ char *argv[];
break;
} else
usage();
- case 'f': /* first hop */
- if (arg && isdigit(*arg)) {
- qno = atoi(arg);
- if (qno > MAXHOPS) qno = MAXHOPS;
- else if (qno < 1) qno = 0;
- if (arg == argv[0]) argv++, argc--;
- fflag++;
- break;
- } else
- usage();
case 'm': /* Max number of hops to trace */
if (arg && isdigit(*arg)) {
qno = atoi(arg);
@@ -2642,16 +2190,11 @@ char *argv[];
usage();
}
-#ifdef SUNOS5
- if (sendopts)
- checkforsolarisbug();
-#endif
-
/*
* Set useful defaults for as many parameters as possible.
*/
- defgrp = 0; /* Default to no group */
+ defgrp = htonl(0xE0020001); /* MBone Audio (224.2.0.1) */
query_cast = htonl(0xE0000002); /* All routers multicast addr */
resp_cast = htonl(0xE0000120); /* Mtrace response multicast addr */
if (qgrp == 0) {
@@ -2679,13 +2222,6 @@ char *argv[];
addr.sin_addr.s_addr = qgrp ? qgrp : query_cast;
addr.sin_port = htons(2000); /* Any port above 1024 will do */
- /*
- * Note that getsockname() can return 0 on some systems
- * (notably SunOS 5.x, x < 6). This is taken care of in
- * get_netmask(). If the default multicast interface (set
- * with the route for 224.0.0.0) is not the same as the
- * hostname, mtrace -i [if_addr] will have to be used.
- */
if (((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0) ||
(connect(udp, (struct sockaddr *) &addr, sizeof(addr)) < 0) ||
getsockname(udp, (struct sockaddr *) &addr, &addrlen) < 0)
@@ -2724,7 +2260,7 @@ char *argv[];
*/
if (qdst == 0) {
qdst = lcl_addr ? lcl_addr : addr.sin_addr.s_addr;
- dst_netmask = get_netmask(udp, &qdst);
+ dst_netmask = get_netmask(udp, qdst);
if (gwy && (gwy & dst_netmask) != (qdst & dst_netmask) &&
!IN_MULTICAST(ntohl(gwy)))
qdst = gwy;
@@ -2733,8 +2269,7 @@ char *argv[];
qsrc = lcl_addr ? lcl_addr : addr.sin_addr.s_addr;
if (qsrc == 0)
usage();
- if (!dst_netmask)
- dst_netmask = get_netmask(udp, &qdst);
+ dst_netmask = get_netmask(udp, qdst);
close(udp);
if (lcl_addr == 0) lcl_addr = addr.sin_addr.s_addr;
@@ -2755,7 +2290,7 @@ char *argv[];
* older implementations.
*/
if (gwy && !IN_MULTICAST(ntohl(gwy)))
- if (send_recv(gwy, IGMP_DVMRP, DVMRP_ASK_NEIGHBORS2, 1, &incr[0], NULL)) {
+ if (send_recv(gwy, IGMP_DVMRP, DVMRP_ASK_NEIGHBORS2, 1, &incr[0])) {
int flags = ntohl(incr[0].igmp.igmp_group.s_addr);
int version = flags & 0xFFFF;
int info = (flags & 0xFF0000) >> 16;
@@ -2775,8 +2310,10 @@ char *argv[];
printf("Mtrace from %s to %s via group %s\n",
inet_fmt(qsrc, s1), inet_fmt(qdst, s2), inet_fmt(qgrp, s3));
- if ((qdst & dst_netmask) == (qsrc & dst_netmask))
- fprintf(stderr, "mtrace: Source & receiver appear to be directly connected\n");
+ if ((qdst & dst_netmask) == (qsrc & dst_netmask)) {
+ printf("Source & receiver are directly connected, no path to trace\n");
+ exit(0);
+ }
/*
* If the response is to be a multicast address, make sure we
@@ -2799,8 +2336,8 @@ char *argv[];
if ((qdst & dst_netmask) == (lcl_addr & dst_netmask)) tdst = query_cast;
else tdst = qgrp;
else tdst = gwy;
- if (tdst == 0 && qgrp == 0)
- errx(1, "mtrace: weak mtrace requires -g if destination is not local.\n");
+ if (tdst == 0 && weak)
+ errx(1, "-W requires -g if destination is not local");
if (IN_MULTICAST(ntohl(tdst))) {
k_set_loop(1); /* If I am running on a router, I need to hear this */
@@ -2819,17 +2356,13 @@ char *argv[];
} else {
hops = qno;
tries = nqueries;
- if (fflag)
- printf("Querying full reverse path, starting at hop %d...", qno);
- else
- printf("Querying reverse path, maximum %d hops... ", qno);
+ printf("Querying reverse path, maximum %d hops... ", qno);
fflush(stdout);
}
base.rtime = 0;
base.len = 0;
- hopbyhop = FALSE;
- recvlen = send_recv(tdst, IGMP_MTRACE, hops, tries, &base, mtrace_callback);
+ recvlen = send_recv(tdst, IGMP_MTRACE, hops, tries, &base);
/*
* If the initial query was successful, print it. Otherwise, if
@@ -2839,22 +2372,19 @@ char *argv[];
* send multicast packets because all phyints are disabled.
*/
if (recvlen) {
+ hopbyhop = FALSE;
printf("\n 0 ");
print_host(qdst);
printf("\n");
- print_trace(1, &base, names);
+ print_trace(1, &base);
r = base.resps + base.len - 1;
if (r->tr_rflags == TR_OLD_ROUTER || r->tr_rflags == TR_NO_SPACE ||
- (qno != 0 && r->tr_rmtaddr != 0 && !fflag)) {
+ (qno != 0 && r->tr_rmtaddr != 0)) {
printf("%3d ", -(base.len+1));
what_kind(&base, r->tr_rflags == TR_OLD_ROUTER ?
"doesn't support mtrace"
: "is the next hop");
} else {
- if (fflag) {
- nexthop = hops = qno;
- goto continuehop;
- }
VAL_TO_MASK(smask, r->tr_smask);
if ((r->tr_inaddr & smask) == (qsrc & smask)) {
printf("%3d ", -(base.len+1));
@@ -2881,17 +2411,15 @@ char *argv[];
* reduces the amount of multicast traffic and avoids a bug
* with duplicate suppression in mrouted 3.5.
*/
- if (hops == 2 && gwy == 0 && lastout != 0 &&
- (recvlen = send_recv(lastout, IGMP_MTRACE, hops, 1, &base, mtrace_callback)))
+ if (hops == 2 && gwy == 0 &&
+ (recvlen = send_recv(lastout, IGMP_MTRACE, hops, 1, &base)))
tdst = lastout;
- else recvlen = send_recv(tdst, IGMP_MTRACE, hops, nqueries, &base, mtrace_callback);
+ else recvlen = send_recv(tdst, IGMP_MTRACE, hops, nqueries, &base);
if (recvlen == 0) {
- /*if (hops == 1) break;*/
+ if (hops == 1) break;
if (hops == nexthop) {
- if (hops == 1) {
- printf("\n");
- } else if (what_kind(&base, "didn't respond")) {
+ if (what_kind(&base, "didn't respond")) {
/* the ask_neighbors determined that the
* not-responding router is the first-hop. */
break;
@@ -2909,10 +2437,10 @@ char *argv[];
if (base.len == hops &&
(hops == 1 || (base.resps+nexthop-2)->tr_outaddr == lastout)) {
if (hops == nexthop) {
- print_trace(-hops, &base, names);
+ print_trace(-hops, &base);
} else {
printf("\nResuming...\n");
- print_trace(nexthop, &base, names);
+ print_trace(nexthop, &base);
}
} else {
if (base.len < hops) {
@@ -2931,26 +2459,20 @@ char *argv[];
*/
if (nexthop <= base.len) {
printf("\nResuming...\n");
- print_trace(nexthop, &base, names);
+ print_trace(nexthop, &base);
} else if (nexthop > base.len + 1) {
hops = base.len;
printf("\nRoute must have changed...\n");
- print_trace(1, &base, names);
+ print_trace(1, &base);
}
} else {
/*
- * The last hop address is not the same as it was.
- * If we didn't know the last hop then we just
- * got the first response from a hop-by-hop trace;
- * if we did know the last hop then
+ * The last hop address is not the same as it was;
* the route probably changed underneath us.
*/
hops = base.len;
- if (lastout != 0)
- printf("\nRoute must have changed...\n");
- else
- printf("\nResuming...\n");
- print_trace(1, &base, names);
+ printf("\nRoute must have changed...\n");
+ print_trace(1, &base);
}
}
continuehop:
@@ -3005,7 +2527,7 @@ or multicast at ttl %d doesn't reach its last-hop router for that source\n",
rno = base.len - 1;
while (--rno > 0) {
--n;
- ttl = MaX(ttl, MaX(1, n->tr_fttl) + base.len - rno);
+ ttl = MaX(ttl, n->tr_fttl + base.len - rno);
}
printf("total ttl of %d required.\n\n",ttl);
}
@@ -3015,7 +2537,7 @@ or multicast at ttl %d doesn't reach its last-hop router for that source\n",
* and make additional probes after delay to measure loss.
*/
raddr = base.qhdr.tr_raddr;
- rttl = TR_GETTTL(base.qhdr.tr_rttlqid);
+ rttl = base.qhdr.tr_rttl;
gettimeofday(&tv, 0);
waittime = statint - (((tv.tv_sec + JAN_1970) & 0xFFFF) - (base.qtime >> 16));
prev = &base;
@@ -3032,17 +2554,13 @@ or multicast at ttl %d doesn't reach its last-hop router for that source\n",
while (numstats--) {
if (waittime < 1) printf("\n");
else {
- if (printstats && (lossthresh == 0 || printed)) {
- printf("Waiting to accumulate statistics...");
- } else {
- printf(".");
- }
+ printf("%s", printstats ? "Waiting to accumulate statistics... "
+ : ".");
fflush(stdout);
sleep((unsigned)waittime);
}
- printed = 0;
rno = hopbyhop ? base.len : qno ? qno : MAXHOPS;
- recvlen = send_recv(tdst, IGMP_MTRACE, rno, nqueries, new, mtrace_callback);
+ recvlen = send_recv(tdst, IGMP_MTRACE, rno, nqueries, new);
if (recvlen == 0) {
printf("Timed out.\n");
@@ -3061,7 +2579,7 @@ or multicast at ttl %d doesn't reach its last-hop router for that source\n",
(int)((new->qtime - base.qtime) >> 16));
printf(":\n");
printandcontinue:
- print_trace(1, new, names);
+ print_trace(1, new);
numstats++;
bcopy(new, &base, sizeof(base));
nexthop = hops = new->len;
@@ -3070,31 +2588,13 @@ printandcontinue:
}
if (printstats) {
- if (new->igmp.igmp_group.s_addr != qgrp ||
- new->qhdr.tr_src != qsrc || new->qhdr.tr_dst != qdst)
- printf("\nWARNING: trace modified en route; statistics may be incorrect\n");
+ printf("Results after %d seconds:\n\n",
+ (int)((new->qtime - base.qtime) >> 16));
fixup_stats(&base, prev, new, bugs);
- if ((lossthresh == 0) || check_thresh(lossthresh, &base, prev, new)) {
- printf("Results after %d seconds",
- (int)((new->qtime - base.qtime) >> 16));
- if (lossthresh)
- printf(" (this trace %d seconds)",
- (int)((new->qtime - prev->qtime) >> 16));
- if (verbose) {
- time_t t = time(0);
- struct tm *qr = localtime(&t);
-
- printf(" qid 0x%06x at %2d:%02d:%02d",
- TR_GETQID(base.qhdr.tr_rttlqid),
- qr->tm_hour, qr->tm_min, qr->tm_sec);
- }
- printf(":\n\n");
- printed = 1;
- if (print_stats(&base, prev, new, bugs, names)) {
- printf("This should have been detected earlier, but ");
- printf("Route changed:\n");
- goto printandcontinue;
- }
+ if (print_stats(&base, prev, new, bugs)) {
+ printf("This should have been detected earlier, but ");
+ printf("Route changed:\n");
+ goto printandcontinue;
}
}
prev = new;
@@ -3116,9 +2616,9 @@ static void
usage()
{
fprintf(stderr, "%s\n%s\n%s\n",
- "usage: mtrace [-MUOPTWVlnpvs] [-e extra_hops] [-f first_hop] [-i if_addr]",
- " [-g gateway] [-m max_hops] [-q nqueries] [-r resp_dest]",
- " [-S statint] [-t ttl] [-w wait] source [receiver] [group]");
+ "usage: mtrace [-Mlnps] [-w wait] [-m max_hops] [-q nqueries]",
+ " [-g gateway] [-S statint] [-t ttl] [-r resp_dest]",
+ " [-i if_addr] source [receiver] [group]");
exit(1);
}
@@ -3175,3 +2675,92 @@ log(severity, syserr, format, va_alist)
}
if (severity <= LOG_ERR) exit(1);
}
+
+/* dummies */
+void accept_probe(src, dst, p, datalen, level)
+ u_int32 src, dst, level;
+ char *p;
+ int datalen;
+{
+}
+void accept_group_report(src, dst, group, r_type)
+ u_int32 src, dst, group;
+ int r_type;
+{
+}
+void accept_neighbor_request2(src, dst)
+ u_int32 src, dst;
+{
+}
+void accept_report(src, dst, p, datalen, level)
+ u_int32 src, dst, level;
+ char *p;
+ int datalen;
+{
+}
+void accept_neighbor_request(src, dst)
+ u_int32 src, dst;
+{
+}
+void accept_prune(src, dst, p, datalen)
+ u_int32 src, dst;
+ char *p;
+ int datalen;
+{
+}
+void accept_graft(src, dst, p, datalen)
+ u_int32 src, dst;
+ char *p;
+ int datalen;
+{
+}
+void accept_g_ack(src, dst, p, datalen)
+ u_int32 src, dst;
+ char *p;
+ int datalen;
+{
+}
+void add_table_entry(origin, mcastgrp)
+ u_int32 origin, mcastgrp;
+{
+}
+void accept_leave_message(src, dst, group)
+ u_int32 src, dst, group;
+{
+}
+void accept_mtrace(src, dst, group, data, no, datalen)
+ u_int32 src, dst, group;
+ char *data;
+ u_int no;
+ int datalen;
+{
+}
+void accept_membership_query(src, dst, group, tmo)
+ u_int32 src, dst, group;
+ int tmo;
+{
+}
+void accept_neighbors(src, dst, p, datalen, level)
+ u_int32 src, dst, level;
+ u_char *p;
+ int datalen;
+{
+}
+void accept_neighbors2(src, dst, p, datalen, level)
+ u_int32 src, dst, level;
+ u_char *p;
+ int datalen;
+{
+}
+void accept_info_request(src, dst, p, datalen)
+ u_int32 src, dst;
+ u_char *p;
+ int datalen;
+{
+}
+void accept_info_reply(src, dst, p, datalen)
+ u_int32 src, dst;
+ u_char *p;
+ int datalen;
+{
+}
diff --git a/usr.sbin/mrouted/mtrace.h b/usr.sbin/mrouted/mtrace.h
index e67dbd0fa145..1d704910475b 100644
--- a/usr.sbin/mrouted/mtrace.h
+++ b/usr.sbin/mrouted/mtrace.h
@@ -1,31 +1,31 @@
/*
* Multicast traceroute related definitions
*
- * mtrace.h,v 5.2 1998/12/04 04:48:21 fenner Exp
+ * mtrace.h,v 5.1 1996/12/19 21:31:26 fenner Exp
*/
/*
- * NetBSD renamed the mtrace packet types.
- */
-#if !defined(IGMP_MTRACE_RESP) && defined(IGMP_MTRACE_REPLY)
-#define IGMP_MTRACE_RESP IGMP_MTRACE_REPLY
-#define IGMP_MTRACE IGMP_MTRACE_QUERY
-#endif
-
-/*
* The packet format for a traceroute request.
*/
struct tr_query {
u_int32 tr_src; /* traceroute source */
u_int32 tr_dst; /* traceroute destination */
u_int32 tr_raddr; /* traceroute response address */
- u_int32 tr_rttlqid; /* response ttl and qid */
+#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
+ struct {
+ u_int qid : 24; /* traceroute query id */
+ u_int ttl : 8; /* traceroute response ttl */
+ } q;
+#else
+ struct {
+ u_int ttl : 8; /* traceroute response ttl */
+ u_int qid : 24; /* traceroute query id */
+ } q;
+#endif /* BYTE_ORDER */
};
-#define TR_SETTTL(x, ttl) (x = (x & 0x00ffffff) | ((ttl) << 24))
-#define TR_GETTTL(x) (((x) >> 24) & 0xff)
-#define TR_SETQID(x, qid) (x = (x & 0xff000000) | ((qid) & 0x00ffffff))
-#define TR_GETQID(x) ((x) & 0x00ffffff)
+#define tr_rttl q.ttl
+#define tr_qid q.qid
/*
* Traceroute response format. A traceroute response has a tr_query at the
@@ -46,6 +46,8 @@ struct tr_resp {
};
/* defs within mtrace */
+#define QUERY 1
+#define RESP 2
#define QLEN sizeof(struct tr_query)
#define RLEN sizeof(struct tr_resp)
@@ -72,10 +74,6 @@ struct tr_resp {
#define PROTO_PIM_SPECIAL 5
#define PROTO_PIM_STATIC 6
#define PROTO_DVMRP_STATIC 7
-#define PROTO_PIM_BGP4PLUS 8
-#define PROTO_CBT_SPECIAL 9
-#define PROTO_CBT_STATIC 10
-#define PROTO_PIM_ASSERT 11
#define VAL_TO_MASK(x, i) { \
x = htonl(~((1 << (32 - (i))) - 1)); \
diff --git a/usr.sbin/mrouted/pathnames.h b/usr.sbin/mrouted/pathnames.h
index 0c30420900c7..b8fb6baf4333 100644
--- a/usr.sbin/mrouted/pathnames.h
+++ b/usr.sbin/mrouted/pathnames.h
@@ -7,8 +7,7 @@
* Leland Stanford Junior University.
*
*
- * $Id: pathnames.h,v 1.5 1997/02/22 16:07:01 peter Exp $
- * pathnames.h,v 3.8 1995/11/29 22:36:57 fenner Rel
+ * $Id$
*/
#define _PATH_MROUTED_CONF "/etc/mrouted.conf"
diff --git a/usr.sbin/mrouted/prune.c b/usr.sbin/mrouted/prune.c
index 358613702a79..23ba6384bd03 100644
--- a/usr.sbin/mrouted/prune.c
+++ b/usr.sbin/mrouted/prune.c
@@ -5,37 +5,45 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
- *
- *
- * prune.c,v 3.8.4.59 1998/03/01 02:06:32 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: prune.c,v 1.15 1998/01/16 07:17:44 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include "defs.h"
extern int cache_lifetime;
-extern int prune_lifetime;
+extern int max_prune_lifetime;
extern struct rtentry *routing_table;
extern int phys_vif;
-extern int allow_black_holes;
-
/*
- * randomize value to obtain a value between .5x and 1.5x
- * in order to prevent synchronization
+ * dither cache lifetime to obtain a value between x and 2*x
*/
#ifdef SYSV
-#define JITTERED_VALUE(x) ((x)/2 + (lrand48() % (x)))
+#define CACHE_LIFETIME(x) ((x) + (lrand48() % (x)))
#else
-#define JITTERED_VALUE(x) ((x)/2 + (random() % (x)))
+#define CACHE_LIFETIME(x) ((x) + (random() % (x)))
#endif
-#define CACHE_LIFETIME(x) JITTERED_VALUE(x) /* XXX */
+#define CHK_GS(x, y) { \
+ switch(x) { \
+ case 2: \
+ case 4: \
+ case 8: \
+ case 16: \
+ case 32: \
+ case 64: \
+ case 128: \
+ case 256: y = 1; \
+ break; \
+ default: y = 0; \
+ } \
+ }
+
struct gtable *kernel_table; /* ptr to list of kernel grp entries*/
static struct gtable *kernel_no_route; /* list of grp entries w/o routes */
struct gtable *gtp; /* pointer for kernel rt entries */
@@ -44,20 +52,17 @@ unsigned int kroutes; /* current number of cache entries */
/****************************************************************************
Functions that are local to prune.c
****************************************************************************/
-static int scoped_addr __P((vifi_t vifi, u_int32 addr));
static void prun_add_ttls __P((struct gtable *gt));
static int pruning_neighbor __P((vifi_t vifi, u_int32 addr));
static int can_mtrace __P((vifi_t vifi, u_int32 addr));
static struct ptable * find_prune_entry __P((u_int32 vr, struct ptable *pt));
-static void remove_sources __P((struct gtable *gt));
-static void rexmit_prune __P((void *arg));
static void expire_prune __P((vifi_t vifi, struct gtable *gt));
static void send_prune __P((struct gtable *gt));
static void send_graft __P((struct gtable *gt));
static void send_graft_ack __P((u_int32 src, u_int32 dst,
- u_int32 origin, u_int32 grp,
- vifi_t vifi));
+ u_int32 origin, u_int32 grp));
static void update_kernel __P((struct gtable *g));
+static char * scaletime __P((u_long t));
/*
* Updates the ttl values for each vif.
@@ -79,34 +84,16 @@ prun_add_ttls(gt)
/*
* checks for scoped multicast addresses
- * XXX I want to make the check of allow_black_holes based on ALLOW_BLACK_HOLES
- * but macros are not functions.
*/
#define GET_SCOPE(gt) { \
register vifi_t _i; \
- VIFM_CLRALL((gt)->gt_scope); \
- if (allow_black_holes || \
- (ntohl((gt)->gt_mcastgrp) & 0xff000000) == 0xef000000) \
+ if ((ntohl((gt)->gt_mcastgrp) & 0xff000000) == 0xef000000) \
for (_i = 0; _i < numvifs; _i++) \
if (scoped_addr(_i, (gt)->gt_mcastgrp)) \
VIFM_SET(_i, (gt)->gt_scope); \
- } \
- if ((gt)->gt_route == NULL || ((gt)->gt_route->rt_parent != NO_VIF && \
- VIFM_ISSET((gt)->gt_route->rt_parent, (gt)->gt_scope))) \
- VIFM_SETALL((gt)->gt_scope);
-
-#define APPLY_SCOPE(gt) VIFM_CLR_MASK((gt)->gt_grpmems, (gt)->gt_scope)
-
-#define GET_MEMBERSHIP(gt, vifi) { \
- if ((gt)->gt_route && \
- VIFM_ISSET((vifi), (gt)->gt_route->rt_children) && \
- (!SUBS_ARE_PRUNED((gt)->gt_route->rt_subordinates, \
- uvifs[vifi].uv_nbrmap, (gt)->gt_prunes) || \
- grplst_mem((vifi), (gt)->gt_mcastgrp))) \
- VIFM_SET((vifi), (gt)->gt_grpmems); \
}
-static int
+int
scoped_addr(vifi, addr)
vifi_t vifi;
u_int32 addr;
@@ -120,38 +107,6 @@ scoped_addr(vifi, addr)
return 0;
}
-/*
- * Determine the list of outgoing vifs, based upon
- * route subordinates, prunes received, and group
- * memberships.
- */
-void
-determine_forwvifs(gt)
- struct gtable *gt;
-{
- vifi_t i;
-
- VIFM_CLRALL(gt->gt_grpmems);
- for (i = 0; i < numvifs; i++) {
- GET_MEMBERSHIP(gt, i);
- }
- GET_SCOPE(gt);
- APPLY_SCOPE(gt);
-}
-
-/*
- * Send a prune or a graft if necessary.
- */
-void
-send_prune_or_graft(gt)
- struct gtable *gt;
-{
- if (VIFM_ISEMPTY(gt->gt_grpmems))
- send_prune(gt);
- else if (gt->gt_prsent_timer)
- send_graft(gt);
-}
-
/*
* Determine if mcastgrp has a listener on vifi
*/
@@ -226,8 +181,15 @@ pruning_neighbor(vifi, addr)
if (n == NULL)
return 0;
+ if (n->al_flags & NF_PRUNE)
+ return 1;
+
+ /*
+ * Versions from 3.0 to 3.4 relied on the version number to identify
+ * that they could handle pruning.
+ */
vers = NBR_VERS(n);
- return (vers >= 0x0300 && ((vers & 0xff00) != 0x0a00));
+ return (vers >= 0x0300 && vers <= 0x0304);
}
/*
@@ -242,10 +204,17 @@ can_mtrace(vifi, addr)
int vers;
if (n == NULL)
- return 1; /* fail "safe" */
+ return 0;
+
+ if (n->al_flags & NF_MTRACE)
+ return 1;
+ /*
+ * Versions 3.3 and 3.4 relied on the version number to identify
+ * that they could handle traceroute.
+ */
vers = NBR_VERS(n);
- return (vers >= 0x0303 && ((vers & 0xff00) != 0x0a00));
+ return (vers >= 0x0303 && vers <= 0x0304);
}
/*
@@ -266,76 +235,6 @@ find_prune_entry(vr, pt)
}
/*
- * Remove all the sources hanging off the group table entry from the kernel
- * cache. Remember the packet counts wherever possible, to keep the mtrace
- * counters consistent. This prepares for possible prune retransmission,
- * either on a multi-access network or when a prune that we sent upstream
- * has expired.
- */
-static void
-remove_sources(gt)
- struct gtable *gt;
-{
- struct stable *st;
- struct sioc_sg_req sg_req;
-
- sg_req.grp.s_addr = gt->gt_mcastgrp;
-
- /*
- * call k_del_rg() on every one of the gt->gt_srctbl entries
- * but first save the packet count so that the mtrace packet
- * counters can remain approximately correct. There's a race
- * here but it's minor.
- */
- for (st = gt->gt_srctbl; st; st = st->st_next) {
- if (st->st_ctime == 0)
- continue;
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "rexmit_prune deleting (%s %s) (next is %d sec)",
- inet_fmt(st->st_origin, s1),
- inet_fmt(gt->gt_mcastgrp, s2),
- gt->gt_prune_rexmit);
- sg_req.src.s_addr = st->st_origin;
- if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) < 0) {
- sg_req.pktcnt = 0;
- }
- k_del_rg(st->st_origin, gt);
- st->st_ctime = 0; /* flag that it's not in the kernel any more */
- st->st_savpkt += sg_req.pktcnt;
- kroutes--;
- }
-
- /*
- * Now, add_table_entry will prune when asked to add a cache entry.
- */
-}
-
-/*
- * Prepare for possible prune retransmission
- */
-static void
-rexmit_prune(arg)
- void *arg;
-{
- struct gtable *gt = *(struct gtable **)arg;
-
- free(arg);
-
- gt->gt_rexmit_timer = 0;
-
- /* Make sure we're still not forwarding traffic */
- if (!VIFM_ISEMPTY(gt->gt_grpmems)) {
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "rexmit_prune (%s %s): gm:%x",
- RT_FMT(gt->gt_route, s1), inet_fmt(gt->gt_mcastgrp, s2),
- gt->gt_grpmems);
- return;
- }
-
- remove_sources(gt);
-}
-
-/*
* Send a prune message to the dominant router for
* this source.
*
@@ -349,77 +248,38 @@ send_prune(gt)
char *p;
int i;
int datalen;
+ u_int32 src;
u_int32 dst;
u_int32 tmp;
- int rexmitting = 0;
- struct uvif *v;
- /*
- * Can't process a prune if we don't have an associated route
- * or if the route points to a local interface.
- */
- if (gt->gt_route == NULL || gt->gt_route->rt_parent == NO_VIF ||
- gt->gt_route->rt_gateway == 0)
+ /* Don't process any prunes if router is not pruning */
+ if (pruning == 0)
+ return;
+
+ /* Can't process a prune if we don't have an associated route */
+ if (gt->gt_route == NULL)
return;
/* Don't send a prune to a non-pruning router */
if (!pruning_neighbor(gt->gt_route->rt_parent, gt->gt_route->rt_gateway))
return;
- v = &uvifs[gt->gt_route->rt_parent];
/*
* sends a prune message to the router upstream.
*/
-#if 0
- dst = v->uv_flags & VIFF_TUNNEL ? dvmrp_group : gt->gt_route->rt_gateway; /*XXX*/
-#else
+ src = uvifs[gt->gt_route->rt_parent].uv_lcl_addr;
dst = gt->gt_route->rt_gateway;
-#endif
p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
datalen = 0;
/*
- * determine prune lifetime, if this isn't a retransmission.
- *
- * Use interface-specified lifetime if there is one.
+ * determine prune lifetime
*/
- if (gt->gt_prsent_timer == 0) {
- int l = prune_lifetime;
-
- if (v->uv_prune_lifetime != 0)
- l = v->uv_prune_lifetime;
-
- gt->gt_prsent_timer = JITTERED_VALUE(l);
- for (pt = gt->gt_pruntbl; pt; pt = pt->pt_next)
- if (pt->pt_timer < gt->gt_prsent_timer)
- gt->gt_prsent_timer = pt->pt_timer;
- } else if (gt->gt_prsent_timer < 0) {
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "asked to rexmit? (%s,%s)/%d on vif %d to %s with negative time",
- RT_FMT(gt->gt_route, s1), inet_fmt(gt->gt_mcastgrp, s2),
- gt->gt_prsent_timer, gt->gt_route->rt_parent,
- inet_fmt(gt->gt_route->rt_gateway, s3));
- return;
- } else
- rexmitting = 1;
-
- if (rexmitting && !(v->uv_flags & VIFF_REXMIT_PRUNES)) {
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "not rexmitting prune for (%s %s)/%d on vif %d to %s",
- RT_FMT(gt->gt_route, s1), inet_fmt(gt->gt_mcastgrp, s2),
- gt->gt_prsent_timer, gt->gt_route->rt_parent,
- inet_fmt(gt->gt_route->rt_gateway, s3));
- return;
- }
- if (gt->gt_prsent_timer <= MIN_PRUNE_LIFE) {
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "not bothering to send prune for (%s,%s)/%d on vif %d to %s because it's too short",
- RT_FMT(gt->gt_route, s1), inet_fmt(gt->gt_mcastgrp, s2),
- gt->gt_prsent_timer, gt->gt_route->rt_parent,
- inet_fmt(gt->gt_route->rt_gateway, s3));
- return;
- }
+ gt->gt_prsent_timer = gt->gt_timer;
+ for (pt = gt->gt_pruntbl; pt; pt = pt->pt_next)
+ if (pt->pt_timer < gt->gt_prsent_timer)
+ gt->gt_prsent_timer = pt->pt_timer;
/*
* If we have a graft pending, cancel graft retransmission
@@ -435,27 +295,14 @@ send_prune(gt)
*p++ = ((char *)&(tmp))[i];
datalen += 12;
- send_on_vif(v, dst, DVMRP_PRUNE, datalen);
+ send_igmp(src, dst, IGMP_DVMRP, DVMRP_PRUNE,
+ htonl(MROUTED_LEVEL), datalen);
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "%s prune for (%s %s)/%d on vif %d to %s",
- rexmitting ? "rexmitted" : "sent",
- RT_FMT(gt->gt_route, s1), inet_fmt(gt->gt_mcastgrp, s2),
+ log(LOG_DEBUG, 0, "sent prune for (%s %s)/%d on vif %d to %s",
+ inet_fmts(gt->gt_route->rt_origin, gt->gt_route->rt_originmask, s1),
+ inet_fmt(gt->gt_mcastgrp, s2),
gt->gt_prsent_timer, gt->gt_route->rt_parent,
inet_fmt(gt->gt_route->rt_gateway, s3));
-
- if ((v->uv_flags & VIFF_REXMIT_PRUNES) &&
- gt->gt_rexmit_timer == 0 &&
- gt->gt_prsent_timer > gt->gt_prune_rexmit) {
- struct gtable **arg =
- (struct gtable **)malloc(sizeof (struct gtable **));
-
- *arg = gt;
- gt->gt_rexmit_timer = timer_setTimer(
- JITTERED_VALUE(gt->gt_prune_rexmit),
- rexmit_prune, arg);
- gt->gt_prune_rexmit *= 2;
- }
}
/*
@@ -472,28 +319,16 @@ send_graft(gt)
register char *p;
register int i;
int datalen;
+ u_int32 src;
u_int32 dst;
/* Can't send a graft without an associated route */
- if (gt->gt_route == NULL || gt->gt_route->rt_parent == NO_VIF) {
- gt->gt_grftsnt = 0;
+ if (gt->gt_route == NULL)
return;
- }
-
- gt->gt_prsent_timer = 0;
- gt->gt_prune_rexmit = PRUNE_REXMIT_VAL;
- if (gt->gt_rexmit_timer)
- timer_clearTimer(gt->gt_rexmit_timer);
-
- if (gt->gt_grftsnt == 0)
- gt->gt_grftsnt = 1;
-
-#if 0
- dst = uvifs[gt->gt_route->rt_parent].uv_flags & VIFF_TUNNEL ? dvmrp_group : gt->gt_route->rt_gateway; /*XXX*/
-#else
+
+ src = uvifs[gt->gt_route->rt_parent].uv_lcl_addr;
dst = gt->gt_route->rt_gateway;
-#endif
-
+
p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
datalen = 0;
@@ -503,10 +338,13 @@ send_graft(gt)
*p++ = ((char *)&(gt->gt_mcastgrp))[i];
datalen += 8;
- send_on_vif(&uvifs[gt->gt_route->rt_parent], dst, DVMRP_GRAFT, datalen);
- IF_DEBUG(DEBUG_PRUNE)
+ if (datalen != 0) {
+ send_igmp(src, dst, IGMP_DVMRP, DVMRP_GRAFT,
+ htonl(MROUTED_LEVEL), datalen);
+ }
log(LOG_DEBUG, 0, "sent graft for (%s %s) to %s on vif %d",
- RT_FMT(gt->gt_route, s1), inet_fmt(gt->gt_mcastgrp, s2),
+ inet_fmts(gt->gt_route->rt_origin, gt->gt_route->rt_originmask, s1),
+ inet_fmt(gt->gt_mcastgrp, s2),
inet_fmt(gt->gt_route->rt_gateway, s3), gt->gt_route->rt_parent);
}
@@ -514,12 +352,11 @@ send_graft(gt)
* Send an ack that a graft was received
*/
static void
-send_graft_ack(src, dst, origin, grp, vifi)
+send_graft_ack(src, dst, origin, grp)
u_int32 src;
u_int32 dst;
u_int32 origin;
u_int32 grp;
- vifi_t vifi;
{
register char *p;
register int i;
@@ -534,24 +371,11 @@ send_graft_ack(src, dst, origin, grp, vifi)
*p++ = ((char *)&(grp))[i];
datalen += 8;
- if (vifi == NO_VIF)
- send_igmp(src, dst, IGMP_DVMRP, DVMRP_GRAFT_ACK,
- htonl(MROUTED_LEVEL), datalen);
- else {
-#if 0
- if (uvifs[vifi].uv_flags & VIFF_TUNNEL)
- dst = dvmrp_group; /* XXX */
-#endif
- send_on_vif(&uvifs[vifi], dst, DVMRP_GRAFT_ACK, datalen);
- }
+ send_igmp(src, dst, IGMP_DVMRP, DVMRP_GRAFT_ACK,
+ htonl(MROUTED_LEVEL), datalen);
- IF_DEBUG(DEBUG_PRUNE)
- if (vifi == NO_VIF)
- log(LOG_DEBUG, 0, "sent graft ack for (%s, %s) to %s",
- inet_fmt(origin, s1), inet_fmt(grp, s2), inet_fmt(dst, s3));
- else
- log(LOG_DEBUG, 0, "sent graft ack for (%s, %s) to %s on vif %d",
- inet_fmt(origin, s1), inet_fmt(grp, s2), inet_fmt(dst, s3), vifi);
+ log(LOG_DEBUG, 0, "sent graft ack for (%s, %s) to %s",
+ inet_fmt(origin, s1), inet_fmt(grp, s2), inet_fmt(dst, s3));
}
/*
@@ -564,8 +388,7 @@ update_kernel(g)
struct stable *st;
for (st = g->gt_srctbl; st; st = st->st_next)
- if (st->st_ctime != 0)
- k_add_rg(st->st_origin, g);
+ k_add_rg(st->st_origin, g);
}
/****************************************************************************
@@ -581,7 +404,7 @@ update_kernel(g)
*/
struct gtable *
find_grp(grp)
- u_int32 grp;
+ u_long grp;
{
struct gtable *gt;
@@ -601,7 +424,7 @@ find_grp(grp)
struct stable *
find_grp_src(gt, src)
struct gtable *gt;
- u_int32 src;
+ u_long src;
{
struct stable *st;
u_long grp = gt->gt_mcastgrp;
@@ -622,9 +445,9 @@ int
next_grp_src_mask(gtpp, stpp, grp, src, mask)
struct gtable **gtpp; /* ordered by group */
struct stable **stpp; /* ordered by source */
- u_int32 grp;
- u_int32 src;
- u_int32 mask;
+ u_long grp;
+ u_long src;
+ u_long mask;
{
struct gtable *gt, *gbest = NULL;
struct stable *st, *sbest = NULL;
@@ -686,6 +509,76 @@ refresh_sg(sg, gt, st)
}
/*
+ * Return pointer to a specific route entry. This must be a separate
+ * function from find_route() which modifies rtp.
+ */
+struct rtentry *
+snmp_find_route(src, mask)
+ register u_long src, mask;
+{
+ register struct rtentry *rt;
+
+ for (rt = routing_table; rt; rt = rt->rt_next) {
+ if (src == rt->rt_origin && mask == rt->rt_originmask)
+ return rt;
+ }
+ return NULL;
+}
+
+/*
+ * Find next route entry > specification
+ */
+int
+next_route(rtpp, src, mask)
+ struct rtentry **rtpp;
+ u_long src;
+ u_long mask;
+{
+ struct rtentry *rt, *rbest = NULL;
+
+ /* Among all entries > spec, find "lowest" one in order */
+ for (rt = routing_table; rt; rt=rt->rt_next) {
+ if ((ntohl(rt->rt_origin) > ntohl(src)
+ || (ntohl(rt->rt_origin) == ntohl(src)
+ && ntohl(rt->rt_originmask) > ntohl(mask)))
+ && (!rbest || (ntohl(rt->rt_origin) < ntohl(rbest->rt_origin))
+ || (ntohl(rt->rt_origin) == ntohl(rbest->rt_origin)
+ && ntohl(rt->rt_originmask) < ntohl(rbest->rt_originmask))))
+ rbest = rt;
+ }
+ (*rtpp) = rbest;
+ return (*rtpp)!=0;
+}
+
+/*
+ * Given a routing table entry, and a vifi, find the next vifi/entry
+ */
+int
+next_route_child(rtpp, src, mask, vifi)
+ struct rtentry **rtpp;
+ u_long src;
+ u_long mask;
+ vifi_t *vifi; /* vif at which to start looking */
+{
+ struct rtentry *rt;
+
+ /* Get (S,M) entry */
+ if (!((*rtpp) = snmp_find_route(src,mask)))
+ if (!next_route(rtpp, src, mask))
+ return 0;
+
+ /* Continue until we get one with a valid next vif */
+ do {
+ for (; (*rtpp)->rt_children && *vifi<numvifs; (*vifi)++)
+ if (VIFM_ISSET(*vifi, (*rtpp)->rt_children))
+ return 1;
+ *vifi = 0;
+ } while( next_route(rtpp, (*rtpp)->rt_origin, (*rtpp)->rt_originmask) );
+
+ return 0;
+}
+
+/*
* Given a routing table entry, and a vifi, find the next entry
* equal to or greater than those
*/
@@ -693,11 +586,13 @@ int
next_child(gtpp, stpp, grp, src, mask, vifi)
struct gtable **gtpp;
struct stable **stpp;
- u_int32 grp;
- u_int32 src;
- u_int32 mask;
+ u_long grp;
+ u_long src;
+ u_long mask;
vifi_t *vifi; /* vif at which to start looking */
{
+ struct stable *st;
+
/* Get (G,S,M) entry */
if (mask!=0xFFFFFFFF
|| !((*gtpp) = find_grp(grp))
@@ -740,15 +635,7 @@ add_table_entry(origin, mcastgrp)
struct rtentry *r;
struct gtable *gt,**gtnp,*prev_gt;
struct stable *st,**stnp;
-
- /*
- * Since we have to enable mrouting to get the version number,
- * some cache creation requests can sneak through. Ignore them
- * since we're not going to do useful stuff until we've performed
- * final initialization.
- */
- if (!did_final_init)
- return;
+ vifi_t i;
#ifdef DEBUG_MFC
md_log(MD_MISS, origin, mcastgrp);
@@ -784,20 +671,35 @@ add_table_entry(origin, mcastgrp)
gt->gt_mcastgrp = mcastgrp;
gt->gt_timer = CACHE_LIFETIME(cache_lifetime);
time(&gt->gt_ctime);
+ gt->gt_grpmems = 0;
+ gt->gt_scope = 0;
gt->gt_prsent_timer = 0;
gt->gt_grftsnt = 0;
gt->gt_srctbl = NULL;
gt->gt_pruntbl = NULL;
gt->gt_route = r;
- gt->gt_rexmit_timer = 0;
- NBRM_CLRALL(gt->gt_prunes);
- gt->gt_prune_rexmit = PRUNE_REXMIT_VAL;
#ifdef RSRR
gt->gt_rsrr_cache = NULL;
#endif
- /* Calculate forwarding vifs */
- determine_forwvifs(gt);
+ if (r != NULL) {
+ /* obtain the multicast group membership list */
+ for (i = 0; i < numvifs; i++) {
+ if (VIFM_ISSET(i, r->rt_children) &&
+ !(VIFM_ISSET(i, r->rt_leaves)))
+ VIFM_SET(i, gt->gt_grpmems);
+
+ if (VIFM_ISSET(i, r->rt_leaves) && grplst_mem(i, mcastgrp))
+ VIFM_SET(i, gt->gt_grpmems);
+ }
+ GET_SCOPE(gt);
+ if (VIFM_ISSET(r->rt_parent, gt->gt_scope))
+ gt->gt_scope = -1;
+ gt->gt_grpmems &= ~gt->gt_scope;
+ } else {
+ gt->gt_scope = -1;
+ gt->gt_grpmems = 0;
+ }
/* update ttls */
prun_add_ttls(gt);
@@ -814,7 +716,8 @@ add_table_entry(origin, mcastgrp)
g = gtp ? gtp->gt_gnext : kernel_table;
log(LOG_WARNING, 0, "Entry for (%s %s) (rt:%x) exists (rt:%x)",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
+ inet_fmt(g->gt_mcastgrp, s2),
r, g->gt_route);
} else {
if (gtp) {
@@ -848,46 +751,39 @@ add_table_entry(origin, mcastgrp)
st->st_origin = origin;
st->st_pktcnt = 0;
- st->st_savpkt = 0;
- time(&st->st_ctime);
st->st_next = *stnp;
*stnp = st;
} else {
- if (st->st_ctime == 0) {
- /* An old source which we're keeping around for statistics */
- time(&st->st_ctime);
- } else {
#ifdef DEBUG_MFC
- md_log(MD_DUPE, origin, mcastgrp);
+ md_log(MD_DUPE, origin, mcastgrp);
#endif
- /* Ignore kernel->mrouted retransmissions */
- if (time(0) - st->st_ctime > 5)
- log(LOG_WARNING, 0, "kernel entry already exists for (%s %s)",
- inet_fmt(origin, s1), inet_fmt(mcastgrp, s2));
- k_add_rg(origin, gt);
- return;
- }
+ log(LOG_WARNING, 0, "kernel entry already exists for (%s %s)",
+ inet_fmt(origin, s1), inet_fmt(mcastgrp, s2));
+ /* XXX Doing this should cause no harm, and may ensure
+ * kernel<>mrouted synchronization */
+ k_add_rg(origin, gt);
+ return;
}
kroutes++;
k_add_rg(origin, gt);
- IF_DEBUG(DEBUG_CACHE)
log(LOG_DEBUG, 0, "add cache entry (%s %s) gm:%x, parent-vif:%d",
inet_fmt(origin, s1),
inet_fmt(mcastgrp, s2),
gt->gt_grpmems, r ? r->rt_parent : -1);
-
- /*
- * If there are no downstream routers that want traffic for
- * this group, send (or retransmit) a prune upstream.
+
+ /* If there are no leaf vifs
+ * which have this group, then
+ * mark this src-grp as a prune candidate.
*/
- if (VIFM_ISEMPTY(gt->gt_grpmems))
+ if (!gt->gt_prsent_timer && !gt->gt_grpmems && r && r->rt_gateway)
send_prune(gt);
}
/*
- * A router has gone down. Remove prune state pertinent to that router.
+ * An mrouter has gone down and come up on an interface
+ * Forward on that interface immediately
*/
void
reset_neighbor_state(vifi, addr)
@@ -909,29 +805,35 @@ reset_neighbor_state(vifi, addr)
*/
if (vifi == r->rt_parent) {
if (addr == r->rt_gateway) {
- IF_DEBUG(DEBUG_PEER)
log(LOG_DEBUG, 0, "reset_neighbor_state parent reset (%s %s)",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2));
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
+ inet_fmt(g->gt_mcastgrp, s2));
g->gt_prsent_timer = 0;
g->gt_grftsnt = 0;
- while ((st = g->gt_srctbl) != NULL) {
+ while ((st = g->gt_srctbl)) {
g->gt_srctbl = st->st_next;
- if (st->st_ctime != 0) {
- k_del_rg(st->st_origin, g);
- kroutes--;
- }
+ k_del_rg(st->st_origin, g);
+ kroutes--;
free(st);
}
}
} else {
/*
+ * Neighbor was not the parent, send grafts to join the groups
+ */
+ if (g->gt_prsent_timer) {
+ g->gt_grftsnt = 1;
+ send_graft(g);
+ g->gt_prsent_timer = 0;
+ }
+
+ /*
* Remove any prunes that this router has sent us.
*/
ptnp = &g->gt_pruntbl;
while ((pt = *ptnp) != NULL) {
if (pt->pt_vifi == vifi && pt->pt_router == addr) {
- NBRM_CLR(pt->pt_index, g->gt_prunes);
*ptnp = pt->pt_next;
free(pt);
} else
@@ -942,8 +844,15 @@ reset_neighbor_state(vifi, addr)
* And see if we want to forward again.
*/
if (!VIFM_ISSET(vifi, g->gt_grpmems)) {
- GET_MEMBERSHIP(g, vifi);
- APPLY_SCOPE(g);
+ if (VIFM_ISSET(vifi, r->rt_children) &&
+ !(VIFM_ISSET(vifi, r->rt_leaves)))
+ VIFM_SET(vifi, g->gt_grpmems);
+
+ if (VIFM_ISSET(vifi, r->rt_leaves) &&
+ grplst_mem(vifi, g->gt_mcastgrp))
+ VIFM_SET(vifi, g->gt_grpmems);
+
+ g->gt_grpmems &= ~g->gt_scope;
prun_add_ttls(g);
/* Update kernel state */
@@ -953,17 +862,8 @@ reset_neighbor_state(vifi, addr)
rsrr_cache_send(g,1);
#endif /* RSRR */
- /*
- * If removing this prune causes us to start forwarding
- * (e.g. the neighbor rebooted), and we sent a prune upstream,
- * send a graft to cancel the prune.
- */
- if (!VIFM_ISEMPTY(g->gt_grpmems) && g->gt_prsent_timer)
- send_graft(g);
-
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "reset neighbor state (%s %s) gm:%x",
- RT_FMT(r, s1),
+ log(LOG_DEBUG, 0, "reset member state (%s %s) gm:%x",
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(g->gt_mcastgrp, s2), g->gt_grpmems);
}
}
@@ -987,20 +887,18 @@ del_table_entry(r, mcastgrp, del_flag)
if (del_flag == DEL_ALL_ROUTES) {
g = r->rt_groups;
while (g) {
- IF_DEBUG(DEBUG_CACHE)
log(LOG_DEBUG, 0, "del_table_entry deleting (%s %s)",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2));
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
+ inet_fmt(g->gt_mcastgrp, s2));
st = g->gt_srctbl;
while (st) {
- if (st->st_ctime != 0) {
- if (k_del_rg(st->st_origin, g) < 0) {
- log(LOG_WARNING, errno,
- "del_table_entry trying to delete (%s, %s)",
- inet_fmt(st->st_origin, s1),
- inet_fmt(g->gt_mcastgrp, s2));
- }
- kroutes--;
+ if (k_del_rg(st->st_origin, g) < 0) {
+ log(LOG_WARNING, errno,
+ "del_table_entry trying to delete (%s, %s)",
+ inet_fmt(st->st_origin, s1),
+ inet_fmt(g->gt_mcastgrp, s2));
}
+ kroutes--;
prev_st = st;
st = st->st_next;
free(prev_st);
@@ -1027,9 +925,6 @@ del_table_entry(r, mcastgrp, del_flag)
rsrr_cache_send(g,0);
rsrr_cache_clean(g);
#endif /* RSRR */
- if (g->gt_rexmit_timer)
- timer_clearTimer(g->gt_rexmit_timer);
-
prev_g = g;
g = g->gt_next;
free(prev_g);
@@ -1044,20 +939,18 @@ del_table_entry(r, mcastgrp, del_flag)
prev_g = (struct gtable *)&r->rt_groups;
for (g = r->rt_groups; g; g = g->gt_next) {
if (g->gt_mcastgrp == mcastgrp) {
- IF_DEBUG(DEBUG_CACHE)
log(LOG_DEBUG, 0, "del_table_entry deleting (%s %s)",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2));
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
+ inet_fmt(g->gt_mcastgrp, s2));
st = g->gt_srctbl;
while (st) {
- if (st->st_ctime != 0) {
- if (k_del_rg(st->st_origin, g) < 0) {
- log(LOG_WARNING, errno,
- "del_table_entry trying to delete (%s, %s)",
- inet_fmt(st->st_origin, s1),
- inet_fmt(g->gt_mcastgrp, s2));
- }
- kroutes--;
+ if (k_del_rg(st->st_origin, g) < 0) {
+ log(LOG_WARNING, errno,
+ "del_table_entry trying to delete (%s, %s)",
+ inet_fmt(st->st_origin, s1),
+ inet_fmt(g->gt_mcastgrp, s2));
}
+ kroutes--;
prev_st = st;
st = st->st_next;
free(prev_st);
@@ -1085,8 +978,6 @@ del_table_entry(r, mcastgrp, del_flag)
g->gt_next->gt_prev = NULL;
prev_g->gt_next = g->gt_next;
- if (g->gt_rexmit_timer)
- timer_clearTimer(g->gt_rexmit_timer);
#ifdef RSRR
/* Send route change notification to reservation protocol. */
rsrr_cache_send(g,0);
@@ -1105,70 +996,48 @@ del_table_entry(r, mcastgrp, del_flag)
* update kernel table entry when a route entry changes
*/
void
-update_table_entry(r, old_parent_gw)
+update_table_entry(r)
struct rtentry *r;
- u_int32 old_parent_gw;
{
struct gtable *g;
- struct ptable *pt, **ptnp;
+ struct ptable *pt, *prev_pt;
+ vifi_t i;
for (g = r->rt_groups; g; g = g->gt_next) {
- ptnp = &g->gt_pruntbl;
- /*
- * Delete prune entries from non-children, or non-subordinates.
- */
- while ((pt = *ptnp)) {
- if (!VIFM_ISSET(pt->pt_vifi, r->rt_children) ||
- !NBRM_ISSET(pt->pt_index, r->rt_subordinates)) {
+ pt = g->gt_pruntbl;
+ while (pt) {
+ prev_pt = pt->pt_next;
+ free(pt);
+ pt = prev_pt;
+ }
+ g->gt_pruntbl = NULL;
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "update_table_entry deleting prune for (%s %s) from %s on vif %d -%s%s",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2),
- inet_fmt(pt->pt_router, s3), pt->pt_vifi,
- VIFM_ISSET(pt->pt_vifi, r->rt_children) ? "" : " not a child",
- NBRM_ISSET(pt->pt_index, r->rt_subordinates) ? "" : " not a subordinate");
+ g->gt_grpmems = 0;
- if (!NBRM_ISSET(pt->pt_index, g->gt_prunes)) {
- log(LOG_WARNING, 0,
- "gt_prunes lost track of (%s %s) from %s on vif %d",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2),
- inet_fmt(pt->pt_router, s3), pt->pt_vifi);
- }
-
- NBRM_CLR(pt->pt_index, g->gt_prunes);
- *ptnp = pt->pt_next;
- free(pt);
- continue;
- }
- ptnp = &((*ptnp)->pt_next);
+ /* obtain the multicast group membership list */
+ for (i = 0; i < numvifs; i++) {
+ if (VIFM_ISSET(i, r->rt_children) &&
+ !(VIFM_ISSET(i, r->rt_leaves)))
+ VIFM_SET(i, g->gt_grpmems);
+
+ if (VIFM_ISSET(i, r->rt_leaves) && grplst_mem(i, g->gt_mcastgrp))
+ VIFM_SET(i, g->gt_grpmems);
}
+ if (VIFM_ISSET(r->rt_parent, g->gt_scope))
+ g->gt_scope = -1;
+ g->gt_grpmems &= ~g->gt_scope;
- IF_DEBUG(DEBUG_CACHE)
- log(LOG_DEBUG, 0, "updating cache entries (%s %s) old gm:%x",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2),
+ log(LOG_DEBUG, 0, "updating cache entries (%s %s) gm:%x",
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
+ inet_fmt(g->gt_mcastgrp, s2),
g->gt_grpmems);
- /*
- * Forget about a prune or graft that we sent previously if we
- * have a new parent router (since the new parent router will
- * know nothing about what I sent to the previous parent). The
- * old parent will forget any prune state it is keeping for us.
- */
- if (old_parent_gw != r->rt_gateway) {
+ if (g->gt_grpmems && g->gt_prsent_timer) {
+ g->gt_grftsnt = 1;
+ send_graft(g);
g->gt_prsent_timer = 0;
- g->gt_grftsnt = 0;
}
- /* Recalculate membership */
- determine_forwvifs(g);
- /* send a prune or graft if needed. */
- send_prune_or_graft(g);
-
- IF_DEBUG(DEBUG_CACHE)
- log(LOG_DEBUG, 0, "updating cache entries (%s %s) new gm:%x",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2),
- g->gt_grpmems);
-
/* update ttls and add entry into kernel */
prun_add_ttls(g);
update_kernel(g);
@@ -1176,6 +1045,12 @@ update_table_entry(r, old_parent_gw)
/* Send route change notification to reservation protocol. */
rsrr_cache_send(g,1);
#endif /* RSRR */
+
+ /* Check if we want to prune this group */
+ if (!g->gt_prsent_timer && g->gt_grpmems == 0 && r->rt_gateway) {
+ g->gt_timer = CACHE_LIFETIME(cache_lifetime);
+ send_prune(g);
+ }
}
}
@@ -1190,7 +1065,6 @@ update_lclgrp(vifi, mcastgrp)
struct rtentry *r;
struct gtable *g;
- IF_DEBUG(DEBUG_MEMBER)
log(LOG_DEBUG, 0, "group %s joined on vif %d",
inet_fmt(mcastgrp, s1), vifi);
@@ -1203,14 +1077,13 @@ update_lclgrp(vifi, mcastgrp)
VIFM_ISSET(vifi, r->rt_children)) {
VIFM_SET(vifi, g->gt_grpmems);
- APPLY_SCOPE(g);
- if (VIFM_ISEMPTY(g->gt_grpmems))
+ g->gt_grpmems &= ~g->gt_scope;
+ if (g->gt_grpmems == 0)
continue;
prun_add_ttls(g);
- IF_DEBUG(DEBUG_CACHE)
log(LOG_DEBUG, 0, "update lclgrp (%s %s) gm:%x",
- RT_FMT(r, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(g->gt_mcastgrp, s2), g->gt_grpmems);
update_kernel(g);
@@ -1230,9 +1103,9 @@ delete_lclgrp(vifi, mcastgrp)
vifi_t vifi;
u_int32 mcastgrp;
{
+ struct rtentry *r;
struct gtable *g;
- IF_DEBUG(DEBUG_MEMBER)
log(LOG_DEBUG, 0, "group %s left on vif %d",
inet_fmt(mcastgrp, s1), vifi);
@@ -1240,14 +1113,28 @@ delete_lclgrp(vifi, mcastgrp)
if (ntohl(mcastgrp) < ntohl(g->gt_mcastgrp))
break;
- if (g->gt_mcastgrp == mcastgrp && VIFM_ISSET(vifi, g->gt_grpmems)) {
- if (g->gt_route == NULL ||
- SUBS_ARE_PRUNED(g->gt_route->rt_subordinates,
- uvifs[vifi].uv_nbrmap, g->gt_prunes)) {
+ if (g->gt_mcastgrp == mcastgrp) {
+ int stop_sending = 1;
+
+ r = g->gt_route;
+ /*
+ * If this is not a leaf, then we have router neighbors on this
+ * vif. Only turn off forwarding if they have all pruned.
+ */
+ if (!VIFM_ISSET(vifi, r->rt_leaves)) {
+ struct listaddr *vr;
+
+ for (vr = uvifs[vifi].uv_neighbors; vr; vr = vr->al_next)
+ if (find_prune_entry(vr->al_addr, g->gt_pruntbl) == NULL) {
+ stop_sending = 0;
+ break;
+ }
+ }
+
+ if (stop_sending) {
VIFM_CLR(vifi, g->gt_grpmems);
- IF_DEBUG(DEBUG_CACHE)
log(LOG_DEBUG, 0, "delete lclgrp (%s %s) gm:%x",
- RT_FMT(g->gt_route, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(g->gt_mcastgrp, s2), g->gt_grpmems);
prun_add_ttls(g);
@@ -1261,7 +1148,7 @@ delete_lclgrp(vifi, mcastgrp)
* If there are no more members of this particular group,
* send prune upstream
*/
- if (VIFM_ISEMPTY(g->gt_grpmems) && g->gt_route->rt_gateway)
+ if (!g->gt_prsent_timer && g->gt_grpmems == 0 && r->rt_gateway)
send_prune(g);
}
}
@@ -1290,9 +1177,15 @@ accept_prune(src, dst, p, datalen)
u_int32 prun_tmr;
vifi_t vifi;
int i;
+ int stop_sending;
struct rtentry *r;
struct gtable *g;
struct ptable *pt;
+ struct listaddr *vr;
+
+ /* Don't process any prunes if router is not pruning */
+ if (pruning == 0)
+ return;
if ((vifi = find_vif(src, dst)) == NO_VIF) {
log(LOG_INFO, 0,
@@ -1318,15 +1211,6 @@ accept_prune(src, dst, p, datalen)
((char *)&prun_tmr)[i] = *p++;
prun_tmr = ntohl(prun_tmr);
- if (prun_tmr <= MIN_PRUNE_LIFE) {
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "ignoring prune from %s on vif %d for (%s %s)/%d because its lifetime is too short",
- inet_fmt(src, s1), vifi,
- inet_fmt(prun_src, s2), inet_fmt(prun_grp, s3), prun_tmr);
- return;
- }
-
- IF_DEBUG(DEBUG_PRUNE)
log(LOG_DEBUG, 0, "%s on vif %d prunes (%s %s)/%d",
inet_fmt(src, s1), vifi,
inet_fmt(prun_src, s2), inet_fmt(prun_grp, s3), prun_tmr);
@@ -1338,19 +1222,10 @@ accept_prune(src, dst, p, datalen)
g = gtp ? gtp->gt_gnext : kernel_table;
r = g->gt_route;
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "found grp state, (%s %s), metric is %d, children are %x, subords are %08x%08x",
- RT_FMT(r, s1), inet_fmt(g->gt_mcastgrp, s2), r->rt_metric,
- r->rt_children, r->rt_subordinates.hi, r->rt_subordinates.lo);
if (!VIFM_ISSET(vifi, r->rt_children)) {
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_WARNING, 0, "prune received from non-child %s for (%s %s) (dominant on vif %d is %s)",
+ log(LOG_WARNING, 0, "prune received from non-child %s for (%s %s)",
inet_fmt(src, s1), inet_fmt(prun_src, s2),
- inet_fmt(prun_grp, s3), vifi,
- inet_fmt(r->rt_dominants[vifi], s4));
-#ifdef RINGBUFFER
- printringbuf();
-#endif
+ inet_fmt(prun_grp, s3));
return;
}
if (VIFM_ISSET(vifi, g->gt_scope)) {
@@ -1360,7 +1235,6 @@ accept_prune(src, dst, p, datalen)
return;
}
if ((pt = find_prune_entry(src, g->gt_pruntbl)) != NULL) {
- IF_DEBUG(DEBUG_PRUNE)
log(LOG_DEBUG, 0, "%s %d from %s for (%s %s)/%d %s %d %s %x",
"duplicate prune received on vif",
vifi, inet_fmt(src, s1), inet_fmt(prun_src, s2),
@@ -1368,14 +1242,6 @@ accept_prune(src, dst, p, datalen)
"old timer:", pt->pt_timer, "cur gm:", g->gt_grpmems);
pt->pt_timer = prun_tmr;
} else {
- struct listaddr *n = neighbor_info(vifi, src);
-
- if (!n) {
- log(LOG_WARNING, 0, "Prune from non-neighbor %s on vif %d!?",
- inet_fmt(src, s1), vifi);
- return;
- }
-
/* allocate space for the prune structure */
pt = (struct ptable *)(malloc(sizeof(struct ptable)));
if (pt == NULL)
@@ -1387,37 +1253,28 @@ accept_prune(src, dst, p, datalen)
pt->pt_next = g->gt_pruntbl;
g->gt_pruntbl = pt;
-
- if (n) {
- pt->pt_index = n->al_index;
- NBRM_SET(n->al_index, g->gt_prunes);
- }
}
+ /* Refresh the group's lifetime */
+ g->gt_timer = CACHE_LIFETIME(cache_lifetime);
+ if (g->gt_timer < prun_tmr)
+ g->gt_timer = prun_tmr;
+
/*
* check if any more packets need to be sent on the
* vif which sent this message
*/
- if (SUBS_ARE_PRUNED(r->rt_subordinates,
- uvifs[vifi].uv_nbrmap, g->gt_prunes) &&
- !grplst_mem(vifi, prun_grp)) {
- nbrbitmap_t tmp;
+ stop_sending = 1;
+ for (vr = uvifs[vifi].uv_neighbors; vr; vr = vr->al_next)
+ if (find_prune_entry(vr->al_addr, g->gt_pruntbl) == NULL) {
+ stop_sending = 0;
+ break;
+ }
+ if (stop_sending && !grplst_mem(vifi, prun_grp)) {
VIFM_CLR(vifi, g->gt_grpmems);
- IF_DEBUG(DEBUG_PRUNE)
- log(LOG_DEBUG, 0, "vifnbrs=0x%08x%08x, subord=0x%08x%08x prunes=0x%08x%08x",
- uvifs[vifi].uv_nbrmap.hi,uvifs[vifi].uv_nbrmap.lo,
- r->rt_subordinates.hi, r->rt_subordinates.lo,
- g->gt_prunes.hi, g->gt_prunes.lo);
- /* XXX debugging */
- NBRM_COPY(r->rt_subordinates, tmp);
- NBRM_MASK(tmp, uvifs[vifi].uv_nbrmap);
- if (!NBRM_ISSETALLMASK(g->gt_prunes, tmp))
- log(LOG_WARNING, 0, "subordinate error");
- /* XXX end debugging */
- IF_DEBUG(DEBUG_PRUNE|DEBUG_CACHE)
log(LOG_DEBUG, 0, "prune (%s %s), stop sending on vif %d, gm:%x",
- RT_FMT(r, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(g->gt_mcastgrp, s2), vifi, g->gt_grpmems);
prun_add_ttls(g);
@@ -1434,7 +1291,7 @@ accept_prune(src, dst, p, datalen)
* interface
* Send a prune message then upstream
*/
- if (VIFM_ISEMPTY(g->gt_grpmems) && r->rt_gateway) {
+ if (!g->gt_prsent_timer && g->gt_grpmems == 0 && r->rt_gateway) {
send_prune(g);
}
} else {
@@ -1443,7 +1300,6 @@ accept_prune(src, dst, p, datalen)
* simply ignore the prune, as we are not forwarding this traffic
* downstream.
*/
- IF_DEBUG(DEBUG_PRUNE|DEBUG_CACHE)
log(LOG_DEBUG, 0, "%s (%s %s)/%d from %s",
"prune message received with no kernel entry for",
inet_fmt(prun_src, s1), inet_fmt(prun_grp, s2),
@@ -1477,19 +1333,22 @@ chkgrp_graft(vifi, mcastgrp)
* If the vif that was joined was a scoped vif,
* ignore it ; don't graft back
*/
- APPLY_SCOPE(g);
- if (VIFM_ISEMPTY(g->gt_grpmems))
+ g->gt_grpmems &= ~g->gt_scope;
+ if (g->gt_grpmems == 0)
continue;
+ /* set the flag for graft retransmission */
+ g->gt_grftsnt = 1;
+
/* send graft upwards */
send_graft(g);
- /* update cache timer*/
- g->gt_timer = CACHE_LIFETIME(cache_lifetime);
+ /* reset the prune timer and update cache timer*/
+ g->gt_prsent_timer = 0;
+ g->gt_timer = max_prune_lifetime;
- IF_DEBUG(DEBUG_PRUNE|DEBUG_CACHE)
log(LOG_DEBUG, 0, "chkgrp graft (%s %s) gm:%x",
- RT_FMT(r, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(g->gt_mcastgrp, s2), g->gt_grpmems);
prun_add_ttls(g);
@@ -1529,6 +1388,13 @@ accept_graft(src, dst, p, datalen)
struct gtable *g;
struct ptable *pt, **ptnp;
+ if ((vifi = find_vif(src, dst)) == NO_VIF) {
+ log(LOG_INFO, 0,
+ "ignoring graft from non-neighbor %s",
+ inet_fmt(src, s1));
+ return;
+ }
+
if (datalen < 8) {
log(LOG_WARNING, 0,
"received non-decipherable graft from %s",
@@ -1540,19 +1406,7 @@ accept_graft(src, dst, p, datalen)
((char *)&graft_src)[i] = *p++;
for (i = 0; i< 4; i++)
((char *)&graft_grp)[i] = *p++;
-
- vifi = find_vif(src, dst);
- send_graft_ack(dst, src, graft_src, graft_grp, vifi);
-
- if (vifi == NO_VIF) {
- log(LOG_INFO, 0,
- "ignoring graft for (%s %s) from non-neighbor %s",
- inet_fmt(graft_src, s2), inet_fmt(graft_grp, s3),
- inet_fmt(src, s1));
- return;
- }
-
- IF_DEBUG(DEBUG_PRUNE)
+
log(LOG_DEBUG, 0, "%s on vif %d grafts (%s %s)",
inet_fmt(src, s1), vifi,
inet_fmt(graft_src, s2), inet_fmt(graft_grp, s3));
@@ -1574,14 +1428,12 @@ accept_graft(src, dst, p, datalen)
ptnp = &g->gt_pruntbl;
while ((pt = *ptnp) != NULL) {
if ((pt->pt_vifi == vifi) && (pt->pt_router == src)) {
- NBRM_CLR(pt->pt_index, g->gt_prunes);
*ptnp = pt->pt_next;
free(pt);
VIFM_SET(vifi, g->gt_grpmems);
- IF_DEBUG(DEBUG_PRUNE|DEBUG_CACHE)
log(LOG_DEBUG, 0, "accept graft (%s %s) gm:%x",
- RT_FMT(r, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(g->gt_mcastgrp, s2), g->gt_grpmems);
prun_add_ttls(g);
@@ -1596,18 +1448,28 @@ accept_graft(src, dst, p, datalen)
}
}
- g->gt_timer = CACHE_LIFETIME(cache_lifetime);
+ /* send ack downstream */
+ send_graft_ack(dst, src, graft_src, graft_grp);
+ g->gt_timer = max_prune_lifetime;
- if (g->gt_prsent_timer)
+ if (g->gt_prsent_timer) {
+ /* set the flag for graft retransmission */
+ g->gt_grftsnt = 1;
+
/* send graft upwards */
send_graft(g);
+
+ /* reset the prune sent timer */
+ g->gt_prsent_timer = 0;
+ }
} else {
/*
* We have no state for the source and group in question.
- * This is fine, since we know that we have no prune state, and
- * grafts are requests to remove prune state.
+ * We can simply acknowledge the graft, since we know
+ * that we have no prune state, and grafts are requests
+ * to remove prune state.
*/
- IF_DEBUG(DEBUG_PRUNE)
+ send_graft_ack(dst, src, graft_src, graft_grp);
log(LOG_DEBUG, 0, "%s (%s %s) from %s",
"graft received with no kernel entry for",
inet_fmt(graft_src, s1), inet_fmt(graft_grp, s2),
@@ -1656,7 +1518,6 @@ accept_g_ack(src, dst, p, datalen)
for (i = 0; i< 4; i++)
((char *)&grft_grp)[i] = *p++;
- IF_DEBUG(DEBUG_PRUNE)
log(LOG_DEBUG, 0, "%s on vif %d acks graft (%s, %s)",
inet_fmt(src, s1), vifi,
inet_fmt(grft_src, s2), inet_fmt(grft_grp, s3));
@@ -1672,9 +1533,6 @@ accept_g_ack(src, dst, p, datalen)
"rcvd graft ack with no kernel entry for",
inet_fmt(grft_src, s1), inet_fmt(grft_grp, s2),
inet_fmt(src, s3));
-#ifdef RINGBUFFER
- printringbuf();
-#endif
return;
}
}
@@ -1713,8 +1571,6 @@ free_all_prunes()
prev_g = g;
g = g->gt_next;
- if (prev_g->gt_rexmit_timer)
- timer_clearTimer(prev_g->gt_rexmit_timer);
free(prev_g);
}
r->rt_groups = NULL;
@@ -1728,8 +1584,6 @@ free_all_prunes()
prev_g = g;
g = g->gt_next;
- if (prev_g->gt_rexmit_timer)
- timer_clearTimer(prev_g->gt_rexmit_timer);
free(prev_g);
}
kernel_no_route = NULL;
@@ -1753,32 +1607,27 @@ steal_sources(rt)
register struct stable *st, **stnp;
for (rp = rt->rt_next; rp; rp = rp->rt_next) {
- if (rp->rt_groups == NULL)
- continue;
if ((rt->rt_origin & rp->rt_originmask) == rp->rt_origin) {
- IF_DEBUG(DEBUG_ROUTE)
log(LOG_DEBUG, 0, "Route for %s stealing sources from %s",
- RT_FMT(rt, s1), RT_FMT(rp, s2));
+ inet_fmts(rt->rt_origin, rt->rt_originmask, s1),
+ inet_fmts(rp->rt_origin, rp->rt_originmask, s2));
for (gt = rp->rt_groups; gt; gt = gt->gt_next) {
stnp = &gt->gt_srctbl;
while ((st = *stnp) != NULL) {
if ((st->st_origin & rt->rt_originmask) == rt->rt_origin) {
- IF_DEBUG(DEBUG_ROUTE)
log(LOG_DEBUG, 0, "%s stealing (%s %s) from %s",
- RT_FMT(rt, s1),
+ inet_fmts(rt->rt_origin, rt->rt_originmask, s1),
inet_fmt(st->st_origin, s3),
inet_fmt(gt->gt_mcastgrp, s4),
- RT_FMT(rp, s2));
- if (st->st_ctime != 0) {
- if (k_del_rg(st->st_origin, gt) < 0) {
- log(LOG_WARNING, errno, "%s (%s, %s)",
- "steal_sources trying to delete",
- inet_fmt(st->st_origin, s1),
- inet_fmt(gt->gt_mcastgrp, s2));
- }
- kroutes--;
+ inet_fmts(rp->rt_origin, rp->rt_originmask, s2));
+ if (k_del_rg(st->st_origin, gt) < 0) {
+ log(LOG_WARNING, errno, "%s (%s, %s)",
+ "steal_sources trying to delete",
+ inet_fmt(st->st_origin, s1),
+ inet_fmt(gt->gt_mcastgrp, s2));
}
*stnp = st->st_next;
+ kroutes--;
free(st);
} else {
stnp = &st->st_next;
@@ -1792,27 +1641,22 @@ steal_sources(rt)
while ((gt = *gtnp) != NULL) {
if (gt->gt_srctbl && ((gt->gt_srctbl->st_origin & rt->rt_originmask)
== rt->rt_origin)) {
- IF_DEBUG(DEBUG_ROUTE)
log(LOG_DEBUG, 0, "%s stealing (%s %s) from %s",
- RT_FMT(rt, s1),
+ inet_fmts(rt->rt_origin, rt->rt_originmask, s1),
inet_fmt(gt->gt_srctbl->st_origin, s3),
inet_fmt(gt->gt_mcastgrp, s4),
"no_route table");
- if (gt->gt_srctbl->st_ctime != 0) {
- if (k_del_rg(gt->gt_srctbl->st_origin, gt) < 0) {
- log(LOG_WARNING, errno, "%s (%s %s)",
- "steal_sources trying to delete",
- inet_fmt(gt->gt_srctbl->st_origin, s1),
- inet_fmt(gt->gt_mcastgrp, s2));
- }
- kroutes--;
+ if (k_del_rg(gt->gt_srctbl->st_origin, gt) < 0) {
+ log(LOG_WARNING, errno, "%s (%s %s)",
+ "steal_sources trying to delete",
+ inet_fmt(gt->gt_srctbl->st_origin, s1),
+ inet_fmt(gt->gt_mcastgrp, s2));
}
+ kroutes--;
free(gt->gt_srctbl);
*gtnp = gt->gt_next;
if (gt->gt_next)
gt->gt_next->gt_prev = gt->gt_prev;
- if (gt->gt_rexmit_timer)
- timer_clearTimer(gt->gt_rexmit_timer);
free(gt);
} else {
gtnp = &gt->gt_next;
@@ -1834,98 +1678,31 @@ age_table_entry()
struct ptable *pt, **ptnp;
struct sioc_sg_req sg_req;
- IF_DEBUG(DEBUG_PRUNE|DEBUG_CACHE)
- log(LOG_DEBUG, 0, "aging forwarding cache entries");
+ log(LOG_DEBUG, 0, "ageing entries");
gtnptr = &kernel_table;
while ((gt = *gtnptr) != NULL) {
- vifi_t i; /* XXX Debugging */
- int fixit = 0; /* XXX Debugging */
-
r = gt->gt_route;
- /* XXX Debugging... */
- for (i = 0; i < numvifs; i++) {
- /*
- * If we're not sending on this vif,
- * And this group isn't scoped on this vif,
- * And I'm the parent for this route on this vif,
- * And there are subordinates on this vif,
- * And all of the subordinates haven't pruned,
- * YELL LOUDLY
- * and remember to fix it up later
- */
- if (!VIFM_ISSET(i, gt->gt_grpmems) &&
- !VIFM_ISSET(i, gt->gt_scope) &&
- VIFM_ISSET(i, r->rt_children) &&
- NBRM_ISSETMASK(uvifs[i].uv_nbrmap, r->rt_subordinates) &&
- !SUBS_ARE_PRUNED(r->rt_subordinates, uvifs[i].uv_nbrmap, gt->gt_prunes)) {
- log(LOG_WARNING, 0, "(%s %s) is blackholing on vif %d",
- RT_FMT(r, s1), inet_fmt(gt->gt_mcastgrp, s2), i);
- fixit = 1;
- }
- }
- if (fixit) {
- log(LOG_WARNING, 0, "fixing membership for (%s %s) gm:%x",
- RT_FMT(r, s1), inet_fmt(gt->gt_mcastgrp, s2), gt->gt_grpmems);
- determine_forwvifs(gt);
- send_prune_or_graft(gt);
- log(LOG_WARNING, 0, "fixed membership for (%s %s) gm:%x",
- RT_FMT(r, s1), inet_fmt(gt->gt_mcastgrp, s2), gt->gt_grpmems);
-#ifdef RINGBUFFER
- printringbuf();
-#endif
- }
- /*DEBUG2*/
- /* If there are group members,
- * and there are recent sources,
- * and we have a route,
- * and it's not directly connected,
- * and we haven't sent a prune,
- * if there are any cache entries in the kernel
- * [if there aren't we're probably waiting to rexmit],
- * YELL LOUDLY
- * and send a prune
- */
- if (VIFM_ISEMPTY(gt->gt_grpmems) && gt->gt_srctbl && r && r->rt_gateway && gt->gt_prsent_timer == 0) {
- for (st = gt->gt_srctbl; st; st = st->st_next)
- if (st->st_ctime != 0)
- break;
- if (st != NULL) {
- log(LOG_WARNING, 0, "grpmems for (%s %s) is empty but no prune state!", RT_FMT(r, s1), inet_fmt(gt->gt_mcastgrp, s2));
- send_prune_or_graft(gt);
-#ifdef RINGBUFFER
- printringbuf();
-#endif
- }
- }
- /* XXX ...Debugging */
-
/* advance the timer for the kernel entry */
- gt->gt_timer -= TIMER_INTERVAL;
+ gt->gt_timer -= ROUTE_MAX_REPORT_DELAY;
/* decrement prune timer if need be */
if (gt->gt_prsent_timer > 0) {
- gt->gt_prsent_timer -= TIMER_INTERVAL;
+ gt->gt_prsent_timer -= ROUTE_MAX_REPORT_DELAY;
if (gt->gt_prsent_timer <= 0) {
- IF_DEBUG(DEBUG_PRUNE)
log(LOG_DEBUG, 0, "upstream prune tmo (%s %s)",
- RT_FMT(r, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(gt->gt_mcastgrp, s2));
gt->gt_prsent_timer = -1;
- /* Reset the prune retransmission timer to its initial value */
- gt->gt_prune_rexmit = PRUNE_REXMIT_VAL;
}
}
- /* retransmit graft with exponential backoff */
+ /* retransmit graft if graft sent flag is still set */
if (gt->gt_grftsnt) {
register int y;
-
- y = ++gt->gt_grftsnt;
- while (y && !(y & 1))
- y >>= 1;
- if (y == 1)
+ CHK_GS(gt->gt_grftsnt++, y);
+ if (y)
send_graft(gt);
}
@@ -1936,24 +1713,13 @@ age_table_entry()
*/
ptnp = &gt->gt_pruntbl;
while ((pt = *ptnp) != NULL) {
- if ((pt->pt_timer -= TIMER_INTERVAL) <= 0) {
- IF_DEBUG(DEBUG_PRUNE)
+ if ((pt->pt_timer -= ROUTE_MAX_REPORT_DELAY) <= 0) {
log(LOG_DEBUG, 0, "expire prune (%s %s) from %s on vif %d",
- RT_FMT(r, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(gt->gt_mcastgrp, s2),
inet_fmt(pt->pt_router, s3),
pt->pt_vifi);
- if (gt->gt_prsent_timer > 0) {
- log(LOG_WARNING, 0, "prune (%s %s) from %s on vif %d expires with %d left on prsent timer",
- RT_FMT(r, s1),
- inet_fmt(gt->gt_mcastgrp, s2),
- inet_fmt(pt->pt_router, s3),
- pt->pt_vifi, gt->gt_prsent_timer);
- /* Send a graft to heal the tree. */
- send_graft(gt);
- }
- NBRM_CLR(pt->pt_index, gt->gt_prunes);
expire_prune(pt->pt_vifi, gt);
/* remove the router's prune entry and await new one */
@@ -1971,47 +1737,31 @@ age_table_entry()
* Otherwise, the cache entry's timer is refreshed.
*/
if (gt->gt_timer <= 0) {
- IF_DEBUG(DEBUG_CACHE)
- log(LOG_DEBUG, 0, "(%s %s) timed out, checking for traffic",
- RT_FMT(gt->gt_route, s1),
- inet_fmt(gt->gt_mcastgrp, s2));
/* Check for traffic before deleting source entries */
sg_req.grp.s_addr = gt->gt_mcastgrp;
stnp = &gt->gt_srctbl;
while ((st = *stnp) != NULL) {
- /*
- * Source entries with no ctime are not actually in the
- * kernel; they have been removed by rexmit_prune() so
- * are safe to remove from the list at this point.
- */
- if (st->st_ctime) {
- sg_req.src.s_addr = st->st_origin;
- if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) < 0) {
- log(LOG_WARNING, errno, "%s (%s %s)",
- "age_table_entry: SIOCGETSGCNT failing for",
- inet_fmt(st->st_origin, s1),
- inet_fmt(gt->gt_mcastgrp, s2));
- /* Make sure it gets deleted below */
- sg_req.pktcnt = st->st_pktcnt;
- }
- } else {
+ sg_req.src.s_addr = st->st_origin;
+ if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) < 0) {
+ log(LOG_WARNING, errno, "%s (%s %s)",
+ "age_table_entry: SIOCGETSGCNT failing for",
+ inet_fmt(st->st_origin, s1),
+ inet_fmt(gt->gt_mcastgrp, s2));
+ /* Make sure it gets deleted below */
sg_req.pktcnt = st->st_pktcnt;
}
if (sg_req.pktcnt == st->st_pktcnt) {
*stnp = st->st_next;
- IF_DEBUG(DEBUG_CACHE)
log(LOG_DEBUG, 0, "age_table_entry deleting (%s %s)",
inet_fmt(st->st_origin, s1),
inet_fmt(gt->gt_mcastgrp, s2));
- if (st->st_ctime != 0) {
- if (k_del_rg(st->st_origin, gt) < 0) {
- log(LOG_WARNING, errno,
- "age_table_entry trying to delete (%s %s)",
- inet_fmt(st->st_origin, s1),
- inet_fmt(gt->gt_mcastgrp, s2));
- }
- kroutes--;
+ if (k_del_rg(st->st_origin, gt) < 0) {
+ log(LOG_WARNING, errno,
+ "age_table_entry trying to delete (%s %s)",
+ inet_fmt(st->st_origin, s1),
+ inet_fmt(gt->gt_mcastgrp, s2));
}
+ kroutes--;
free(st);
} else {
st->st_pktcnt = sg_req.pktcnt;
@@ -2022,39 +1772,22 @@ age_table_entry()
/*
* Retain the group entry if we have downstream prunes or if
* there is at least one source in the list that still has
- * traffic, or if our upstream prune timer or graft
- * retransmission timer is running.
+ * traffic, or if our upstream prune timer is running.
*/
if (gt->gt_pruntbl != NULL || gt->gt_srctbl != NULL ||
- gt->gt_prsent_timer > 0 || gt->gt_grftsnt > 0) {
- IF_DEBUG(DEBUG_CACHE)
- log(LOG_DEBUG, 0, "refresh lifetim of cache entry %s%s%s%s(%s, %s)",
- gt->gt_pruntbl ? "(dstrm prunes) " : "",
- gt->gt_srctbl ? "(trfc flow) " : "",
- gt->gt_prsent_timer > 0 ? "(upstrm prune) " : "",
- gt->gt_grftsnt > 0 ? "(grft rexmit) " : "",
- RT_FMT(r, s1),
- inet_fmt(gt->gt_mcastgrp, s2));
+ gt->gt_prsent_timer > 0) {
gt->gt_timer = CACHE_LIFETIME(cache_lifetime);
- if (gt->gt_prsent_timer == -1) {
- /*
- * The upstream prune timed out. Remove any kernel
- * state.
- */
- gt->gt_prsent_timer = 0;
- if (gt->gt_pruntbl) {
- log(LOG_WARNING, 0, "upstream prune for (%s %s) expires with downstream prunes active",
- RT_FMT(r, s1), inet_fmt(gt->gt_mcastgrp, s2));
- }
- remove_sources(gt);
- }
+ if (gt->gt_prsent_timer == -1)
+ if (gt->gt_grpmems == 0)
+ send_prune(gt);
+ else
+ gt->gt_prsent_timer = 0;
gtnptr = &gt->gt_gnext;
continue;
}
- IF_DEBUG(DEBUG_CACHE)
log(LOG_DEBUG, 0, "timeout cache entry (%s, %s)",
- RT_FMT(r, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(gt->gt_mcastgrp, s2));
if (gt->gt_prev)
@@ -2079,23 +1812,13 @@ age_table_entry()
rsrr_cache_send(gt,0);
rsrr_cache_clean(gt);
#endif /* RSRR */
- if (gt->gt_rexmit_timer)
- timer_clearTimer(gt->gt_rexmit_timer);
-
free((char *)gt);
} else {
- if (gt->gt_prsent_timer == -1) {
- /*
- * The upstream prune timed out. Remove any kernel
- * state.
- */
- gt->gt_prsent_timer = 0;
- if (gt->gt_pruntbl) {
- log(LOG_WARNING, 0, "upstream prune for (%s %s) expires with downstream prunes active",
- RT_FMT(r, s1), inet_fmt(gt->gt_mcastgrp, s2));
- }
- remove_sources(gt);
- }
+ if (gt->gt_prsent_timer == -1)
+ if (gt->gt_grpmems == 0)
+ send_prune(gt);
+ else
+ gt->gt_prsent_timer = 0;
gtnptr = &gt->gt_gnext;
}
}
@@ -2107,18 +1830,15 @@ age_table_entry()
gtnptr = &kernel_no_route;
while ((gt = *gtnptr) != NULL) {
/* advance the timer for the kernel entry */
- gt->gt_timer -= TIMER_INTERVAL;
+ gt->gt_timer -= ROUTE_MAX_REPORT_DELAY;
if (gt->gt_timer < 0) {
if (gt->gt_srctbl) {
- if (gt->gt_srctbl->st_ctime != 0) {
- if (k_del_rg(gt->gt_srctbl->st_origin, gt) < 0) {
- log(LOG_WARNING, errno, "%s (%s %s)",
- "age_table_entry trying to delete no-route",
- inet_fmt(gt->gt_srctbl->st_origin, s1),
- inet_fmt(gt->gt_mcastgrp, s2));
- }
- kroutes--;
+ if (k_del_rg(gt->gt_srctbl->st_origin, gt) < 0) {
+ log(LOG_WARNING, errno, "%s (%s %s)",
+ "age_table_entry trying to delete no-route",
+ inet_fmt(gt->gt_srctbl->st_origin, s1),
+ inet_fmt(gt->gt_mcastgrp, s2));
}
free(gt->gt_srctbl);
}
@@ -2126,9 +1846,6 @@ age_table_entry()
if (gt->gt_next)
gt->gt_next->gt_prev = gt->gt_prev;
- if (gt->gt_rexmit_timer)
- timer_clearTimer(gt->gt_rexmit_timer);
-
free((char *)gt);
} else {
gtnptr = &gt->gt_next;
@@ -2149,24 +1866,19 @@ expire_prune(vifi, gt)
/*
* No need to send a graft, any prunes that we sent
* will expire before any prunes that we have received.
- * However, in the case that we did make a mistake,
- * send a graft to compensate.
*/
- if (gt->gt_prsent_timer >= MIN_PRUNE_LIFE) {
- IF_DEBUG(DEBUG_PRUNE)
+ if (gt->gt_prsent_timer > 0) {
log(LOG_DEBUG, 0, "prune expired with %d left on %s",
gt->gt_prsent_timer, "prsent_timer");
gt->gt_prsent_timer = 0;
- send_graft(gt);
}
/* modify the kernel entry to forward packets */
if (!VIFM_ISSET(vifi, gt->gt_grpmems)) {
struct rtentry *rt = gt->gt_route;
VIFM_SET(vifi, gt->gt_grpmems);
- IF_DEBUG(DEBUG_CACHE)
log(LOG_DEBUG, 0, "forw again (%s %s) gm:%x vif:%d",
- RT_FMT(rt, s1),
+ inet_fmts(rt->rt_origin, rt->rt_originmask, s1),
inet_fmt(gt->gt_mcastgrp, s2), gt->gt_grpmems, vifi);
prun_add_ttls(gt);
@@ -2178,6 +1890,46 @@ expire_prune(vifi, gt)
}
}
+
+static char *
+scaletime(t)
+ u_long t;
+{
+ static char buf1[5];
+ static char buf2[5];
+ static char *buf=buf1;
+ char s;
+ char *p;
+
+ p = buf;
+ if (buf == buf1)
+ buf = buf2;
+ else
+ buf = buf1;
+
+ if (t < 120) {
+ s = 's';
+ } else if (t < 3600) {
+ t /= 60;
+ s = 'm';
+ } else if (t < 86400) {
+ t /= 3600;
+ s = 'h';
+ } else if (t < 864000) {
+ t /= 86400;
+ s = 'd';
+ } else {
+ t /= 604800;
+ s = 'w';
+ }
+ if (t > 999)
+ return "*** ";
+
+ sprintf(p,"%3d%c", (int)t, s);
+
+ return p;
+}
+
/*
* Print the contents of the cache table on file 'fp2'.
*/
@@ -2195,14 +1947,11 @@ dump_cache(fp2)
fprintf(fp2,
"Multicast Routing Cache Table (%d entries)\n%s", kroutes,
- " Origin Mcast-group CTmr Age Ptmr Rx IVif Forwvifs\n");
- fprintf(fp2,
- "<(prunesrc:vif[idx]/tmr) prunebitmap\n%s",
- ">Source Lifetime SavPkt Pkts Bytes RPFf\n");
+ " Origin Mcast-group CTmr Age Ptmr IVif Forwvifs\n");
for (gt = kernel_no_route; gt; gt = gt->gt_next) {
if (gt->gt_srctbl) {
- fprintf(fp2, " %-18s %-15s %-8s %-8s - -1 (no route)\n",
+ fprintf(fp2, " %-18s %-15s %-4s %-4s - -1\n",
inet_fmts(gt->gt_srctbl->st_origin, 0xffffffff, s1),
inet_fmt(gt->gt_mcastgrp, s2), scaletime(gt->gt_timer),
scaletime(thyme - gt->gt_ctime));
@@ -2213,78 +1962,40 @@ dump_cache(fp2)
for (gt = kernel_table; gt; gt = gt->gt_gnext) {
r = gt->gt_route;
fprintf(fp2, " %-18s %-15s",
- RT_FMT(r, s1),
+ inet_fmts(r->rt_origin, r->rt_originmask, s1),
inet_fmt(gt->gt_mcastgrp, s2));
- fprintf(fp2, " %-8s", scaletime(gt->gt_timer));
+ fprintf(fp2, " %-4s", scaletime(gt->gt_timer));
- fprintf(fp2, " %-8s %-8s ", scaletime(thyme - gt->gt_ctime),
+ fprintf(fp2, " %-4s %-4s ", scaletime(thyme - gt->gt_ctime),
gt->gt_prsent_timer ? scaletime(gt->gt_prsent_timer) :
- " -");
-
- if (gt->gt_prune_rexmit) {
- int i = gt->gt_prune_rexmit;
- int n = 0;
+ " -");
- while (i > PRUNE_REXMIT_VAL) {
- n++;
- i /= 2;
- }
- if (n == 0 && gt->gt_prsent_timer == 0)
- fprintf(fp2, " -");
- else
- fprintf(fp2, "%2d", n);
- } else {
- fprintf(fp2, " -");
- }
-
- fprintf(fp2, " %2u%c%c", r->rt_parent,
- gt->gt_prsent_timer ? 'P' :
- gt->gt_grftsnt ? 'G' : ' ',
+ fprintf(fp2, "%2u%c%c ", r->rt_parent,
+ gt->gt_prsent_timer ? 'P' : ' ',
VIFM_ISSET(r->rt_parent, gt->gt_scope) ? 'B' : ' ');
for (i = 0; i < numvifs; ++i) {
if (VIFM_ISSET(i, gt->gt_grpmems))
fprintf(fp2, " %u ", i);
else if (VIFM_ISSET(i, r->rt_children) &&
- NBRM_ISSETMASK(uvifs[i].uv_nbrmap, r->rt_subordinates))
+ !VIFM_ISSET(i, r->rt_leaves))
fprintf(fp2, " %u%c", i,
- VIFM_ISSET(i, gt->gt_scope) ? 'b' :
- SUBS_ARE_PRUNED(r->rt_subordinates,
- uvifs[i].uv_nbrmap, gt->gt_prunes) ? 'p' : '!');
+ VIFM_ISSET(i, gt->gt_scope) ? 'b' : 'p');
}
fprintf(fp2, "\n");
if (gt->gt_pruntbl) {
fprintf(fp2, "<");
c = '(';
for (pt = gt->gt_pruntbl; pt; pt = pt->pt_next) {
- fprintf(fp2, "%c%s:%d[%d]/%d", c, inet_fmt(pt->pt_router, s1),
- pt->pt_vifi, pt->pt_index, pt->pt_timer);
+ fprintf(fp2, "%c%s:%d/%d", c, inet_fmt(pt->pt_router, s1),
+ pt->pt_vifi, pt->pt_timer);
c = ',';
}
- fprintf(fp2, ")");
- fprintf(fp2, " 0x%08lx%08lx\n",/*XXX*/
- gt->gt_prunes.hi, gt->gt_prunes.lo);
+ fprintf(fp2, ")\n");
}
for (st = gt->gt_srctbl; st; st = st->st_next) {
- fprintf(fp2, ">%-18s %-8s %6ld", inet_fmt(st->st_origin, s1),
- st->st_ctime ? scaletime(thyme - st->st_ctime) : "-",
- st->st_savpkt);
- if (st->st_ctime) {
- struct sioc_sg_req sg_req;
-
- sg_req.src.s_addr = st->st_origin;
- sg_req.grp.s_addr = gt->gt_mcastgrp;
- if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) < 0) {
- log(LOG_WARNING, errno, "SIOCGETSGCNT on (%s %s)",
- inet_fmt(st->st_origin, s1),
- inet_fmt(gt->gt_mcastgrp, s2));
- } else {
- fprintf(fp2, " %8ld %8ld %4ld", sg_req.pktcnt,
- sg_req.bytecnt, sg_req.wrong_if);
- }
- }
- fprintf(fp2, "\n");
+ fprintf(fp2, ">%s\n", inet_fmt(st->st_origin, s1));
}
}
}
@@ -2327,17 +2038,14 @@ accept_mtrace(src, dst, group, data, no, datalen)
*/
if (datalen == QLEN) {
type = QUERY;
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Initial traceroute query rcvd from %s to %s",
inet_fmt(src, s1), inet_fmt(dst, s2));
}
else if ((datalen - QLEN) % RLEN == 0) {
type = RESP;
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "In-transit traceroute query rcvd from %s to %s",
inet_fmt(src, s1), inet_fmt(dst, s2));
if (IN_MULTICAST(ntohl(dst))) {
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Dropping multicast response");
return;
}
@@ -2355,27 +2063,23 @@ accept_mtrace(src, dst, group, data, no, datalen)
* if it is a packet with all reports filled, drop it
*/
if ((rcount = (datalen - QLEN)/RLEN) == no) {
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "packet with all reports filled in");
return;
}
- IF_DEBUG(DEBUG_TRACE) {
log(LOG_DEBUG, 0, "s: %s g: %s d: %s ", inet_fmt(qry->tr_src, s1),
inet_fmt(group, s2), inet_fmt(qry->tr_dst, s3));
log(LOG_DEBUG, 0, "rttl: %d rd: %s", qry->tr_rttl,
inet_fmt(qry->tr_raddr, s1));
log(LOG_DEBUG, 0, "rcount:%d, qid:%06x", rcount, qry->tr_qid);
- }
/* determine the routing table entry for this traceroute */
rt = determine_route(qry->tr_src);
- IF_DEBUG(DEBUG_TRACE)
if (rt) {
log(LOG_DEBUG, 0, "rt parent vif: %d rtr: %s metric: %d",
rt->rt_parent, inet_fmt(rt->rt_gateway, s1), rt->rt_metric);
log(LOG_DEBUG, 0, "rt origin %s",
- RT_FMT(rt, s1));
+ inet_fmts(rt->rt_origin, rt->rt_originmask, s1));
} else
log(LOG_DEBUG, 0, "...no route");
@@ -2396,13 +2100,11 @@ accept_mtrace(src, dst, group, data, no, datalen)
* only get N copies, N <= the number of interfaces on the router,
* it is not fatal.
*/
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "ignoring duplicate traceroute packet");
return;
}
if (rt == NULL) {
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Mcast traceroute: no route entry %s",
inet_fmt(qry->tr_src, s1));
if (IN_MULTICAST(ntohl(dst)))
@@ -2412,14 +2114,12 @@ accept_mtrace(src, dst, group, data, no, datalen)
if (vifi == NO_VIF) {
/* The traceroute destination is not on one of my subnet vifs. */
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Destination %s not an interface",
inet_fmt(qry->tr_dst, s1));
if (IN_MULTICAST(ntohl(dst)))
return;
errcode = TR_WRONG_IF;
} else if (rt != NULL && !VIFM_ISSET(vifi, rt->rt_children)) {
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Destination %s not on forwarding tree for src %s",
inet_fmt(qry->tr_dst, s1), inet_fmt(qry->tr_src, s2));
if (IN_MULTICAST(ntohl(dst)))
@@ -2434,7 +2134,6 @@ accept_mtrace(src, dst, group, data, no, datalen)
* a tunnel or came from a directly attached mrouter.
*/
if ((vifi = find_vif(src, dst)) == NO_VIF) {
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Wrong interface for packet");
errcode = TR_WRONG_IF;
}
@@ -2443,7 +2142,6 @@ accept_mtrace(src, dst, group, data, no, datalen)
/* Now that we've decided to send a response, save the qid */
oqid = qry->tr_qid;
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Sending traceroute response");
/* copy the packet to the sending buffer */
@@ -2475,18 +2173,21 @@ accept_mtrace(src, dst, group, data, no, datalen)
((tp.tv_usec << 10) / 15625));
resp->tr_rproto = PROTO_DVMRP;
- resp->tr_outaddr = (vifi == NO_VIF) ? dst : uvifs[vifi].uv_lcl_addr;
- resp->tr_fttl = (vifi == NO_VIF) ? 0 : uvifs[vifi].uv_threshold;
- resp->tr_rflags = errcode;
+ if (errcode != TR_NO_ERR) {
+ resp->tr_rflags = errcode;
+ rt = NULL; /* hack to enforce send straight to requestor */
+ goto sendit;
+ }
+ resp->tr_outaddr = uvifs[vifi].uv_lcl_addr;
+ resp->tr_fttl = uvifs[vifi].uv_threshold;
+ resp->tr_rflags = TR_NO_ERR;
/*
* obtain # of packets out on interface
*/
v_req.vifi = vifi;
- if (vifi != NO_VIF && ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) >= 0)
+ if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) >= 0)
resp->tr_vifout = htonl(v_req.ocount);
- else
- resp->tr_vifout = 0xffffffff;
/*
* fill in scoping & pruning information
@@ -2500,34 +2201,23 @@ accept_mtrace(src, dst, group, data, no, datalen)
gt = NULL;
if (gt && gt->gt_mcastgrp == group) {
- struct stable *st;
-
- for (st = gt->gt_srctbl; st; st = st->st_next)
- if (qry->tr_src == st->st_origin)
- break;
-
sg_req.src.s_addr = qry->tr_src;
sg_req.grp.s_addr = group;
- if (st && st->st_ctime != 0 &&
- ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) >= 0)
- resp->tr_pktcnt = htonl(sg_req.pktcnt + st->st_savpkt);
- else
- resp->tr_pktcnt = htonl(st ? st->st_savpkt : 0xffffffff);
+ if (ioctl(udp_socket, SIOCGETSGCNT, (char *)&sg_req) >= 0)
+ resp->tr_pktcnt = htonl(sg_req.pktcnt);
if (VIFM_ISSET(vifi, gt->gt_scope))
resp->tr_rflags = TR_SCOPED;
else if (gt->gt_prsent_timer)
resp->tr_rflags = TR_PRUNED;
else if (!VIFM_ISSET(vifi, gt->gt_grpmems))
- if (!NBRM_ISEMPTY(uvifs[vifi].uv_nbrmap) &&
- SUBS_ARE_PRUNED(rt->rt_subordinates,
- uvifs[vifi].uv_nbrmap, gt->gt_prunes))
+ if (VIFM_ISSET(vifi, rt->rt_children) &&
+ !VIFM_ISSET(vifi, rt->rt_leaves))
resp->tr_rflags = TR_OPRUNED;
else
resp->tr_rflags = TR_NO_FWD;
} else {
- if ((vifi != NO_VIF && scoped_addr(vifi, group)) ||
- (rt && scoped_addr(rt->rt_parent, group)))
+ if (scoped_addr(vifi, group))
resp->tr_rflags = TR_SCOPED;
else if (rt && !VIFM_ISSET(vifi, rt->rt_children))
resp->tr_rflags = TR_NO_FWD;
@@ -2546,15 +2236,12 @@ accept_mtrace(src, dst, group, data, no, datalen)
v_req.vifi = rt->rt_parent;
if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) >= 0)
resp->tr_vifin = htonl(v_req.icount);
- else
- resp->tr_vifin = 0xffffffff;
MASK_TO_VAL(rt->rt_originmask, resp->tr_smask);
src = uvifs[rt->rt_parent].uv_lcl_addr;
resp->tr_inaddr = src;
resp->tr_rmtaddr = rt->rt_gateway;
if (!VIFM_ISSET(vifi, rt->rt_children)) {
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Destination %s not on forwarding tree for src %s",
inet_fmt(qry->tr_dst, s1), inet_fmt(qry->tr_src, s2));
resp->tr_rflags = TR_WRONG_IF;
@@ -2572,7 +2259,6 @@ sendit:
* else send to upstream router. If the upstream router can't handle
* mtrace, set an error code and send to requestor anyway.
*/
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "rcount:%d, no:%d", rcount, no);
if ((rcount + 1 == no) || (rt == NULL) || (rt->rt_metric == 1)) {
@@ -2594,7 +2280,6 @@ sendit:
* If we don't have one, we can't source any multicasts anyway.
*/
if (phys_vif != -1) {
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Sending reply to %s from %s",
inet_fmt(dst, s1), inet_fmt(uvifs[phys_vif].uv_lcl_addr, s2));
k_set_ttl(qry->tr_rttl);
@@ -2606,7 +2291,6 @@ sendit:
log(LOG_INFO, 0, "No enabled phyints -- %s",
"dropping traceroute reply");
} else {
- IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Sending %s to %s from %s",
resptype == IGMP_MTRACE_RESP ? "reply" : "request on",
inet_fmt(dst, s1), inet_fmt(src, s2));
diff --git a/usr.sbin/mrouted/prune.h b/usr.sbin/mrouted/prune.h
index dbc232f6385b..c007ed31d6fa 100644
--- a/usr.sbin/mrouted/prune.h
+++ b/usr.sbin/mrouted/prune.h
@@ -7,8 +7,7 @@
* Leland Stanford Junior University.
*
*
- * $Id: prune.h,v 1.8 1997/02/22 16:07:04 peter Exp $
- * prune.h,v 3.8.4.5 1998/02/27 22:45:43 fenner Exp
+ * $Id$
*/
/*
@@ -33,14 +32,11 @@ struct gtable {
vifbitmap_t gt_grpmems; /* forw. vifs for src, grp */
int gt_prsent_timer; /* prune timer for this group */
int gt_timer; /* timer for this group entry */
- time_t gt_ctime; /* time of entry creation */
+ time_t gt_ctime; /* time of entry creation */
u_char gt_grftsnt; /* graft sent/retransmit timer */
- nbrbitmap_t gt_prunes; /* bitmap of neighbors who pruned */
struct stable *gt_srctbl; /* source table */
struct ptable *gt_pruntbl; /* prune table */
struct rtentry *gt_route; /* parent route */
- int gt_rexmit_timer; /* timer for prune retransmission */
- int gt_prune_rexmit; /* time til prune retransmission */
#ifdef RSRR
struct rsrr_cache *gt_rsrr_cache; /* RSRR cache */
#endif /* RSRR */
@@ -56,8 +52,6 @@ struct stable
struct stable *st_next; /* pointer to the next entry */
u_int32 st_origin; /* host origin of multicasts */
u_long st_pktcnt; /* packet count for src-grp entry */
- u_long st_savpkt; /* saved pkt cnt when no krnl entry */
- time_t st_ctime; /* kernel entry creation time */
};
/*
@@ -68,12 +62,9 @@ struct ptable
struct ptable *pt_next; /* pointer to the next entry */
u_int32 pt_router; /* router that sent this prune */
vifi_t pt_vifi; /* vif prune received on */
- int pt_index; /* neighbor index of router */
int pt_timer; /* timer for prune */
};
-#define MIN_PRUNE_LIFE TIMER_INTERVAL /* min prune lifetime to bother with */
-
/*
* The packet format for a traceroute request.
*/
@@ -146,7 +137,7 @@ struct tr_resp {
};
#define VAL_TO_MASK(x, i) { \
- x = i ? htonl(~((1 << (32 - (i))) - 1)) : 0; \
+ x = htonl(~((1 << (32 - (i))) - 1)); \
};
#define NBR_VERS(n) (((n)->al_pv << 8) + (n)->al_mv)
diff --git a/usr.sbin/mrouted/route.c b/usr.sbin/mrouted/route.c
index ff59a237095c..1e26fb5acfe5 100644
--- a/usr.sbin/mrouted/route.c
+++ b/usr.sbin/mrouted/route.c
@@ -5,14 +5,11 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
- *
- *
- * route.c,v 3.8.4.41 1998/01/15 00:08:34 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: route.c,v 1.10 1998/01/16 07:17:45 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#include "defs.h"
@@ -45,89 +42,13 @@ unsigned int nroutes; /* current number of route entries */
* Private functions.
*/
static int init_children_and_leaves __P((struct rtentry *r,
- vifi_t parent, int first));
+ vifi_t parent));
static int find_route __P((u_int32 origin, u_int32 mask));
static void create_route __P((u_int32 origin, u_int32 mask));
static void discard_route __P((struct rtentry *prev_r));
static int compare_rts __P((const void *rt1, const void *rt2));
-static int report_chunk __P((int, struct rtentry *start_rt, vifi_t vifi,
+static int report_chunk __P((struct rtentry *start_rt, vifi_t vifi,
u_int32 dst));
-static void queue_blaster_report __P((vifi_t, u_int32, u_int32, char *,
- int, u_int32));
-static void process_blaster_report __P((void *));
-
-#ifdef SNMP
-#include <sys/types.h>
-#include "snmp.h"
-
-/*
- * Return pointer to a specific route entry. This must be a separate
- * function from find_route() which modifies rtp.
- */
-struct rtentry *
-snmp_find_route(src, mask)
- register u_int32 src, mask;
-{
- register struct rtentry *rt;
-
- for (rt = routing_table; rt; rt = rt->rt_next) {
- if (src == rt->rt_origin && mask == rt->rt_originmask)
- return rt;
- }
- return NULL;
-}
-
-/*
- * Find next route entry > specification
- */
-int
-next_route(rtpp, src, mask)
- struct rtentry **rtpp;
- u_int32 src;
- u_int32 mask;
-{
- struct rtentry *rt, *rbest = NULL;
-
- /* Among all entries > spec, find "lowest" one in order */
- for (rt = routing_table; rt; rt=rt->rt_next) {
- if ((ntohl(rt->rt_origin) > ntohl(src)
- || (ntohl(rt->rt_origin) == ntohl(src)
- && ntohl(rt->rt_originmask) > ntohl(mask)))
- && (!rbest || (ntohl(rt->rt_origin) < ntohl(rbest->rt_origin))
- || (ntohl(rt->rt_origin) == ntohl(rbest->rt_origin)
- && ntohl(rt->rt_originmask) < ntohl(rbest->rt_originmask))))
- rbest = rt;
- }
- (*rtpp) = rbest;
- return (*rtpp)!=0;
-}
-
-/*
- * Given a routing table entry, and a vifi, find the next vifi/entry
- */
-int
-next_route_child(rtpp, src, mask, vifi)
- struct rtentry **rtpp;
- u_int32 src;
- u_int32 mask;
- vifi_t *vifi; /* vif at which to start looking */
-{
- /* Get (S,M) entry */
- if (!((*rtpp) = snmp_find_route(src,mask)))
- if (!next_route(rtpp, src, mask))
- return 0;
-
- /* Continue until we get one with a valid next vif */
- do {
- for (; (*rtpp)->rt_children && *vifi<numvifs; (*vifi)++)
- if (VIFM_ISSET(*vifi, (*rtpp)->rt_children))
- return 1;
- *vifi = 0;
- } while( next_route(rtpp, (*rtpp)->rt_origin, (*rtpp)->rt_originmask) );
-
- return 0;
-}
-#endif
/*
* Initialize the routing table and associated variables.
@@ -144,50 +65,54 @@ init_routes()
/*
- * Initialize the children bits for route 'r', along with the
- * associated dominant and subordinate data structures.
- * If first is set, initialize dominants, otherwise keep old
- * dominants on non-parent interfaces.
- * XXX Does this need a return value?
+ * Initialize the children and leaf bits for route 'r', along with the
+ * associated dominant, subordinate, and leaf timing data structures.
+ * Return TRUE if this changes the value of either the children or
+ * leaf bitmaps for 'r'.
*/
static int
-init_children_and_leaves(r, parent, first)
+init_children_and_leaves(r, parent)
register struct rtentry *r;
register vifi_t parent;
- int first;
{
register vifi_t vifi;
register struct uvif *v;
- vifbitmap_t old_children;
- nbrbitmap_t old_subords;
+ vifbitmap_t old_children, old_leaves;
VIFM_COPY(r->rt_children, old_children);
- NBRM_COPY(r->rt_subordinates, old_subords);
+ VIFM_COPY(r->rt_leaves, old_leaves );
VIFM_CLRALL(r->rt_children);
+ VIFM_CLRALL(r->rt_leaves);
+ r->rt_flags &= ~RTF_LEAF_TIMING;
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
- if (first || vifi == parent)
- r->rt_dominants [vifi] = 0;
- if (vifi == parent || uvifs[vifi].uv_flags & VIFF_NOFLOOD ||
- AVOID_TRANSIT(vifi, r) || (!first && r->rt_dominants[vifi]))
- NBRM_CLRMASK(r->rt_subordinates, uvifs[vifi].uv_nbrmap);
- else
- NBRM_SETMASK(r->rt_subordinates, uvifs[vifi].uv_nbrmap);
+ r->rt_dominants [vifi] = 0;
+ r->rt_subordinates[vifi] = 0;
- if (vifi != parent && !(v->uv_flags & (VIFF_DOWN|VIFF_DISABLED)) &&
- !(!first && r->rt_dominants[vifi])) {
+ if (vifi != parent && !(v->uv_flags & (VIFF_DOWN|VIFF_DISABLED))) {
VIFM_SET(vifi, r->rt_children);
+ if (v->uv_neighbors == NULL) {
+ VIFM_SET(vifi, r->rt_leaves);
+ r->rt_leaf_timers[vifi] = 0;
+ }
+ else {
+ r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME;
+ r->rt_flags |= RTF_LEAF_TIMING;
+ }
+ }
+ else {
+ r->rt_leaf_timers[vifi] = 0;
}
}
return (!VIFM_SAME(r->rt_children, old_children) ||
- !NBRM_SAME(r->rt_subordinates, old_subords));
+ !VIFM_SAME(r->rt_leaves, old_leaves));
}
/*
- * A new vif has come up -- update the children bitmaps in all route
+ * A new vif has come up -- update the children and leaf bitmaps in all route
* entries to take that into account.
*/
void
@@ -203,9 +128,17 @@ add_vif_to_routes(vifi)
!VIFM_ISSET(vifi, r->rt_children)) {
VIFM_SET(vifi, r->rt_children);
r->rt_dominants [vifi] = 0;
- /*XXX isn't uv_nbrmap going to be empty?*/
- NBRM_CLRMASK(r->rt_subordinates, v->uv_nbrmap);
- update_table_entry(r, r->rt_gateway);
+ r->rt_subordinates[vifi] = 0;
+ if (v->uv_neighbors == NULL) {
+ VIFM_SET(vifi, r->rt_leaves);
+ r->rt_leaf_timers[vifi] = 0;
+ }
+ else {
+ VIFM_CLR(vifi, r->rt_leaves);
+ r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME;
+ r->rt_flags |= RTF_LEAF_TIMING;
+ }
+ update_table_entry(r);
}
}
}
@@ -233,8 +166,10 @@ delete_vif_from_routes(vifi)
}
else if (VIFM_ISSET(vifi, r->rt_children)) {
VIFM_CLR(vifi, r->rt_children);
- NBRM_CLRMASK(r->rt_subordinates, uvifs[vifi].uv_nbrmap);
- update_table_entry(r, r->rt_gateway);
+ VIFM_CLR(vifi, r->rt_leaves);
+ r->rt_subordinates[vifi] = 0;
+ r->rt_leaf_timers [vifi] = 0;
+ update_table_entry(r);
}
else {
r->rt_dominants[vifi] = 0;
@@ -245,42 +180,14 @@ delete_vif_from_routes(vifi)
/*
- * A new neighbor has come up. If we're flooding on the neighbor's
- * vif, mark that neighbor as subordinate for all routes whose parent
- * is not this vif.
- */
-void
-add_neighbor_to_routes(vifi, index)
- register vifi_t vifi;
- register int index;
-{
- register struct rtentry *r;
- register struct uvif *v;
-
- v = &uvifs[vifi];
- if (v->uv_flags & VIFF_NOFLOOD)
- return;
- for (r = routing_table; r != NULL; r = r->rt_next) {
- if (r->rt_metric != UNREACHABLE && r->rt_parent != vifi &&
- !AVOID_TRANSIT(vifi, r)) {
- NBRM_SET(index, r->rt_subordinates);
- update_table_entry(r, r->rt_gateway);
- }
- }
-}
-
-
-/*
* A neighbor has failed or become unreachable. If that neighbor was
* considered a dominant or subordinate router in any route entries,
- * take appropriate action. Expire all routes this neighbor advertised
- * to us.
+ * take appropriate action.
*/
void
-delete_neighbor_from_routes(addr, vifi, index)
+delete_neighbor_from_routes(addr, vifi)
register u_int32 addr;
register vifi_t vifi;
- int index;
{
register struct rtentry *r;
register struct uvif *v;
@@ -288,24 +195,37 @@ delete_neighbor_from_routes(addr, vifi, index)
v = &uvifs[vifi];
for (r = routing_table; r != NULL; r = r->rt_next) {
if (r->rt_metric != UNREACHABLE) {
- if (r->rt_parent == vifi && r->rt_gateway == addr) {
- del_table_entry(r, 0, DEL_ALL_ROUTES);
- r->rt_timer = ROUTE_EXPIRE_TIME;
- r->rt_metric = UNREACHABLE;
- r->rt_flags |= RTF_CHANGED;
- routes_changed = TRUE;
- } else if (r->rt_dominants[vifi] == addr) {
+ if (r->rt_dominants[vifi] == addr) {
VIFM_SET(vifi, r->rt_children);
- r->rt_dominants[vifi] = 0;
- if ((uvifs[vifi].uv_flags & VIFF_NOFLOOD) ||
- AVOID_TRANSIT(vifi, r))
- NBRM_CLRMASK(r->rt_subordinates, uvifs[vifi].uv_nbrmap);
- else
- NBRM_SETMASK(r->rt_subordinates, uvifs[vifi].uv_nbrmap);
- update_table_entry(r, r->rt_gateway);
- } else if (NBRM_ISSET(index, r->rt_subordinates)) {
- NBRM_CLR(index, r->rt_subordinates);
- update_table_entry(r, r->rt_gateway);
+ r->rt_dominants [vifi] = 0;
+ r->rt_subordinates[vifi] = 0;
+ if (v->uv_neighbors == NULL) {
+ VIFM_SET(vifi, r->rt_leaves);
+ r->rt_leaf_timers[vifi] = 0;
+ }
+ else {
+ VIFM_CLR(vifi, r->rt_leaves);
+ r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME;
+ r->rt_flags |= RTF_LEAF_TIMING;
+ }
+ update_table_entry(r);
+ }
+ else if (r->rt_subordinates[vifi] == addr) {
+ r->rt_subordinates[vifi] = 0;
+ if (v->uv_neighbors == NULL) {
+ VIFM_SET(vifi, r->rt_leaves);
+ update_table_entry(r);
+ }
+ else {
+ r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME;
+ r->rt_flags |= RTF_LEAF_TIMING;
+ }
+ }
+ else if (v->uv_neighbors == NULL &&
+ r->rt_leaf_timers[vifi] != 0) {
+ VIFM_SET(vifi, r->rt_leaves);
+ r->rt_leaf_timers[vifi] = 0;
+ update_table_entry(r);
}
}
}
@@ -376,7 +296,8 @@ create_route(origin, mask)
register struct rtentry *r;
if ((r = (struct rtentry *) malloc(sizeof(struct rtentry) +
- (numvifs * sizeof(u_int32)))) == NULL) {
+ (2 * numvifs * sizeof(u_int32)) +
+ (numvifs * sizeof(u_int)))) == NULL) {
log(LOG_ERR, 0, "ran out of memory"); /* fatal */
}
r->rt_origin = origin;
@@ -387,11 +308,9 @@ create_route(origin, mask)
else r->rt_originwidth = 1;
r->rt_flags = 0;
r->rt_dominants = (u_int32 *)(r + 1);
- bzero(r->rt_dominants, numvifs * sizeof(u_int32));
+ r->rt_subordinates = (u_int32 *)(r->rt_dominants + numvifs);
+ r->rt_leaf_timers = (u_int *)(r->rt_subordinates + numvifs);
r->rt_groups = NULL;
- VIFM_CLRALL(r->rt_children);
- NBRM_CLRALL(r->rt_subordinates);
- NBRM_CLRALL(r->rt_subordadv);
r->rt_next = rtp->rt_next;
rtp->rt_next = r;
@@ -415,8 +334,6 @@ discard_route(prev_r)
register struct rtentry *r;
r = prev_r->rt_next;
- uvifs[r->rt_parent].uv_nroutes--;
- /*???nbr???.al_nroutes--;*/
prev_r->rt_next = r->rt_next;
if (prev_r->rt_next != NULL)
(prev_r->rt_next)->rt_prev = prev_r;
@@ -434,12 +351,11 @@ discard_route(prev_r)
* to indicate a change of status of one of our own interfaces.
*/
void
-update_route(origin, mask, metric, src, vifi, n)
+update_route(origin, mask, metric, src, vifi)
u_int32 origin, mask;
u_int metric;
u_int32 src;
vifi_t vifi;
- struct listaddr *n;
{
register struct rtentry *r;
u_int adj_metric;
@@ -477,17 +393,18 @@ update_route(origin, mask, metric, src, vifi, n)
return;
}
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s advertises new route %s",
- inet_fmt(src, s1), inet_fmts(origin, mask, s2));
-
/*
* OK, create the new routing entry. 'rtp' will be left pointing
* to the new entry.
*/
create_route(origin, mask);
- uvifs[vifi].uv_nroutes++;
- /*n->al_nroutes++;*/
+
+ /*
+ * Now "steal away" any sources that belong under this route
+ * by deleting any cache entries they might have created
+ * and allowing the kernel to re-request them.
+ */
+ steal_sources(rtp);
rtp->rt_metric = UNREACHABLE; /* temporary; updated below */
}
@@ -505,32 +422,15 @@ update_route(origin, mask, metric, src, vifi, n)
if (adj_metric == UNREACHABLE)
return;
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s advertises %s with adj_metric %d (ours was %d)",
- inet_fmt(src, s1), inet_fmts(origin, mask, s2),
- adj_metric, r->rt_metric);
-
- /*
- * Now "steal away" any sources that belong under this route
- * by deleting any cache entries they might have created
- * and allowing the kernel to re-request them.
- *
- * If we haven't performed final initialization yet and are
- * just collecting the routing table, we can't have any
- * sources so we don't perform this step.
- */
- if (did_final_init)
- steal_sources(rtp);
-
r->rt_parent = vifi;
- r->rt_gateway = src;
- init_children_and_leaves(r, vifi, 1);
+ init_children_and_leaves(r, vifi);
+ r->rt_gateway = src;
r->rt_timer = 0;
r->rt_metric = adj_metric;
r->rt_flags |= RTF_CHANGED;
routes_changed = TRUE;
- update_table_entry(r, r->rt_gateway);
+ update_table_entry(r);
}
else if (src == r->rt_gateway) {
/*
@@ -542,12 +442,6 @@ update_route(origin, mask, metric, src, vifi, n)
* our entry accordingly.
*/
r->rt_timer = 0;
-
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s (current parent) advertises %s with adj_metric %d (ours was %d)",
- inet_fmt(src, s1), inet_fmts(origin, mask, s2),
- adj_metric, r->rt_metric);
-
if (adj_metric == r->rt_metric)
return;
@@ -555,6 +449,11 @@ update_route(origin, mask, metric, src, vifi, n)
del_table_entry(r, 0, DEL_ALL_ROUTES);
r->rt_timer = ROUTE_EXPIRE_TIME;
}
+ else if (adj_metric < r->rt_metric) {
+ if (init_children_and_leaves(r, vifi)) {
+ update_table_entry(r);
+ }
+ }
r->rt_metric = adj_metric;
r->rt_flags |= RTF_CHANGED;
routes_changed = TRUE;
@@ -580,29 +479,16 @@ update_route(origin, mask, metric, src, vifi, n)
* IP address than the gateway associated with the route entry.
* Did you get all that?
*/
- u_int32 old_gateway;
- vifi_t old_parent;
- old_gateway = r->rt_gateway;
- old_parent = r->rt_parent;
- r->rt_gateway = src;
- r->rt_parent = vifi;
-
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s (new parent) on vif %d advertises %s with adj_metric %d (old parent was %s on vif %d, metric %d)",
- inet_fmt(src, s1), vifi, inet_fmts(origin, mask, s2),
- adj_metric, inet_fmt(old_gateway, s3), old_parent,
- r->rt_metric);
-
- if (old_parent != vifi) {
- init_children_and_leaves(r, vifi, 0);
- uvifs[old_parent].uv_nroutes--;
- uvifs[vifi].uv_nroutes++;
- }
- if (old_gateway != src) {
- update_table_entry(r, old_gateway);
- /*???old_gateway???->al_nroutes--;*/
- /*n->al_nroutes++;*/
+ if (r->rt_parent != vifi || adj_metric < r->rt_metric) {
+ /*
+ * XXX Why do we do this if we are just changing the metric?
+ */
+ r->rt_parent = vifi;
+ if (init_children_and_leaves(r, vifi)) {
+ update_table_entry(r);
+ }
}
+ r->rt_gateway = src;
r->rt_timer = 0;
r->rt_metric = adj_metric;
r->rt_flags |= RTF_CHANGED;
@@ -611,18 +497,9 @@ update_route(origin, mask, metric, src, vifi, n)
else if (vifi != r->rt_parent) {
/*
* The report came from a vif other than the route's parent vif.
- * Update the children info, if necessary.
+ * Update the children and leaf info, if necessary.
*/
- if (AVOID_TRANSIT(vifi, r)) {
- /*
- * The route's parent is a vif from which we're not supposed
- * to transit onto this vif. Simply ignore the update.
- */
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s on vif %d advertises %s with metric %d (ignored due to NOTRANSIT)",
- inet_fmt(src, s1), vifi, inet_fmts(origin, mask, s2),
- metric);
- } else if (VIFM_ISSET(vifi, r->rt_children)) {
+ if (VIFM_ISSET(vifi, r->rt_children)) {
/*
* Vif is a child vif for this route.
*/
@@ -635,51 +512,42 @@ update_route(origin, mask, metric, src, vifi, n)
* and vif is no longer a child for me.
*/
VIFM_CLR(vifi, r->rt_children);
+ VIFM_CLR(vifi, r->rt_leaves);
r->rt_dominants [vifi] = src;
- /* XXX
- * We don't necessarily want to forget about subordinateness
- * so that we can become the dominant quickly if the current
- * dominant fails.
- */
- NBRM_CLRMASK(r->rt_subordinates, uvifs[vifi].uv_nbrmap);
- update_table_entry(r, r->rt_gateway);
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s on vif %d becomes dominant for %s with metric %d",
- inet_fmt(src, s1), vifi, inet_fmts(origin, mask, s2),
- metric);
+ r->rt_subordinates[vifi] = 0;
+ r->rt_leaf_timers [vifi] = 0;
+ update_table_entry(r);
}
else if (metric > UNREACHABLE) { /* "poisoned reverse" */
/*
* Neighbor considers this vif to be on path to route's
- * origin; record this neighbor as subordinate
+ * origin; if no subordinate recorded, record this neighbor
+ * as subordinate and clear the leaf flag.
*/
- if (!NBRM_ISSET(n->al_index, r->rt_subordinates)) {
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s on vif %d becomes subordinate for %s with poison-reverse metric %d",
- inet_fmt(src, s1), vifi, inet_fmts(origin, mask, s2),
- metric - UNREACHABLE);
- NBRM_SET(n->al_index, r->rt_subordinates);
- update_table_entry(r, r->rt_gateway);
- } else {
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s on vif %d confirms subordinateness for %s with poison-reverse metric %d",
- inet_fmt(src, s1), vifi, inet_fmts(origin, mask, s2),
- metric - UNREACHABLE);
+ if (r->rt_subordinates[vifi] == 0) {
+ VIFM_CLR(vifi, r->rt_leaves);
+ r->rt_subordinates[vifi] = src;
+ r->rt_leaf_timers [vifi] = 0;
+ update_table_entry(r);
}
- NBRM_SET(n->al_index, r->rt_subordadv);
}
- else if (NBRM_ISSET(n->al_index, r->rt_subordinates)) {
+ else if (src == r->rt_subordinates[vifi]) {
/*
* Current subordinate no longer considers this vif to be on
* path to route's origin; it is no longer a subordinate
- * router.
+ * router, and we set the leaf confirmation timer to give
+ * us time to hear from other subordinates.
*/
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s on vif %d is no longer a subordinate for %s with metric %d",
- inet_fmt(src, s1), vifi, inet_fmts(origin, mask, s2),
- metric);
- NBRM_CLR(n->al_index, r->rt_subordinates);
- update_table_entry(r, r->rt_gateway);
+ r->rt_subordinates[vifi] = 0;
+ if (uvifs[vifi].uv_neighbors == NULL ||
+ uvifs[vifi].uv_neighbors->al_next == NULL) {
+ VIFM_SET(vifi, r->rt_leaves);
+ update_table_entry(r);
+ }
+ else {
+ r->rt_leaf_timers [vifi] = LEAF_CONFIRMATION_TIME;
+ r->rt_flags |= RTF_LEAF_TIMING;
+ }
}
}
@@ -692,26 +560,20 @@ update_route(origin, mask, metric, src, vifi, n)
* (or same metric and lower IP address); we adopt the vif
* as our own child.
*/
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s (current dominant) on vif %d is no longer dominant for %s with metric %d",
- inet_fmt(src, s1), vifi, inet_fmts(origin, mask, s2),
- metric);
VIFM_SET(vifi, r->rt_children);
- r->rt_dominants[vifi] = 0;
- if (uvifs[vifi].uv_flags & VIFF_NOFLOOD)
- NBRM_CLRMASK(r->rt_subordinates, uvifs[vifi].uv_nbrmap);
- else
- NBRM_SETMASK(r->rt_subordinates, uvifs[vifi].uv_nbrmap);
+ r->rt_dominants [vifi] = 0;
if (metric > UNREACHABLE) {
- NBRM_SET(n->al_index, r->rt_subordinates);
- NBRM_SET(n->al_index, r->rt_subordadv);
+ r->rt_subordinates[vifi] = src;
+ }
+ else if (uvifs[vifi].uv_neighbors == NULL ||
+ uvifs[vifi].uv_neighbors->al_next == NULL) {
+ VIFM_SET(vifi, r->rt_leaves);
}
- update_table_entry(r, r->rt_gateway);
- } else {
- IF_DEBUG(DEBUG_RTDETAIL)
- log(LOG_DEBUG, 0, "%s on vif %d advertises %s with metric %d (ignored)",
- inet_fmt(src, s1), vifi, inet_fmts(origin, mask, s2),
- metric);
+ else {
+ r->rt_leaf_timers[vifi] = LEAF_CONFIRMATION_TIME;
+ r->rt_flags |= RTF_LEAF_TIMING;
+ }
+ update_table_entry(r);
}
}
}
@@ -725,13 +587,47 @@ age_routes()
{
register struct rtentry *r;
register struct rtentry *prev_r;
- extern u_long virtual_time; /* from main.c */
+ register vifi_t vifi;
for (prev_r = RT_ADDR, r = routing_table;
r != NULL;
prev_r = r, r = r->rt_next) {
- if ((r->rt_timer += TIMER_INTERVAL) >= ROUTE_DISCARD_TIME) {
+ if ((r->rt_timer += TIMER_INTERVAL) < ROUTE_EXPIRE_TIME) {
+ /*
+ * Route is still good; see if any leaf timers need to be
+ * advanced.
+ */
+ if (r->rt_flags & RTF_LEAF_TIMING) {
+ r->rt_flags &= ~RTF_LEAF_TIMING;
+ for (vifi = 0; vifi < numvifs; ++vifi) {
+ if (r->rt_leaf_timers[vifi] != 0) {
+ /*
+ * Unlike other timers, leaf timers decrement.
+ */
+ if ((r->rt_leaf_timers[vifi] -= TIMER_INTERVAL) == 0){
+#ifdef NOTYET
+ /* If the vif is a physical leaf but has neighbors,
+ * it is not a tree leaf. If I am a leaf, then no
+ * interface with neighbors is a tree leaf. */
+ if (!(((uvifs[vifi].uv_flags & VIFF_LEAF) ||
+ (vifs_with_neighbors == 1)) &&
+ (uvifs[vifi].uv_neighbors != NULL))) {
+#endif
+ VIFM_SET(vifi, r->rt_leaves);
+ update_table_entry(r);
+#ifdef NOTYET
+ }
+#endif
+ }
+ else {
+ r->rt_flags |= RTF_LEAF_TIMING;
+ }
+ }
+ }
+ }
+ }
+ else if (r->rt_timer >= ROUTE_DISCARD_TIME) {
/*
* Time to garbage-collect the route entry.
*/
@@ -739,8 +635,7 @@ age_routes()
discard_route(prev_r);
r = prev_r;
}
- else if (r->rt_timer >= ROUTE_EXPIRE_TIME &&
- r->rt_metric != UNREACHABLE) {
+ else if (r->rt_metric != UNREACHABLE) {
/*
* Time to expire the route entry. If the gateway is zero,
* i.e., it is a route to a directly-connected subnet, just
@@ -757,22 +652,6 @@ age_routes()
routes_changed = TRUE;
}
}
- else if (virtual_time % (ROUTE_REPORT_INTERVAL * 2) == 0) {
- /*
- * Time out subordinateness that hasn't been reported in
- * the last 2 intervals.
- */
- if (!NBRM_SAME(r->rt_subordinates, r->rt_subordadv)) {
- IF_DEBUG(DEBUG_ROUTE)
- log(LOG_DEBUG, 0, "rt %s sub 0x%08x%08x subadv 0x%08x%08x metric %d",
- RT_FMT(r, s1),
- r->rt_subordinates.hi, r->rt_subordinates.lo,
- r->rt_subordadv.hi, r->rt_subordadv.lo, r->rt_metric);
- NBRM_MASK(r->rt_subordinates, r->rt_subordadv);
- update_table_entry(r, r->rt_gateway);
- }
- NBRM_CLRALL(r->rt_subordadv);
- }
}
}
@@ -825,41 +704,10 @@ accept_probe(src, dst, p, datalen, level)
u_int32 level;
{
vifi_t vifi;
- static struct listaddr *unknowns = NULL;
if ((vifi = find_vif(src, dst)) == NO_VIF) {
- struct listaddr *a, **prev;
- struct listaddr *match = NULL;
- time_t now = time(0);
-
- for (prev = &unknowns, a = *prev; a; a = *prev) {
- if (a->al_addr == src)
- match = a;
- if (a->al_ctime + 2 * a->al_timer < now) {
- /* We haven't heard from it in a long time */
- *prev = a->al_next;
- free(a);
- } else {
- prev = &a->al_next;
- }
- }
- if (match == NULL) {
- match = *prev = (struct listaddr *)malloc(sizeof(struct listaddr));
- match->al_next = NULL;
- match->al_addr = src;
- match->al_timer = OLD_NEIGHBOR_EXPIRE_TIME;
- match->al_ctime = now - match->al_timer;
- }
-
- if (match->al_ctime + match->al_timer <= now) {
- log(LOG_WARNING, 0,
- "ignoring probe from non-neighbor %s, check for misconfigured tunnel or routing on %s",
- inet_fmt(src, s1), s1);
- match->al_timer *= 2;
- } else
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0,
- "ignoring probe from non-neighbor %s (%d seconds until next warning)", inet_fmt(src, s1), match->al_ctime + match->al_timer - now);
+ log(LOG_INFO, 0,
+ "ignoring probe from non-neighbor %s", inet_fmt(src, s1));
return;
}
@@ -899,137 +747,8 @@ compare_rts(rt1, rt2)
return (0);
}
-void
-blaster_alloc(vifi)
- vifi_t vifi;
-{
- register struct uvif *v;
-
- v = &uvifs[vifi];
- if (v->uv_blasterbuf)
- free(v->uv_blasterbuf);
-
- v->uv_blasterlen = 64*1024;
- v->uv_blasterbuf = malloc(v->uv_blasterlen);
- v->uv_blastercur = v->uv_blasterend = v->uv_blasterbuf;
- if (v->uv_blastertimer)
- timer_clearTimer(v->uv_blastertimer);
- v->uv_blastertimer = 0;
-}
-
-struct blaster_hdr {
- u_int32 bh_src;
- u_int32 bh_dst;
- u_int32 bh_level;
- int bh_datalen;
-};
-
-/*
- * Queue a route report from a route-blaster.
- * If the timer isn't running to process these reports,
- * start it.
- */
-static void
-queue_blaster_report(vifi, src, dst, p, datalen, level)
- vifi_t vifi;
- u_int32 src, dst, level;
- register char *p;
- register int datalen;
-{
- register struct blaster_hdr *bh;
- register struct uvif *v;
- int bblen = sizeof(*bh) + ((datalen + 3) & ~3);
-
- v = &uvifs[vifi];
- if (v->uv_blasterend - v->uv_blasterbuf +
- bblen > v->uv_blasterlen) {
- int end = v->uv_blasterend - v->uv_blasterbuf;
- int cur = v->uv_blastercur - v->uv_blasterbuf;
-
- v->uv_blasterlen *= 2;
- IF_DEBUG(DEBUG_IF)
- log(LOG_DEBUG, 0, "increasing blasterbuf to %d bytes",
- v->uv_blasterlen);
- v->uv_blasterbuf = realloc(v->uv_blasterbuf,
- v->uv_blasterlen);
- if (v->uv_blasterbuf == NULL) {
- log(LOG_WARNING, ENOMEM, "turning off blaster on vif %d", vifi);
- v->uv_blasterlen = 0;
- v->uv_blasterend = v->uv_blastercur = NULL;
- v->uv_flags &= ~VIFF_BLASTER;
- return;
- }
- v->uv_blasterend = v->uv_blasterbuf + end;
- v->uv_blastercur = v->uv_blasterbuf + cur;
- }
- bh = (struct blaster_hdr *)v->uv_blasterend;
- bh->bh_src = src;
- bh->bh_dst = dst;
- bh->bh_level = level;
- bh->bh_datalen = datalen;
- bcopy(p, (char *)(bh + 1), datalen);
- v->uv_blasterend += bblen;
-
- if (v->uv_blastertimer == 0) {
- int *i = (int *)malloc(sizeof(int *));
-
- if (i == NULL)
- log(LOG_ERR, 0, "out of memory");
-
- *i = vifi;
-
- v->uv_blastertimer = timer_setTimer(5,
- process_blaster_report, i);
- }
-}
-
-/*
- * Periodic process; process up to 5 of the routes in the route-blaster
- * queue. If there are more routes remaining, reschedule myself to run
- * in 1 second.
- */
-static void
-process_blaster_report(vifip)
- void *vifip;
-{
- vifi_t vifi = *(int *)vifip;
- register struct uvif *v;
- register struct blaster_hdr *bh;
- int i;
-
- IF_DEBUG(DEBUG_ROUTE)
- log(LOG_DEBUG, 0, "processing vif %d blasted routes", vifi);
- v = &uvifs[vifi];
- for (i = 0; i < 5; i++) {
- if (v->uv_blastercur >= v->uv_blasterend)
- break;
- bh = (struct blaster_hdr *)v->uv_blastercur;
- v->uv_blastercur += sizeof(*bh) + ((bh->bh_datalen + 3) & ~3);
- accept_report(bh->bh_src, bh->bh_dst, (char *)(bh + 1),
- -bh->bh_datalen, bh->bh_level);
- }
-
- if (v->uv_blastercur >= v->uv_blasterend) {
- v->uv_blastercur = v->uv_blasterbuf;
- v->uv_blasterend = v->uv_blasterbuf;
- v->uv_blastertimer = 0;
- free(vifip);
- IF_DEBUG(DEBUG_ROUTE)
- log(LOG_DEBUG, 0, "finish processing vif %d blaster", vifi);
- } else {
- IF_DEBUG(DEBUG_ROUTE)
- log(LOG_DEBUG, 0, "more blasted routes to come on vif %d", vifi);
- v->uv_blastertimer = timer_setTimer(1,
- process_blaster_report, vifip);
- }
-}
-
/*
* Process an incoming route report message.
- * If the report arrived on a vif marked as a "blaster", then just
- * queue it and return; queue_blaster_report() will schedule it for
- * processing later. If datalen is negative, then this is actually
- * a queued report so actually process it instead of queueing it.
*/
void
accept_report(src, dst, p, datalen, level)
@@ -1043,7 +762,6 @@ accept_report(src, dst, p, datalen, level)
u_int32 mask;
u_int32 origin;
struct newrt rt[4096];
- struct listaddr *nbr;
if ((vifi = find_vif(src, dst)) == NO_VIF) {
log(LOG_INFO, 0,
@@ -1051,15 +769,7 @@ accept_report(src, dst, p, datalen, level)
return;
}
- if (uvifs[vifi].uv_flags & VIFF_BLASTER)
- if (datalen > 0) {
- queue_blaster_report(vifi, src, dst, p, datalen, level);
- return;
- } else {
- datalen = -datalen;
- }
-
- if (!(nbr = update_neighbor(vifi, src, DVMRP_REPORT, NULL, 0, level)))
+ if (!update_neighbor(vifi, src, DVMRP_REPORT, NULL, 0, level))
return;
if (datalen > 2*4096) {
@@ -1116,7 +826,6 @@ accept_report(src, dst, p, datalen, level)
if (rt[nrt-1].origin == 0)
rt[nrt-1].mask = 0;
- IF_DEBUG(DEBUG_ROUTE)
log(LOG_DEBUG, 0, "Updating %d routes from %s to %s", nrt,
inet_fmt(src, s1), inet_fmt(dst, s2));
for (i = 0; i < nrt; ++i) {
@@ -1126,43 +835,8 @@ accept_report(src, dst, p, datalen, level)
inet_fmt(src, s1), inet_fmts(rt[i].origin, rt[i].mask, s2));
continue;
}
- /* Only filter non-poisoned updates. */
- if (uvifs[vifi].uv_filter && rt[i].metric < UNREACHABLE) {
- struct vf_element *vfe;
- int match = 0;
-
- for (vfe = uvifs[vifi].uv_filter->vf_filter; vfe; vfe = vfe->vfe_next) {
- if (vfe->vfe_flags & VFEF_EXACT) {
- if ((vfe->vfe_addr == rt[i].origin) &&
- (vfe->vfe_mask == rt[i].mask)) {
- match = 1;
- break;
- }
- } else {
- if ((rt[i].origin & vfe->vfe_mask) == vfe->vfe_addr) {
- match = 1;
- break;
- }
- }
- }
- if ((uvifs[vifi].uv_filter->vf_type == VFT_ACCEPT && match == 0) ||
- (uvifs[vifi].uv_filter->vf_type == VFT_DENY && match == 1)) {
- IF_DEBUG(DEBUG_ROUTE)
- log(LOG_DEBUG, 0, "%s skipped on vif %d because it %s %s",
- inet_fmts(rt[i].origin, rt[i].mask, s1),
- vifi,
- match ? "matches" : "doesn't match",
- match ? inet_fmts(vfe->vfe_addr, vfe->vfe_mask, s2) :
- "the filter");
-#if 0
- rt[i].metric += vfe->vfe_addmetric;
- if (rt[i].metric > UNREACHABLE)
-#endif
- rt[i].metric = UNREACHABLE;
- }
- }
update_route(rt[i].origin, rt[i].mask, rt[i].metric,
- src, vifi, nbr);
+ src, vifi);
}
if (routes_changed && !delay_change_reports)
@@ -1181,13 +855,85 @@ report(which_routes, vifi, dst)
u_int32 dst;
{
register struct rtentry *r;
+ register char *p;
register int i;
+ int datalen = 0;
+ int width = 0;
+ u_int32 mask = 0;
+ u_int32 src;
+ u_int32 nflags;
+ int metric;
+ int admetric = uvifs[vifi].uv_admetric;
+
+ src = uvifs[vifi].uv_lcl_addr;
+
+ p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
+
+#ifdef NOTYET
+ /* If I'm not a leaf, but the neighbor is a leaf, only advertise default */
+ if ((vifs_with_neighbors != 1) && (uvifs[vifi].uv_flags & VIFF_LEAF)) {
+ *p++ = 0; /* 0xff000000 mask */
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0; /* class A net 0.0.0.0 == default */
+ *p++ = 0x81; /*XXX metric 1, is this safe? */
+ datalen += 5;
+ send_igmp(src, dst, IGMP_DVMRP, DVMRP_REPORT,
+ htonl(MROUTED_LEVEL), datalen);
+ return;
+ }
+#endif
+
+ nflags = (uvifs[vifi].uv_flags & VIFF_LEAF) ? 0 : LEAF_FLAGS;
+
+ for (r = rt_end; r != RT_ADDR; r = r->rt_prev) {
+
+ if (which_routes == CHANGED_ROUTES && !(r->rt_flags & RTF_CHANGED))
+ continue;
+
+ /*
+ * If there is no room for this route in the current message,
+ * send the message and start a new one.
+ */
+ if (datalen + ((r->rt_originmask == mask) ?
+ (width + 1) :
+ (r->rt_originwidth + 4)) > MAX_DVMRP_DATA_LEN) {
+ *(p-1) |= 0x80;
+ send_igmp(src, dst, IGMP_DVMRP, DVMRP_REPORT,
+ htonl(MROUTED_LEVEL | nflags), datalen);
+
+ p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
+ datalen = 0;
+ mask = 0;
+ }
- r = rt_end;
- while (r != RT_ADDR) {
- i = report_chunk(which_routes, r, vifi, dst);
- while (i-- > 0)
- r = r->rt_prev;
+ if (r->rt_originmask != mask || datalen == 0) {
+ mask = r->rt_originmask;
+ width = r->rt_originwidth;
+ if (datalen != 0) *(p-1) |= 0x80;
+ *p++ = ((char *)&mask)[1];
+ *p++ = ((char *)&mask)[2];
+ *p++ = ((char *)&mask)[3];
+ datalen += 3;
+ }
+
+ for (i = 0; i < width; ++i)
+ *p++ = ((char *)&(r->rt_origin))[i];
+
+ metric = r->rt_metric + admetric;
+ if (metric > UNREACHABLE)
+ metric = UNREACHABLE;
+ *p++ = (r->rt_parent == vifi && metric != UNREACHABLE) ?
+ (char)(metric + UNREACHABLE) : /* "poisoned reverse" */
+ (char)(metric);
+
+ datalen += width + 1;
+ }
+
+ if (datalen != 0) {
+ *(p-1) |= 0x80;
+ send_igmp(src, dst, IGMP_DVMRP, DVMRP_REPORT,
+ htonl(MROUTED_LEVEL | nflags), datalen);
}
}
@@ -1214,8 +960,10 @@ report_to_all_neighbors(which_routes)
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
- if (!NBRM_ISEMPTY(v->uv_nbrmap)) {
- report(which_routes, vifi, v->uv_dst_addr);
+ if (v->uv_neighbors != NULL) {
+ report(which_routes, vifi,
+ (v->uv_flags & VIFF_TUNNEL) ? v->uv_rmt_addr
+ : dvmrp_group);
}
}
@@ -1244,8 +992,7 @@ report_to_all_neighbors(which_routes)
* 'vifi'. 'which_routes' specifies ALL_ROUTES or CHANGED_ROUTES.
*/
static int
-report_chunk(which_routes, start_rt, vifi, dst)
- int which_routes;
+report_chunk(start_rt, vifi, dst)
register struct rtentry *start_rt;
vifi_t vifi;
u_int32 dst;
@@ -1254,63 +1001,29 @@ report_chunk(which_routes, start_rt, vifi, dst)
register char *p;
register int i;
register int nrt = 0;
- struct uvif *v = &uvifs[vifi];
int datalen = 0;
int width = 0;
u_int32 mask = 0;
u_int32 src;
- int admetric = v->uv_admetric;
+ u_int32 nflags;
+ int admetric = uvifs[vifi].uv_admetric;
int metric;
- src = v->uv_lcl_addr;
+ src = uvifs[vifi].uv_lcl_addr;
p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
+ nflags = (uvifs[vifi].uv_flags & VIFF_LEAF) ? 0 : LEAF_FLAGS;
+
for (r = start_rt; r != RT_ADDR; r = r->rt_prev) {
- if (which_routes == CHANGED_ROUTES && !(r->rt_flags & RTF_CHANGED)) {
- nrt++;
- continue;
- }
- /*
- * Do not poison-reverse a route for a directly-connected
- * subnetwork on that subnetwork. This can cause loops when
- * some router on the subnetwork is misconfigured.
- */
- if (r->rt_gateway == 0 && r->rt_parent == vifi) {
- nrt++;
+#ifdef NOTYET
+ /* Don't send poisoned routes back to parents if I am a leaf */
+ if ((vifs_with_neighbors == 1) && (r->rt_parent == vifi)
+ && (r->rt_metric > 1)) {
+ ++nrt;
continue;
}
-
- if (v->uv_filter && v->uv_filter->vf_flags & VFF_BIDIR) {
- struct vf_element *vfe;
- int match = 0;
-
- for (vfe = v->uv_filter->vf_filter; vfe; vfe = vfe->vfe_next) {
- if (vfe->vfe_flags & VFEF_EXACT) {
- if ((vfe->vfe_addr == r->rt_origin) &&
- (vfe->vfe_mask == r->rt_originmask)) {
- match = 1;
- break;
- }
- } else {
- if ((r->rt_origin & vfe->vfe_mask) == vfe->vfe_addr) {
- match = 1;
- break;
- }
- }
- }
- if ((v->uv_filter->vf_type == VFT_ACCEPT && match == 0) ||
- (v->uv_filter->vf_type == VFT_DENY && match == 1)) {
- IF_DEBUG(DEBUG_ROUTE)
- log(LOG_DEBUG, 0, "%s not reported on vif %d because it %s %s",
- RT_FMT(r, s1), vifi,
- match ? "matches" : "doesn't match",
- match ? inet_fmts(vfe->vfe_addr, vfe->vfe_mask, s2) :
- "the filter");
- nrt++;
- continue;
- }
- }
+#endif
/*
* If there is no room for this route in the current message,
@@ -1320,10 +1033,10 @@ report_chunk(which_routes, start_rt, vifi, dst)
(width + 1) :
(r->rt_originwidth + 4)) > MAX_DVMRP_DATA_LEN) {
*(p-1) |= 0x80;
- send_on_vif(v, 0, DVMRP_REPORT, datalen);
+ send_igmp(src, dst, IGMP_DVMRP, DVMRP_REPORT,
+ htonl(MROUTED_LEVEL | nflags), datalen);
return (nrt);
}
-
if (r->rt_originmask != mask || datalen == 0) {
mask = r->rt_originmask;
width = r->rt_originwidth;
@@ -1339,17 +1052,16 @@ report_chunk(which_routes, start_rt, vifi, dst)
metric = r->rt_metric + admetric;
if (metric > UNREACHABLE)
metric = UNREACHABLE;
- if (r->rt_parent != vifi && AVOID_TRANSIT(vifi, r))
- metric = UNREACHABLE;
*p++ = (r->rt_parent == vifi && metric != UNREACHABLE) ?
(char)(metric + UNREACHABLE) : /* "poisoned reverse" */
- (char)(metric);
+ (char)(metric);
++nrt;
datalen += width + 1;
}
if (datalen != 0) {
*(p-1) |= 0x80;
- send_on_vif(v, 0, DVMRP_REPORT, datalen);
+ send_igmp(src, dst, IGMP_DVMRP, DVMRP_REPORT,
+ htonl(MROUTED_LEVEL | nflags), datalen);
}
return (nrt);
}
@@ -1384,8 +1096,14 @@ report_next_chunk()
* all our neighbors.
*/
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
- if (!NBRM_ISEMPTY(v->uv_nbrmap)) {
- n = report_chunk(ALL_ROUTES, sr, vifi, v->uv_dst_addr);
+ if ((v->uv_neighbors != NULL)
+#ifdef NOTYET
+ && !(v->uv_flags & VIFF_LEAF)
+#endif
+ ) {
+ n = report_chunk(sr, vifi,
+ (v->uv_flags & VIFF_TUNNEL) ? v->uv_rmt_addr
+ : dvmrp_group);
if (n < min)
min = n;
}
@@ -1394,7 +1112,6 @@ report_next_chunk()
min = 0; /* Neighborless router didn't send any routes */
n = min;
- IF_DEBUG(DEBUG_ROUTE)
log(LOG_INFO, 0, "update %d starting at %d of %d",
n, (nroutes - start_rt), nroutes);
@@ -1417,7 +1134,7 @@ dump_routes(fp)
fprintf(fp,
"Multicast Routing Table (%u %s)\n%s\n",
nroutes, (nroutes == 1) ? "entry" : "entries",
- " Origin-Subnet From-Gateway Metric Tmr Fl In-Vif Out-Vifs");
+ " Origin-Subnet From-Gateway Metric Tmr In-Vif Out-Vifs");
for (r = routing_table; r != NULL; r = r->rt_next) {
@@ -1428,31 +1145,12 @@ dump_routes(fp)
fprintf(fp, (r->rt_metric == UNREACHABLE) ? " NR " : "%4u ",
r->rt_metric);
- fprintf(fp, " %3u %c%c %3u ", r->rt_timer,
- (r->rt_flags & RTF_CHANGED) ? 'C' : '.',
- (r->rt_flags & RTF_HOLDDOWN) ? 'H' : '.',
- r->rt_parent);
+ fprintf(fp, " %3u %3u ", r->rt_timer, r->rt_parent);
for (i = 0; i < numvifs; ++i) {
- struct listaddr *n;
- char l = '[';
-
if (VIFM_ISSET(i, r->rt_children)) {
- if ((uvifs[i].uv_flags & VIFF_TUNNEL) &&
- !NBRM_ISSETMASK(uvifs[i].uv_nbrmap, r->rt_subordinates))
- /* Don't print out parenthood of a leaf tunnel. */
- continue;
- fprintf(fp, " %u", i);
- if (!NBRM_ISSETMASK(uvifs[i].uv_nbrmap, r->rt_subordinates))
- fprintf(fp, "*");
- for (n = uvifs[i].uv_neighbors; n; n = n->al_next) {
- if (NBRM_ISSET(n->al_index, r->rt_subordinates)) {
- fprintf(fp, "%c%d", l, n->al_index);
- l = ',';
- }
- }
- if (l == ',')
- fprintf(fp, "]");
+ fprintf(fp, " %u%c",
+ i, VIFM_ISSET(i, r->rt_leaves) ? '*' : ' ');
}
}
fprintf(fp, "\n");
@@ -1467,8 +1165,7 @@ determine_route(src)
struct rtentry *rt;
for (rt = routing_table; rt != NULL; rt = rt->rt_next) {
- if (rt->rt_origin == (src & rt->rt_originmask) &&
- rt->rt_metric != UNREACHABLE)
+ if (rt->rt_origin == (src & rt->rt_originmask))
break;
}
return rt;
diff --git a/usr.sbin/mrouted/route.h b/usr.sbin/mrouted/route.h
index 8a0f281caa26..5b34e8a0ce27 100644
--- a/usr.sbin/mrouted/route.h
+++ b/usr.sbin/mrouted/route.h
@@ -7,8 +7,7 @@
* Leland Stanford Junior University.
*
*
- * $Id: route.h,v 1.7 1997/02/22 16:07:07 peter Exp $
- * route.h,v 3.8.4.6 1997/07/01 23:02:35 fenner Exp
+ * $Id$
*/
/*
@@ -36,18 +35,17 @@ struct rtentry {
u_int32 rt_gateway; /* first-hop gateway back to origin */
vifi_t rt_parent; /* incoming vif (ie towards origin) */
vifbitmap_t rt_children; /* outgoing children vifs */
+ vifbitmap_t rt_leaves; /* subset of outgoing children vifs */
u_int32 *rt_dominants; /* per vif dominant gateways */
- nbrbitmap_t rt_subordinates; /* bitmap of subordinate gateways */
- nbrbitmap_t rt_subordadv; /* recently advertised subordinates */
+ u_int32 *rt_subordinates; /* per vif subordinate gateways */
+ u_int *rt_leaf_timers; /* per vif leaf confirmation timers */
u_int rt_timer; /* for timing out the route entry */
struct rtentry *rt_prev; /* link to previous entry */
struct gtable *rt_groups; /* link to active groups */
};
#define RTF_CHANGED 0x01 /* route changed but not reported */
-#define RTF_HOLDDOWN 0x04 /* this route is in holddown */
+#define RTF_LEAF_TIMING 0x02 /* some leaf timers are running */
#define ALL_ROUTES 0 /* possible arguments to report() */
#define CHANGED_ROUTES 1 /* and report_to_all_neighbors() */
-
-#define RT_FMT(r, s) inet_fmts((r)->rt_origin, (r)->rt_originmask, s)
diff --git a/usr.sbin/mrouted/rsrr.c b/usr.sbin/mrouted/rsrr.c
index b8a0a825bf56..d0771ecbafa8 100644
--- a/usr.sbin/mrouted/rsrr.c
+++ b/usr.sbin/mrouted/rsrr.c
@@ -32,17 +32,29 @@
#ifndef lint
static const char rcsid[] =
- "$Id: rsrr.c,v 1.6 1998/01/16 07:17:45 charnier Exp $";
+ "$Id$";
#endif /* not lint */
#ifdef RSRR
#include "defs.h"
#include <sys/param.h>
-#ifdef HAVE_SA_LEN
-#include <stddef.h> /* for offsetof */
+#if (defined(BSD) && (BSD >= 199103))
+#include <stddef.h>
#endif
+/* Taken from prune.c */
+/*
+ * checks for scoped multicast addresses
+ */
+#define GET_SCOPE(gt) { \
+ register int _i; \
+ if (((gt)->gt_mcastgrp & 0xff000000) == 0xef000000) \
+ for (_i = 0; _i < numvifs; _i++) \
+ if (scoped_addr(_i, (gt)->gt_mcastgrp)) \
+ VIFM_SET(_i, (gt)->gt_scope); \
+ }
+
/*
* Exported variables.
*/
@@ -65,7 +77,6 @@ static void rsrr_accept __P((int recvlen));
static void rsrr_accept_iq __P((void));
static int rsrr_accept_rq __P((struct rsrr_rq *route_query, int flags,
struct gtable *gt_notify));
-static void rsrr_read __P((int, fd_set *));
static int rsrr_send __P((int sendlen));
static void rsrr_cache __P((struct gtable *gt,
struct rsrr_rq *route_query));
@@ -84,7 +95,7 @@ rsrr_init()
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sun_family = AF_UNIX;
strcpy(serv_addr.sun_path, RSRR_SERV_PATH);
-#ifdef HAVE_SA_LEN
+#if (defined(BSD) && (BSD >= 199103))
servlen = offsetof(struct sockaddr_un, sun_path) +
strlen(serv_addr.sun_path);
serv_addr.sun_len = servlen;
@@ -95,17 +106,22 @@ rsrr_init()
if (bind(rsrr_socket, (struct sockaddr *) &serv_addr, servlen) < 0)
log(LOG_ERR, errno, "Can't bind RSRR socket");
- if (register_input_handler(rsrr_socket, rsrr_read) < 0)
+ if (register_input_handler(rsrr_socket,rsrr_read) < 0)
log(LOG_WARNING, 0, "Couldn't register RSRR as an input handler");
}
/* Read a message from the RSRR socket */
-static void
+void
rsrr_read(f, rfd)
int f;
fd_set *rfd;
{
register int rsrr_recvlen;
+#ifdef SYSV
+ sigset_t block, oblock;
+#else
+ register int omask;
+#endif
bzero((char *) &client_addr, sizeof(client_addr));
rsrr_recvlen = recvfrom(rsrr_socket, rsrr_recv_buf, sizeof(rsrr_recv_buf),
@@ -115,7 +131,21 @@ rsrr_read(f, rfd)
log(LOG_ERR, errno, "RSRR recvfrom");
return;
}
+#ifdef SYSV
+ (void)sigemptyset(&block);
+ (void)sigaddset(&block, SIGALRM);
+ if (sigprocmask(SIG_BLOCK, &block, &oblock) < 0)
+ log(LOG_ERR, errno, "sigprocmask");
+#else
+ /* Use of omask taken from main() */
+ omask = sigblock(sigmask(SIGALRM));
+#endif
rsrr_accept(rsrr_recvlen);
+#ifdef SYSV
+ (void)sigprocmask(SIG_SETMASK, &oblock, (sigset_t *)NULL);
+#else
+ (void)sigsetmask(omask);
+#endif
}
/* Accept a message from the reservation protocol and take
@@ -149,8 +179,7 @@ rsrr_accept(recvlen)
switch (rsrr->type) {
case RSRR_INITIAL_QUERY:
/* Send Initial Reply to client */
- IF_DEBUG(DEBUG_RSRR)
- log(LOG_DEBUG, 0, "Received Initial Query\n");
+ log(LOG_INFO, 0, "Received Initial Query\n");
rsrr_accept_iq();
break;
case RSRR_ROUTE_QUERY:
@@ -163,8 +192,7 @@ rsrr_accept(recvlen)
}
/* Get the query */
route_query = (struct rsrr_rq *) (rsrr_recv_buf + RSRR_HEADER_LEN);
- IF_DEBUG(DEBUG_RSRR)
- log(LOG_DEBUG, 0,
+ log(LOG_INFO, 0,
"Received Route Query for src %s grp %s notification %d",
inet_fmt(route_query->source_addr.s_addr, s1),
inet_fmt(route_query->dest_addr.s_addr,s2),
@@ -230,8 +258,7 @@ rsrr_accept_iq()
sendlen = RSRR_HEADER_LEN + numvifs*RSRR_VIF_LEN;
/* Send it. */
- IF_DEBUG(DEBUG_RSRR)
- log(LOG_DEBUG, 0, "Send RSRR Initial Reply");
+ log(LOG_INFO, 0, "Send RSRR Initial Reply");
rsrr_send(sendlen);
}
@@ -252,7 +279,7 @@ rsrr_accept_rq(route_query,flags,gt_notify)
struct rsrr_rr *route_reply;
struct gtable *gt,local_g;
struct rtentry *r;
- int sendlen;
+ int sendlen,i;
u_long mcastgrp;
/* Set up message */
@@ -284,10 +311,8 @@ rsrr_accept_rq(route_query,flags,gt_notify)
rsrr->flags = flags;
/* Include the routing entry. */
route_reply->in_vif = gt_notify->gt_route->rt_parent;
- if (BIT_TST(flags,RSRR_NOTIFICATION_BIT))
- route_reply->out_vif_bm = gt_notify->gt_grpmems;
- else
- route_reply->out_vif_bm = 0;
+ route_reply->out_vif_bm = gt_notify->gt_grpmems;
+
} else if (find_src_grp(route_query->source_addr.s_addr, 0,
route_query->dest_addr.s_addr)) {
@@ -326,7 +351,17 @@ rsrr_accept_rq(route_query,flags,gt_notify)
gt->gt_route = r;
/* obtain the multicast group membership list */
- determine_forwvifs(gt);
+ for (i = 0; i < numvifs; i++) {
+ if (VIFM_ISSET(i, r->rt_children) &&
+ !(VIFM_ISSET(i, r->rt_leaves)))
+ VIFM_SET(i, gt->gt_grpmems);
+
+ if (VIFM_ISSET(i, r->rt_leaves) && grplst_mem(i, mcastgrp))
+ VIFM_SET(i, gt->gt_grpmems);
+ }
+
+ GET_SCOPE(gt);
+ gt->gt_grpmems &= ~gt->gt_scope;
/* Include the routing entry. */
route_reply->in_vif = gt->gt_route->rt_parent;
@@ -338,9 +373,13 @@ rsrr_accept_rq(route_query,flags,gt_notify)
}
}
- IF_DEBUG(DEBUG_RSRR)
- log(LOG_DEBUG, 0, "%sSend RSRR Route Reply for src %s dst %s in vif %d out vif %d\n",
- gt_notify ? "Route Change: " : "",
+ if (gt_notify)
+ log(LOG_INFO, 0, "Route Change: Send RSRR Route Reply");
+
+ else
+ log(LOG_INFO, 0, "Send RSRR Route Reply");
+
+ log(LOG_INFO, 0, "for src %s dst %s in vif %d out vif %d\n",
inet_fmt(route_reply->source_addr.s_addr,s1),
inet_fmt(route_reply->dest_addr.s_addr,s2),
route_reply->in_vif,route_reply->out_vif_bm);
@@ -400,7 +439,6 @@ rsrr_cache(gt,route_query)
} else {
/* Update */
rc->route_query.query_id = route_query->query_id;
- IF_DEBUG(DEBUG_RSRR)
log(LOG_DEBUG, 0,
"Update cached query id %ld from client %s\n",
rc->route_query.query_id, rc->client_addr.sun_path);
@@ -423,7 +461,6 @@ rsrr_cache(gt,route_query)
rc->client_length = client_length;
rc->next = gt->gt_rsrr_cache;
gt->gt_rsrr_cache = rc;
- IF_DEBUG(DEBUG_RSRR)
log(LOG_DEBUG, 0, "Cached query id %ld from client %s\n",
rc->route_query.query_id,rc->client_addr.sun_path);
}
@@ -445,7 +482,6 @@ rsrr_cache_send(gt,notify)
rcnp = &gt->gt_rsrr_cache;
while ((rc = *rcnp) != NULL) {
if (rsrr_accept_rq(&rc->route_query,flags,gt) < 0) {
- IF_DEBUG(DEBUG_RSRR)
log(LOG_DEBUG, 0, "Deleting cached query id %ld from client %s\n",
rc->route_query.query_id,rc->client_addr.sun_path);
/* Delete cache entry. */
@@ -464,9 +500,7 @@ rsrr_cache_clean(gt)
{
struct rsrr_cache *rc,*rc_next;
- IF_DEBUG(DEBUG_RSRR)
- log(LOG_DEBUG, 0, "cleaning cache for group %s\n",
- inet_fmt(gt->gt_mcastgrp, s1));
+ printf("cleaning cache for group %s\n",inet_fmt(gt->gt_mcastgrp, s1));
rc = gt->gt_rsrr_cache;
while (rc) {
rc_next = rc->next;
diff --git a/usr.sbin/mrouted/vif.c b/usr.sbin/mrouted/vif.c
index 98c11ceb2ee2..4ce99edf49dd 100644
--- a/usr.sbin/mrouted/vif.c
+++ b/usr.sbin/mrouted/vif.c
@@ -5,14 +5,11 @@
*
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
- *
- *
- * vif.c,v 3.8.4.56.2.1 1999/01/20 05:18:50 fenner Exp
*/
#ifndef lint
static const char rcsid[] =
- "$Id: vif.c,v 1.13 1998/06/09 05:01:38 imp Exp $";
+ "$Id: vif.c,v 1.12 1998/01/16 07:17:45 charnier Exp $";
#endif /* not lint */
#include "defs.h"
@@ -31,11 +28,6 @@ int udp_socket; /* Since the honkin' kernel doesn't support */
/* How dumb. */
int vifs_with_neighbors; /* == 1 if I am a leaf */
-/*
- * Private variables.
- */
-struct listaddr *nbrs[MAXNBRS]; /* array of neighbors */
-
typedef struct {
vifi_t vifi;
struct listaddr *g;
@@ -50,7 +42,6 @@ static void start_vif2 __P((vifi_t vifi));
static void stop_vif __P((vifi_t vifi));
static void age_old_hosts __P((void));
static void send_probe_on_vif __P((struct uvif *v));
-static void send_query __P((struct uvif *v));
static int info_version __P((char *p, int plen));
static void DelVif __P((void *arg));
static int SetTimer __P((int vifi, struct listaddr *g));
@@ -80,15 +71,10 @@ init_vifs()
/*
* Configure the vifs based on the interface configuration of the
* the kernel and the contents of the configuration file.
- * (Open a UDP socket for ioctl use in the config procedures if
- * the kernel can't handle IOCTL's on the IGMP socket.)
+ * (Open a UDP socket for ioctl use in the config procedures.)
*/
-#ifdef IOCTL_OK_ON_RAW_SOCKET
- udp_socket = igmp_socket;
-#else
if ((udp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
log(LOG_ERR, errno, "UDP socket");
-#endif
log(LOG_INFO,0,"Getting vifs from kernel interfaces");
config_vifs_from_kernel();
log(LOG_INFO,0,"Getting vifs from %s",configfilename);
@@ -138,47 +124,6 @@ init_vifs()
}
/*
- * Initialize the passed vif with all appropriate default values.
- * "t" is true if a tunnel, or false if a phyint.
- */
-void
-zero_vif(v, t)
- struct uvif *v;
- int t;
-{
- v->uv_flags = 0;
- v->uv_metric = DEFAULT_METRIC;
- v->uv_admetric = 0;
- v->uv_threshold = DEFAULT_THRESHOLD;
- v->uv_rate_limit = t ? DEFAULT_TUN_RATE_LIMIT : DEFAULT_PHY_RATE_LIMIT;
- v->uv_lcl_addr = 0;
- v->uv_rmt_addr = 0;
- v->uv_dst_addr = t ? 0 : dvmrp_group;
- v->uv_subnet = 0;
- v->uv_subnetmask = 0;
- v->uv_subnetbcast = 0;
- v->uv_name[0] = '\0';
- v->uv_groups = NULL;
- v->uv_neighbors = NULL;
- NBRM_CLRALL(v->uv_nbrmap);
- v->uv_querier = NULL;
- v->uv_igmpv1_warn = 0;
- v->uv_prune_lifetime = 0;
- v->uv_leaf_timer = 0;
- v->uv_acl = NULL;
- v->uv_addrs = NULL;
- v->uv_filter = NULL;
- v->uv_blasterbuf = NULL;
- v->uv_blastercur = NULL;
- v->uv_blasterend = NULL;
- v->uv_blasterlen = 0;
- v->uv_blastertimer = 0;
- v->uv_nbrup = 0;
- v->uv_icmp_warn = 0;
- v->uv_nroutes = 0;
-}
-
-/*
* Start routing on all virtual interfaces that are not down or
* administratively disabled.
*/
@@ -265,37 +210,6 @@ check_vif_state()
}
/*
- * Send a DVMRP message on the specified vif. If DVMRP messages are
- * to be encapsulated and sent "inside" the tunnel, use the special
- * encapsulator. If it's not a tunnel or DVMRP messages are to be
- * sent "beside" the tunnel, as required by earlier versions of mrouted,
- * then just send the message.
- */
-void
-send_on_vif(v, dst, code, datalen)
- register struct uvif *v;
- u_int32 dst;
- int code;
- int datalen;
-{
- u_int32 group = htonl(MROUTED_LEVEL |
- ((v->uv_flags & VIFF_LEAF) ? 0 : LEAF_FLAGS));
-
- /*
- * The UNIX kernel will not decapsulate unicasts.
- * Therefore, we don't send encapsulated unicasts.
- */
- if ((v->uv_flags & (VIFF_TUNNEL|VIFF_OTUNNEL)) == VIFF_TUNNEL &&
- ((dst == 0) || IN_MULTICAST(ntohl(dst))))
- send_ipip(v->uv_lcl_addr, dst ? dst : dvmrp_group, IGMP_DVMRP,
- code, group, datalen, v);
- else
- send_igmp(v->uv_lcl_addr, dst ? dst : v->uv_dst_addr, IGMP_DVMRP,
- code, group, datalen);
-}
-
-
-/*
* Send a probe message on vif v
*/
static void
@@ -307,10 +221,6 @@ send_probe_on_vif(v)
struct listaddr *nbr;
int i;
- if ((v->uv_flags & VIFF_PASSIVE && v->uv_neighbors == NULL) ||
- (v->uv_flags & VIFF_FORCE_LEAF))
- return;
-
p = send_buf + MIN_IP_HEADER_LEN + IGMP_MINLEN;
for (i = 0; i < 4; i++)
@@ -329,21 +239,13 @@ send_probe_on_vif(v)
nbr = nbr->al_next;
}
- send_on_vif(v, 0, DVMRP_PROBE, datalen);
-}
-
-static void
-send_query(v)
- register struct uvif *v;
-{
- IF_DEBUG(DEBUG_IGMP)
- log(LOG_DEBUG, 0, "sending %squery on vif %d",
- (v->uv_flags & VIFF_IGMPV1) ? "v1 " : "",
- v - uvifs);
- send_igmp(v->uv_lcl_addr, allhosts_group,
- IGMP_MEMBERSHIP_QUERY,
- (v->uv_flags & VIFF_IGMPV1) ? 0 :
- IGMP_MAX_HOST_REPORT_DELAY * IGMP_TIMER_SCALE, 0, 0);
+ send_igmp(v->uv_lcl_addr,
+ (v->uv_flags & VIFF_TUNNEL) ? v->uv_rmt_addr
+ : dvmrp_group,
+ IGMP_DVMRP, DVMRP_PROBE,
+ htonl(MROUTED_LEVEL |
+ ((v->uv_flags & VIFF_LEAF) ? 0 : LEAF_FLAGS)),
+ datalen);
}
/*
@@ -403,10 +305,10 @@ start_vif2(vifi)
* the interface is connected.
*/
start_route_updates();
- update_route(v->uv_subnet, v->uv_subnetmask, 0, 0, vifi, NULL);
+ update_route(v->uv_subnet, v->uv_subnetmask, 0, 0, vifi);
for (p = v->uv_addrs; p; p = p->pa_next) {
start_route_updates();
- update_route(p->pa_subnet, p->pa_subnetmask, 0, 0, vifi, NULL);
+ update_route(p->pa_subnet, p->pa_subnetmask, 0, 0, vifi);
}
/*
@@ -415,9 +317,10 @@ start_vif2(vifi)
* query.
*/
v->uv_flags |= VIFF_QUERIER;
- IF_DEBUG(DEBUG_IGMP)
- log(LOG_DEBUG, 0, "assuming querier duties on vif %d", vifi);
- send_query(v);
+ send_igmp(src, allhosts_group, IGMP_HOST_MEMBERSHIP_QUERY,
+ (v->uv_flags & VIFF_IGMPV1) ? 0 :
+ IGMP_MAX_HOST_REPORT_DELAY * IGMP_TIMER_SCALE, 0, 0);
+ age_old_hosts();
}
v->uv_leaf_timer = LEAF_CONFIRMATION_TIME;
@@ -458,10 +361,10 @@ stop_vif(vifi)
* failure.
*/
start_route_updates();
- update_route(v->uv_subnet, v->uv_subnetmask, UNREACHABLE, 0, vifi, NULL);
+ update_route(v->uv_subnet, v->uv_subnetmask, UNREACHABLE, 0, vifi);
for (p = v->uv_addrs; p; p = p->pa_next) {
start_route_updates();
- update_route(p->pa_subnet, p->pa_subnetmask, UNREACHABLE, 0, vifi, NULL);
+ update_route(p->pa_subnet, p->pa_subnetmask, UNREACHABLE, 0, vifi);
}
/*
@@ -474,8 +377,6 @@ stop_vif(vifi)
free((char *)a);
}
- IF_DEBUG(DEBUG_IGMP)
- log(LOG_DEBUG, 0, "releasing querier duties on vif %d", vifi);
v->uv_flags &= ~VIFF_QUERIER;
}
@@ -492,16 +393,14 @@ stop_vif(vifi)
/*
* Discard all neighbor addresses.
*/
- if (!NBRM_ISEMPTY(v->uv_nbrmap))
+ if (v->uv_neighbors)
vifs_with_neighbors--;
while (v->uv_neighbors != NULL) {
a = v->uv_neighbors;
v->uv_neighbors = a->al_next;
- nbrs[a->al_index] = NULL;
free((char *)a);
}
- NBRM_CLRALL(v->uv_nbrmap);
}
@@ -526,7 +425,6 @@ stop_all_vifs()
while (v->uv_neighbors != NULL) {
a = v->uv_neighbors;
v->uv_neighbors = a->al_next;
- nbrs[a->al_index] = NULL;
free((char *)a);
}
while (v->uv_acl != NULL) {
@@ -554,8 +452,7 @@ find_vif(src, dst)
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (!(v->uv_flags & (VIFF_DOWN|VIFF_DISABLED))) {
if (v->uv_flags & VIFF_TUNNEL) {
- if (src == v->uv_rmt_addr && (dst == v->uv_lcl_addr ||
- dst == dvmrp_group))
+ if (src == v->uv_rmt_addr && dst == v->uv_lcl_addr)
return(vifi);
}
else {
@@ -594,13 +491,7 @@ age_old_hosts()
/*
- * Send group membership queries on each interface for which I am querier.
- * Note that technically, there should be a timer per interface, as the
- * dynamics of querier election can cause the "right" time to send a
- * query to be different on different interfaces. However, this simple
- * implementation only ever sends queries sooner than the "right" time,
- * so can not cause loss of membership (but can send more packets than
- * necessary)
+ * Send group membership queries to all subnets for which I am querier.
*/
void
query_groups()
@@ -610,16 +501,17 @@ query_groups()
for (vifi = 0, v = uvifs; vifi < numvifs; vifi++, v++) {
if (v->uv_flags & VIFF_QUERIER) {
- send_query(v);
+ send_igmp(v->uv_lcl_addr, allhosts_group,
+ IGMP_HOST_MEMBERSHIP_QUERY,
+ (v->uv_flags & VIFF_IGMPV1) ? 0 :
+ IGMP_MAX_HOST_REPORT_DELAY * IGMP_TIMER_SCALE, 0, 0);
}
}
age_old_hosts();
}
/*
- * Process an incoming host membership query. Warn about
- * IGMP version mismatches, perform querier election, and
- * handle group-specific queries when we're not the querier.
+ * Process an incoming host membership query
*/
void
accept_membership_query(src, dst, group, tmo)
@@ -639,97 +531,20 @@ accept_membership_query(src, dst, group, tmo)
v = &uvifs[vifi];
- if ((tmo == 0 && !(v->uv_flags & VIFF_IGMPV1)) ||
- (tmo != 0 && (v->uv_flags & VIFF_IGMPV1))) {
- int i;
-
- /*
- * Exponentially back-off warning rate
- */
- i = ++v->uv_igmpv1_warn;
- while (i && !(i & 1))
- i >>= 1;
- if (i == 1)
- log(LOG_WARNING, 0, "%s %s on vif %d, %s",
- tmo == 0 ? "Received IGMPv1 report from"
- : "Received IGMPv2 report from",
- inet_fmt(src, s1),
- vifi,
- tmo == 0 ? "please configure vif for IGMPv1"
- : "but I am configured for IGMPv1");
- }
-
- if (v->uv_querier == NULL || v->uv_querier->al_addr != src) {
- /*
- * This might be:
- * - A query from a new querier, with a lower source address
- * than the current querier (who might be me)
- * - A query from a new router that just started up and doesn't
- * know who the querier is.
- */
- if (ntohl(src) < (v->uv_querier ? ntohl(v->uv_querier->al_addr)
- : ntohl(v->uv_lcl_addr))) {
- IF_DEBUG(DEBUG_IGMP)
- log(LOG_DEBUG, 0, "new querier %s (was %s) on vif %d",
- inet_fmt(src, s1),
- v->uv_querier ? inet_fmt(v->uv_querier->al_addr, s2) :
- "me", vifi);
- if (!v->uv_querier) {
- v->uv_querier = (struct listaddr *)
- malloc(sizeof(struct listaddr));
- v->uv_flags &= ~VIFF_QUERIER;
- }
- time(&v->uv_querier->al_ctime);
- v->uv_querier->al_addr = src;
- } else {
- IF_DEBUG(DEBUG_IGMP)
- log(LOG_DEBUG, 0, "ignoring query from %s; querier on vif %d is still %s",
- inet_fmt(src, s1), vifi,
- v->uv_querier ? inet_fmt(v->uv_querier->al_addr, s2) :
- "me");
-
- return;
- }
- }
-
- /*
- * Reset the timer since we've received a query.
- */
- if (v->uv_querier && src == v->uv_querier->al_addr)
- v->uv_querier->al_timer = 0;
-
/*
- * If this is a Group-Specific query which we did not source,
- * we must set our membership timer to [Last Member Query Count] *
- * the [Max Response Time] in the packet.
+ * If we consider ourselves the querier for this vif, but hear a
+ * query from a router with a lower IP address, yield to them.
+ *
+ * This is done here as well as in the neighbor discovery in case
+ * there is a querier that doesn't speak DVMRP.
+ *
+ * XXX If this neighbor doesn't speak DVMRP, then we need to create
+ * some neighbor state for him so that we can time him out!
*/
- if (!(v->uv_flags & (VIFF_IGMPV1|VIFF_QUERIER)) && group != 0 &&
- src != v->uv_lcl_addr) {
- register struct listaddr *g;
+ if ((v->uv_flags & VIFF_QUERIER) &&
+ (ntohl(src) < ntohl(v->uv_lcl_addr))) {
+ v->uv_flags &= ~VIFF_QUERIER;
- IF_DEBUG(DEBUG_IGMP)
- log(LOG_DEBUG, 0,
- "%s for %s from %s on vif %d, timer %d",
- "Group-specific membership query",
- inet_fmt(group, s2), inet_fmt(src, s1), vifi, tmo);
-
- for (g = v->uv_groups; g != NULL; g = g->al_next) {
- if (group == g->al_addr && g->al_query == 0) {
- /* setup a timeout to remove the group membership */
- if (g->al_timerid)
- g->al_timerid = DeleteTimer(g->al_timerid);
- g->al_timer = IGMP_LAST_MEMBER_QUERY_COUNT *
- tmo / IGMP_TIMER_SCALE;
- /* use al_query to record our presence in last-member state */
- g->al_query = -1;
- g->al_timerid = SetTimer(vifi, g);
- IF_DEBUG(DEBUG_IGMP)
- log(LOG_DEBUG, 0,
- "timer for grp %s on vif %d set to %d",
- inet_fmt(group, s2), vifi, g->al_timer);
- break;
- }
- }
}
}
@@ -760,13 +575,14 @@ accept_group_report(src, dst, group, r_type)
*/
for (g = v->uv_groups; g != NULL; g = g->al_next) {
if (group == g->al_addr) {
- if (r_type == IGMP_V1_MEMBERSHIP_REPORT)
+ if (r_type == IGMP_HOST_MEMBERSHIP_REPORT)
g->al_old = OLD_AGE_THRESHOLD;
-
- g->al_reporter = src;
+#ifdef SNMP
+ g->al_genid = src;
+#endif /* SNMP */
/** delete old timers, set a timer for expiration **/
- g->al_timer = IGMP_GROUP_MEMBERSHIP_INTERVAL;
+ g->al_timer = GROUP_EXPIRE_TIME;
if (g->al_query)
g->al_query = DeleteTimer(g->al_query);
if (g->al_timerid)
@@ -785,19 +601,21 @@ accept_group_report(src, dst, group, r_type)
log(LOG_ERR, 0, "ran out of memory"); /* fatal */
g->al_addr = group;
- if (r_type == IGMP_V1_MEMBERSHIP_REPORT)
- g->al_old = OLD_AGE_THRESHOLD;
- else
+ if (r_type == IGMP_HOST_NEW_MEMBERSHIP_REPORT)
g->al_old = 0;
+ else
+ g->al_old = OLD_AGE_THRESHOLD;
+#ifdef SNMP
+ g->al_genid = src;
+#endif
/** set a timer for expiration **/
- g->al_query = 0;
- g->al_timer = IGMP_GROUP_MEMBERSHIP_INTERVAL;
- g->al_reporter = src;
- g->al_timerid = SetTimer(vifi, g);
- g->al_next = v->uv_groups;
- v->uv_groups = g;
+ g->al_query = 0;
+ g->al_timer = GROUP_EXPIRE_TIME;
time(&g->al_ctime);
+ g->al_timerid = SetTimer(vifi, g);
+ g->al_next = v->uv_groups;
+ v->uv_groups = g;
update_lclgrp(vifi, group);
}
@@ -808,9 +626,7 @@ accept_group_report(src, dst, group, r_type)
chkgrp_graft(vifi, group);
}
-/*
- * Process an incoming IGMPv2 Leave Group message.
- */
+
void
accept_leave_message(src, dst, group)
u_int32 src, dst, group;
@@ -838,7 +654,6 @@ accept_leave_message(src, dst, group)
*/
for (g = v->uv_groups; g != NULL; g = g->al_next) {
if (group == g->al_addr) {
- IF_DEBUG(DEBUG_IGMP)
log(LOG_DEBUG, 0,
"[vif.c, _accept_leave_message] %d %d \n",
g->al_old, g->al_query);
@@ -855,20 +670,14 @@ accept_leave_message(src, dst, group)
if (g->al_timerid)
g->al_timerid = DeleteTimer(g->al_timerid);
-#if IGMP_LAST_MEMBER_QUERY_COUNT != 2
-This code needs to be updated to keep a counter of the number
-of queries remaining.
-#endif
/** send a group specific querry **/
- g->al_timer = IGMP_LAST_MEMBER_QUERY_INTERVAL *
- (IGMP_LAST_MEMBER_QUERY_COUNT + 1);
+ g->al_timer = LEAVE_EXPIRE_TIME;
send_igmp(v->uv_lcl_addr, g->al_addr,
- IGMP_MEMBERSHIP_QUERY,
- IGMP_LAST_MEMBER_QUERY_INTERVAL * IGMP_TIMER_SCALE,
- g->al_addr, 0);
- g->al_query = SetQueryTimer(g, vifi,
- IGMP_LAST_MEMBER_QUERY_INTERVAL,
- IGMP_LAST_MEMBER_QUERY_INTERVAL * IGMP_TIMER_SCALE);
+ IGMP_HOST_MEMBERSHIP_QUERY,
+ LEAVE_EXPIRE_TIME / 3 * IGMP_TIMER_SCALE,
+ g->al_addr, 0);
+ g->al_query = SetQueryTimer(g, vifi, g->al_timer / 3,
+ LEAVE_EXPIRE_TIME / 3 * IGMP_TIMER_SCALE);
g->al_timerid = SetTimer(vifi, g);
break;
}
@@ -1024,9 +833,6 @@ accept_neighbor_request2(src, dst)
}
/* Put out the header for this neighbor list... */
if (ncount == 0) {
- /* If it's a one-way tunnel, mark it down. */
- if (rflags & DVMRP_NF_TUNNEL && la->al_flags & NBRF_ONEWAY)
- rflags |= DVMRP_NF_DOWN;
*(u_int*)p = v->uv_lcl_addr;
p += 4;
*p++ = v->uv_metric;
@@ -1036,20 +842,11 @@ accept_neighbor_request2(src, dst)
*p++ = 0;
datalen += 4 + 4;
}
- /* Don't report one-way peering on phyint at all */
- if (!(rflags & DVMRP_NF_TUNNEL) && la->al_flags & NBRF_ONEWAY)
- continue;
*(u_int*)p = la->al_addr;
p += 4;
datalen += 4;
(*ncount)++;
}
- if (*ncount == 0) {
- *(u_int*)p = v->uv_rmt_addr;
- p += 4;
- datalen += 4;
- (*ncount)++;
- }
}
}
if (datalen != 0)
@@ -1145,8 +942,7 @@ accept_neighbors2(src, dst, p, datalen, level)
u_char *p;
int datalen;
{
- IF_DEBUG(DEBUG_PKT)
- log(LOG_DEBUG, 0, "ignoring spurious DVMRP neighbor list2 from %s to %s",
+ log(LOG_INFO, 0, "ignoring spurious DVMRP neighbor list2 from %s to %s",
inet_fmt(src, s1), inet_fmt(dst, s2));
}
@@ -1159,8 +955,7 @@ accept_info_reply(src, dst, p, datalen)
u_char *p;
int datalen;
{
- IF_DEBUG(DEBUG_PKT)
- log(LOG_DEBUG, 0, "ignoring spurious DVMRP info reply from %s to %s",
+ log(LOG_INFO, 0, "ignoring spurious DVMRP info reply from %s to %s",
inet_fmt(src, s1), inet_fmt(dst, s2));
}
@@ -1168,9 +963,9 @@ accept_info_reply(src, dst, p, datalen)
/*
* Update the neighbor entry for neighbor 'addr' on vif 'vifi'.
* 'msgtype' is the type of DVMRP message received from the neighbor.
- * Return the neighbor entry if 'addr' is a valid neighbor, FALSE otherwise.
+ * Return TRUE if 'addr' is a valid neighbor, FALSE otherwise.
*/
-struct listaddr *
+int
update_neighbor(vifi, addr, msgtype, p, datalen, level)
vifi_t vifi;
u_int32 addr;
@@ -1181,17 +976,14 @@ update_neighbor(vifi, addr, msgtype, p, datalen, level)
{
register struct uvif *v;
register struct listaddr *n;
- int pv = level & 0xff;
- int mv = (level >> 8) & 0xff;
- int has_genid = 0;
- int in_router_list = 0;
- int dvmrpspec = 0;
- u_int32 genid;
+ u_int32 genid = 0;
+ u_int32 router;
u_int32 send_tables = 0;
- int i;
int do_reset = FALSE;
+ int nflags;
v = &uvifs[vifi];
+ nflags = (level >> 16) & 0xff;
/*
* Confirm that 'addr' is a valid neighbor address on vif 'vifi'.
@@ -1208,67 +1000,12 @@ update_neighbor(vifi, addr, msgtype, p, datalen, level)
(addr == v->uv_lcl_addr ||
addr == v->uv_subnet )) {
log(LOG_WARNING, 0,
- "received DVMRP message from %s: %s",
- (addr == v->uv_lcl_addr) ? "self (check device loopback)" :
- "'the unknown host'",
+ "received DVMRP message from 'the unknown host' or self: %s",
inet_fmt(addr, s1));
- return NULL;
- }
-
- /*
- * Ignore all neighbors on vifs forced into leaf mode
- */
- if (v->uv_flags & VIFF_FORCE_LEAF) {
- return NULL;
+ return (FALSE);
}
/*
- * mrouted's version 3.3 and later include the generation ID
- * and the list of neighbors on the vif in their probe messages.
- */
- if (msgtype == DVMRP_PROBE && ((pv == 3 && mv > 2) ||
- (pv > 3 && pv < 10))) {
- u_int32 router;
-
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "checking probe from %s (%d.%d) on vif %d",
- inet_fmt(addr, s1), pv, mv, vifi);
-
- if (datalen < 4) {
- log(LOG_WARNING, 0,
- "received truncated probe message from %s (len %d)",
- inet_fmt(addr, s1), datalen);
- return NULL;
- }
-
- has_genid = 1;
-
- for (i = 0; i < 4; i++)
- ((char *)&genid)[i] = *p++;
- datalen -= 4;
-
- while (datalen > 0) {
- if (datalen < 4) {
- log(LOG_WARNING, 0,
- "received truncated probe message from %s (len %d)",
- inet_fmt(addr, s1), datalen);
- return NULL;
- }
- for (i = 0; i < 4; i++)
- ((char *)&router)[i] = *p++;
- datalen -= 4;
-
- if (router == v->uv_lcl_addr) {
- in_router_list = 1;
- break;
- }
- }
- }
-
- if ((pv == 3 && mv == 255) || (pv > 3 && pv < 10))
- dvmrpspec = 1;
-
- /*
* Look for addr in list of neighbors.
*/
for (n = v->uv_neighbors; n != NULL; n = n->al_next) {
@@ -1277,217 +1014,157 @@ update_neighbor(vifi, addr, msgtype, p, datalen, level)
}
}
- if (n == NULL) {
+ /*
+ * Found it. Reset its timer, and check for a version change
+ */
+ if (n) {
+ n->al_timer = 0;
+
/*
- * New neighbor.
- *
- * If this neighbor follows the DVMRP spec, start the probe
- * handshake. If not, then it doesn't require the probe
- * handshake, so establish the peering immediately.
+ * update the neighbors version and protocol number
+ * if changed => router went down and came up,
+ * so take action immediately.
*/
- if (dvmrpspec && (msgtype != DVMRP_PROBE))
- return NULL;
+ if ((n->al_pv != (level & 0xff)) ||
+ (n->al_mv != ((level >> 8) & 0xff))) {
- for (i = 0; i < MAXNBRS; i++)
- if (nbrs[i] == NULL)
- break;
-
- if (i == MAXNBRS) {
- /* XXX This is a severe new restriction. */
- /* XXX want extensible bitmaps! */
- log(LOG_ERR, 0, "Can't handle %dth neighbor %s on vif %d!",
- MAXNBRS, inet_fmt(addr, s1), vifi);
- /*NOTREACHED*/
+ do_reset = TRUE;
+ log(LOG_DEBUG, 0,
+ "version change neighbor %s [old:%d.%d, new:%d.%d]",
+ inet_fmt(addr, s1),
+ n->al_pv, n->al_mv, level&0xff, (level >> 8) & 0xff);
+
+ n->al_pv = level & 0xff;
+ n->al_mv = (level >> 8) & 0xff;
}
-
+ } else {
/*
- * Add it to our list of neighbors.
+ * If not found, add it to the list. If the neighbor has a lower
+ * IP address than me, yield querier duties to it.
*/
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "New neighbor %s on vif %d v%d.%d nf 0x%02x idx %d",
+ log(LOG_DEBUG, 0, "New neighbor %s on vif %d v%d.%d nf 0x%02x",
inet_fmt(addr, s1), vifi, level & 0xff, (level >> 8) & 0xff,
- (level >> 16) & 0xff, i);
+ (level >> 16) & 0xff);
n = (struct listaddr *)malloc(sizeof(struct listaddr));
if (n == NULL)
log(LOG_ERR, 0, "ran out of memory"); /* fatal */
n->al_addr = addr;
- n->al_pv = pv;
- n->al_mv = mv;
- n->al_genid = has_genid ? genid : 0;
- n->al_index = i;
- nbrs[i] = n;
+ n->al_pv = level & 0xff;
+ n->al_mv = (level >> 8) & 0xff;
+ n->al_genid = 0;
time(&n->al_ctime);
n->al_timer = 0;
- n->al_flags = has_genid ? NBRF_GENID : 0;
n->al_next = v->uv_neighbors;
- v->uv_neighbors = n;
-
- /*
- * If we are not configured to peer with non-pruning routers,
- * check the deprecated "I-know-how-to-prune" bit. This bit
- * was MBZ in early mrouted implementations (<3.5) and is required
- * to be set by the DVMRPv3 specification.
- */
- if (!(v->uv_flags & VIFF_ALLOW_NONPRUNERS) &&
- !((level & 0x020000) || (pv == 3 && mv < 5))) {
- n->al_flags |= NBRF_TOOOLD;
- }
-
- /*
- * If this router implements the DVMRPv3 spec, then don't peer
- * with him if we haven't yet established a bidirectional connection.
- */
- if (dvmrpspec) {
- if (!in_router_list) {
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "waiting for probe from %s with my addr",
- inet_fmt(addr, s1));
- n->al_flags |= NBRF_WAITING;
- return NULL;
- }
- }
-
- if (n->al_flags & NBRF_DONTPEER) {
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "not peering with %s on vif %d because %x",
- inet_fmt(addr, s1), vifi, n->al_flags & NBRF_DONTPEER);
- return NULL;
- }
/*
* If we thought that we had no neighbors on this vif, send a route
* report to the vif. If this is just a new neighbor on the same
* vif, send the route report just to the new neighbor.
*/
- if (NBRM_ISEMPTY(v->uv_nbrmap)) {
- send_tables = v->uv_dst_addr;
+ if (v->uv_neighbors == NULL) {
+ send_tables = (v->uv_flags & VIFF_TUNNEL) ? addr : dvmrp_group;
vifs_with_neighbors++;
} else {
send_tables = addr;
}
+ v->uv_neighbors = n;
- NBRM_SET(i, v->uv_nbrmap);
- add_neighbor_to_routes(vifi, i);
- } else {
- /*
- * Found it. Reset its timer.
- */
- n->al_timer = 0;
+ if (!(v->uv_flags & VIFF_TUNNEL) &&
+ ntohl(addr) < ntohl(v->uv_lcl_addr))
+ v->uv_flags &= ~VIFF_QUERIER;
+ }
- if (n->al_flags & NBRF_WAITING && msgtype == DVMRP_PROBE) {
- n->al_flags &= ~NBRF_WAITING;
- if (!in_router_list) {
- log(LOG_WARNING, 0, "possible one-way peering with %s on vif %d",
- inet_fmt(addr, s1), vifi);
- n->al_flags |= NBRF_ONEWAY;
- return NULL;
- } else {
- if (NBRM_ISEMPTY(v->uv_nbrmap)) {
- send_tables = v->uv_dst_addr;
- vifs_with_neighbors++;
- } else {
- send_tables = addr;
- }
- NBRM_SET(n->al_index, v->uv_nbrmap);
- add_neighbor_to_routes(vifi, n->al_index);
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "%s on vif %d exits WAITING",
- inet_fmt(addr, s1), vifi);
- }
- }
+ /*
+ * Check if the router gen-ids are the same.
+ * Need to reset the prune state of the router if not.
+ * Also check for one-way interfaces by seeing if we are in our
+ * neighbor's list of known routers.
+ */
+ if (msgtype == DVMRP_PROBE) {
+
+ /* Check genid neighbor flag. Also check version number; 3.3 and
+ * 3.4 didn't set this flag. */
+ if ((((level >> 16) & 0xff) & NF_GENID) ||
+ (((level & 0xff) == 3) && (((level >> 8) & 0xff) > 2))) {
+
+ int i;
- if (n->al_flags & NBRF_ONEWAY && msgtype == DVMRP_PROBE) {
- if (in_router_list) {
- if (NBRM_ISEMPTY(v->uv_nbrmap))
- vifs_with_neighbors++;
- NBRM_SET(n->al_index, v->uv_nbrmap);
- add_neighbor_to_routes(vifi, n->al_index);
- log(LOG_NOTICE, 0, "peering with %s on vif %d is no longer one-way",
- inet_fmt(addr, s1), vifi);
- n->al_flags &= ~NBRF_ONEWAY;
- } else {
- /* XXX rate-limited warning message? */
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "%s on vif %d is still ONEWAY",
- inet_fmt(addr, s1), vifi);
+ if (datalen < 4) {
+ log(LOG_WARNING, 0,
+ "received truncated probe message from %s (len %d)",
+ inet_fmt(addr, s1), datalen);
+ return (FALSE);
}
- }
- /*
- * When peering with a genid-capable but pre-DVMRP spec peer,
- * we might bring up the peering with a route report and not
- * remember his genid. Assume that he doesn't send a route
- * report and then reboot before sending a probe.
- */
- if (has_genid && !(n->al_flags & NBRF_GENID)) {
- n->al_flags |= NBRF_GENID;
- n->al_genid = genid;
- }
+ for (i = 0; i < 4; i++)
+ ((char *)&genid)[i] = *p++;
+ datalen -= 4;
- /*
- * update the neighbors version and protocol number and genid
- * if changed => router went down and came up,
- * so take action immediately.
- */
- if ((n->al_pv != pv) ||
- (n->al_mv != mv) ||
- (has_genid && n->al_genid != genid)) {
+ if (n->al_genid == 0)
+ n->al_genid = genid;
+ else if (n->al_genid != genid) {
+ log(LOG_DEBUG, 0,
+ "new genid neigbor %s on vif %d [old:%x, new:%x]",
+ inet_fmt(addr, s1), vifi, n->al_genid, genid);
- do_reset = TRUE;
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0,
- "version/genid change neighbor %s [old:%d.%d/%8x, new:%d.%d/%8x]",
- inet_fmt(addr, s1),
- n->al_pv, n->al_mv, n->al_genid, pv, mv, genid);
+ n->al_genid = genid;
+ do_reset = TRUE;
+ }
- n->al_pv = pv;
- n->al_mv = mv;
- n->al_genid = genid;
- time(&n->al_ctime);
- }
-
- if ((pv == 3 && mv > 2) || (pv > 3 && pv < 10)) {
- if (!(n->al_flags & VIFF_ONEWAY) && has_genid && !in_router_list &&
- (time(NULL) - n->al_ctime > 20)) {
- if (NBRM_ISSET(n->al_index, v->uv_nbrmap)) {
- NBRM_CLR(n->al_index, v->uv_nbrmap);
- if (NBRM_ISEMPTY(v->uv_nbrmap))
- vifs_with_neighbors--;
+ /*
+ * loop through router list and check for one-way ifs.
+ */
+
+ v->uv_flags |= VIFF_ONEWAY;
+
+ while (datalen > 0) {
+ if (datalen < 4) {
+ log(LOG_WARNING, 0,
+ "received truncated probe message from %s (len %d)",
+ inet_fmt(addr, s1), datalen);
+ return (FALSE);
+ }
+ for (i = 0; i < 4; i++)
+ ((char *)&router)[i] = *p++;
+ datalen -= 4;
+ if (router == v->uv_lcl_addr) {
+ v->uv_flags &= ~VIFF_ONEWAY;
+ break;
}
- delete_neighbor_from_routes(addr, vifi, n->al_index);
- reset_neighbor_state(vifi, addr);
- log(LOG_WARNING, 0, "peering with %s on vif %d is one-way",
- inet_fmt(addr, s1), vifi);
- n->al_flags |= NBRF_ONEWAY;
}
}
+ }
+ if (n->al_flags != nflags) {
+ n->al_flags = nflags;
- if (n->al_flags & NBRF_DONTPEER) {
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "not peering with %s on vif %d because %x",
- inet_fmt(addr, s1), vifi, n->al_flags & NBRF_DONTPEER);
- return NULL;
+ if (n->al_flags & NF_LEAF) {
+ /*XXX If we have non-leaf neighbors then we know we shouldn't
+ * mark this vif as a leaf. For now we just count on other
+ * probes and/or reports resetting the timer. */
+ if (!v->uv_leaf_timer)
+ v->uv_leaf_timer = LEAF_CONFIRMATION_TIME;
+ } else {
+ /* If we get a leaf to non-leaf transition, we *must* update
+ * the routing table. */
+ if (v->uv_flags & VIFF_LEAF && send_tables == 0)
+ send_tables = addr;
+ v->uv_flags &= ~VIFF_LEAF;
+ v->uv_leaf_timer = 0;
}
-
- /* check "leaf" flag */
}
if (do_reset) {
reset_neighbor_state(vifi, addr);
if (!send_tables)
send_tables = addr;
}
- if (send_tables) {
- send_probe_on_vif(v);
+ if (send_tables)
report(ALL_ROUTES, vifi, send_tables);
- }
- v->uv_leaf_timer = 0;
- v->uv_flags &= ~VIFF_LEAF;
- return n;
+ return (TRUE);
}
@@ -1500,7 +1177,7 @@ age_vifs()
{
register vifi_t vifi;
register struct uvif *v;
- register struct listaddr *a, *prev_a;
+ register struct listaddr *a, *prev_a, *n;
register u_int32 addr;
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v ) {
@@ -1512,58 +1189,39 @@ age_vifs()
a = v->uv_neighbors;
a != NULL;
prev_a = a, a = a->al_next) {
- int exp_time;
- int idx;
-
- if (((a->al_pv == 3) && (a->al_mv >= 3)) ||
- ((a->al_pv > 3) && (a->al_pv < 10)))
- exp_time = NEIGHBOR_EXPIRE_TIME;
- else
- exp_time = OLD_NEIGHBOR_EXPIRE_TIME;
- if ((a->al_timer += TIMER_INTERVAL) < exp_time)
+ if ((a->al_timer += TIMER_INTERVAL) < NEIGHBOR_EXPIRE_TIME)
continue;
- IF_DEBUG(DEBUG_PEER)
- log(LOG_DEBUG, 0, "Neighbor %s (%d.%d) expired after %d seconds",
- inet_fmt(a->al_addr, s1), a->al_pv, a->al_mv, exp_time);
-
/*
* Neighbor has expired; delete it from the neighbor list,
* delete it from the 'dominants' and 'subordinates arrays of
- * any route entries.
+ * any route entries and assume querier duties unless there is
+ * another neighbor with a lower IP address than mine.
*/
- NBRM_CLR(a->al_index, v->uv_nbrmap);
- nbrs[a->al_index] = NULL; /* XXX is it a good idea to reuse indxs? */
- idx = a->al_index;
addr = a->al_addr;
prev_a->al_next = a->al_next;
free((char *)a);
- a = prev_a;/*XXX use ** */
+ a = prev_a;
- delete_neighbor_from_routes(addr, vifi, idx);
- reset_neighbor_state(vifi, addr);
+ delete_neighbor_from_routes(addr, vifi);
- if (NBRM_ISEMPTY(v->uv_nbrmap))
+ if (v->uv_neighbors == NULL)
vifs_with_neighbors--;
v->uv_leaf_timer = LEAF_CONFIRMATION_TIME;
- }
- if (v->uv_querier &&
- (v->uv_querier->al_timer += TIMER_INTERVAL) >
- IGMP_OTHER_QUERIER_PRESENT_INTERVAL) {
- /*
- * The current querier has timed out. We must become the
- * querier.
- */
- IF_DEBUG(DEBUG_IGMP)
- log(LOG_DEBUG, 0, "querier %s timed out",
- inet_fmt(v->uv_querier->al_addr, s1));
- free(v->uv_querier);
- v->uv_querier = NULL;
- v->uv_flags |= VIFF_QUERIER;
- send_query(v);
+ if (!(v->uv_flags & VIFF_TUNNEL)) {
+ v->uv_flags |= VIFF_QUERIER;
+ for (n = v->uv_neighbors; n != NULL; n = n->al_next) {
+ if (ntohl(n->al_addr) < ntohl(v->uv_lcl_addr)) {
+ v->uv_flags &= ~VIFF_QUERIER;
+ }
+ if (!(n->al_flags & NF_LEAF)) {
+ v->uv_leaf_timer = 0;
+ }
+ }
+ }
}
}
}
@@ -1585,36 +1243,6 @@ neighbor_info(vifi, addr)
return NULL;
}
-static struct vnflags {
- int vn_flag;
- char *vn_name;
-} vifflags[] = {
- { VIFF_DOWN, "down" },
- { VIFF_DISABLED, "disabled" },
- { VIFF_QUERIER, "querier" },
- { VIFF_ONEWAY, "one-way" },
- { VIFF_LEAF, "leaf" },
- { VIFF_IGMPV1, "IGMPv1" },
- { VIFF_REXMIT_PRUNES, "rexmit_prunes" },
- { VIFF_PASSIVE, "passive" },
- { VIFF_ALLOW_NONPRUNERS,"allow_nonpruners" },
- { VIFF_NOFLOOD, "noflood" },
- { VIFF_NOTRANSIT, "notransit" },
- { VIFF_BLASTER, "blaster" },
- { VIFF_FORCE_LEAF, "force_leaf" },
- { VIFF_OTUNNEL, "old-tunnel" },
-};
-
-static struct vnflags nbrflags[] = {
- { NBRF_LEAF, "leaf" },
- { NBRF_GENID, "have-genid" },
- { NBRF_WAITING, "waiting" },
- { NBRF_ONEWAY, "one-way" },
- { NBRF_TOOOLD, "too old" },
- { NBRF_TOOMANYROUTES, "too many routes" },
- { NBRF_NOTPRUNING, "not pruning?" },
-};
-
/*
* Print the contents of the uvifs array on file 'fp'.
*/
@@ -1626,13 +1254,8 @@ dump_vifs(fp)
register struct uvif *v;
register struct listaddr *a;
register struct phaddr *p;
- register struct vif_acl *acl;
- int i;
struct sioc_vif_req v_req;
- time_t now;
- char *label;
- time(&now);
fprintf(fp, "vifs_with_neighbors = %d\n", vifs_with_neighbors);
if (vifs_with_neighbors == 1)
@@ -1660,106 +1283,65 @@ dump_vifs(fp)
v->uv_threshold,
v->uv_rate_limit);
- for (i = 0; i < sizeof(vifflags) / sizeof(struct vnflags); i++)
- if (v->uv_flags & vifflags[i].vn_flag)
- fprintf(fp, " %s", vifflags[i].vn_name);
-
+ if (v->uv_flags & VIFF_ONEWAY) fprintf(fp, " one-way");
+ if (v->uv_flags & VIFF_DOWN) fprintf(fp, " down");
+ if (v->uv_flags & VIFF_DISABLED) fprintf(fp, " disabled");
+ if (v->uv_flags & VIFF_QUERIER) fprintf(fp, " querier");
+ if (v->uv_flags & VIFF_SRCRT) fprintf(fp, " src-rt");
+ if (v->uv_flags & VIFF_LEAF) fprintf(fp, " leaf");
+ if (v->uv_flags & VIFF_IGMPV1) fprintf(fp, " IGMPv1");
fprintf(fp, "\n");
- /*
- fprintf(fp, " #routes: %d\n", v->uv_nroutes);
- */
- if (v->uv_admetric != 0)
- fprintf(fp, " advert-metric %2u\n",
- v->uv_admetric);
- label = "alternate subnets:";
- for (p = v->uv_addrs; p; p = p->pa_next) {
- fprintf(fp, " %18s %s\n", label,
+ if (v->uv_addrs != NULL) {
+ fprintf(fp, " alternate subnets: %s\n",
+ inet_fmts(v->uv_addrs->pa_subnet, v->uv_addrs->pa_subnetmask, s1));
+ for (p = v->uv_addrs->pa_next; p; p = p->pa_next) {
+ fprintf(fp, " %s\n",
inet_fmts(p->pa_subnet, p->pa_subnetmask, s1));
- label = "";
+ }
}
- label = "peers:";
- for (a = v->uv_neighbors; a != NULL; a = a->al_next) {
- fprintf(fp, " %6s %s (%d.%d) [%d]",
- label, inet_fmt(a->al_addr, s1), a->al_pv, a->al_mv,
- a->al_index);
- for (i = 0; i < sizeof(nbrflags) / sizeof(struct vnflags); i++)
- if (a->al_flags & nbrflags[i].vn_flag)
- fprintf(fp, " %s", nbrflags[i].vn_name);
- fprintf(fp, " up %s\n", scaletime(now - a->al_ctime));
- /*fprintf(fp, " #routes %d\n", a->al_nroutes);*/
- label = "";
+ if (v->uv_neighbors != NULL) {
+ fprintf(fp, " peers: %s (%d.%d) (0x%x)\n",
+ inet_fmt(v->uv_neighbors->al_addr, s1),
+ v->uv_neighbors->al_pv, v->uv_neighbors->al_mv,
+ v->uv_neighbors->al_flags);
+ for (a = v->uv_neighbors->al_next; a != NULL; a = a->al_next) {
+ fprintf(fp, " %s (%d.%d) (0x%x)\n",
+ inet_fmt(a->al_addr, s1), a->al_pv, a->al_mv,
+ a->al_flags);
+ }
}
- label = "group host (time left):";
- for (a = v->uv_groups; a != NULL; a = a->al_next) {
- fprintf(fp, " %23s %-15s %-15s (%s)\n",
- label,
- inet_fmt(a->al_addr, s1),
- inet_fmt(a->al_reporter, s2),
- scaletime(timer_leftTimer(a->al_timerid)));
- label = "";
- }
- label = "boundaries:";
- for (acl = v->uv_acl; acl != NULL; acl = acl->acl_next) {
- fprintf(fp, " %11s %-18s\n", label,
- inet_fmts(acl->acl_addr, acl->acl_mask, s1));
- label = "";
+ if (v->uv_groups != NULL) {
+ fprintf(fp, " groups: %-15s\n",
+ inet_fmt(v->uv_groups->al_addr, s1));
+ for (a = v->uv_groups->al_next; a != NULL; a = a->al_next) {
+ fprintf(fp, " %-15s\n",
+ inet_fmt(a->al_addr, s1));
+ }
}
- if (v->uv_filter) {
- struct vf_element *vfe;
- char lbuf[100];
+ if (v->uv_acl != NULL) {
+ struct vif_acl *acl;
- sprintf(lbuf, "%5s %7s filter:",
- v->uv_filter->vf_flags & VFF_BIDIR ? "bidir"
- : " ",
- v->uv_filter->vf_type == VFT_ACCEPT ? "accept"
- : "deny");
- label = lbuf;
- for (vfe = v->uv_filter->vf_filter;
- vfe != NULL; vfe = vfe->vfe_next) {
- fprintf(fp, " %23s %-18s%s\n",
- label,
- inet_fmts(vfe->vfe_addr, vfe->vfe_mask, s1),
- vfe->vfe_flags & VFEF_EXACT ? " (exact)" : "");
- label = "";
+ fprintf(fp, " boundaries: %-18s\n",
+ inet_fmts(v->uv_acl->acl_addr, v->uv_acl->acl_mask, s1));
+ for (acl = v->uv_acl->acl_next; acl != NULL; acl = acl->acl_next) {
+ fprintf(fp, " : %-18s\n",
+ inet_fmts(acl->acl_addr, acl->acl_mask, s1));
}
}
- if (!(v->uv_flags & (VIFF_TUNNEL|VIFF_DOWN|VIFF_DISABLED))) {
- fprintf(fp, " IGMP querier: ");
- if (v->uv_querier == NULL)
- if (v->uv_flags & VIFF_QUERIER)
- fprintf(fp, "%-18s (this system)\n",
- inet_fmt(v->uv_lcl_addr, s1));
- else
- fprintf(fp, "NONE - querier election failure?\n");
- else
- fprintf(fp, "%-18s up %s last heard %s ago\n",
- inet_fmt(v->uv_querier->al_addr, s1),
- scaletime(now - v->uv_querier->al_ctime),
- scaletime(v->uv_querier->al_timer));
- }
- if (v->uv_flags & VIFF_BLASTER)
- fprintf(fp, " blasterbuf size: %dk\n",
- v->uv_blasterlen / 1024);
- fprintf(fp, " Nbr bitmaps: 0x%08lx%08lx\n",/*XXX*/
- v->uv_nbrmap.hi, v->uv_nbrmap.lo);
- if (v->uv_prune_lifetime != 0)
- fprintf(fp, " Prune Lifetime: %d seconds\n",
- v->uv_prune_lifetime);
-
v_req.vifi = vifi;
- if (did_final_init)
- if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) < 0) {
- log(LOG_WARNING, errno,
- "SIOCGETVIFCNT fails on vif %d", vifi);
- } else {
- fprintf(fp, " pkts/bytes in : %lu/%lu\n",
- v_req.icount, v_req.ibytes);
- fprintf(fp, " pkts/bytes out: %lu/%lu\n",
- v_req.ocount, v_req.obytes);
- }
+ if (ioctl(udp_socket, SIOCGETVIFCNT, (char *)&v_req) < 0) {
+ log(LOG_WARNING, 0,
+ "SIOCGETVIFCNT fails");
+ }
+ else {
+ fprintf(fp, " pkts in : %ld\n",
+ v_req.icount);
+ fprintf(fp, " pkts out: %ld\n",
+ v_req.ocount);
+ }
fprintf(fp, "\n");
}
fprintf(fp, "\n");
@@ -1812,7 +1394,7 @@ SetTimer(vifi, g)
cbk = (cbk_t *) malloc(sizeof(cbk_t));
cbk->g = g;
cbk->vifi = vifi;
- return timer_setTimer(g->al_timer, DelVif, cbk);
+ return timer_setTimer(g->al_timer, (cfunc_t)DelVif, (void *)cbk);
}
/*
@@ -1837,7 +1419,7 @@ SendQuery(arg)
register struct uvif *v = &uvifs[cbk->vifi];
send_igmp(v->uv_lcl_addr, cbk->g->al_addr,
- IGMP_MEMBERSHIP_QUERY,
+ IGMP_HOST_MEMBERSHIP_QUERY,
cbk->q_time, cbk->g->al_addr, 0);
cbk->g->al_query = 0;
free(cbk);
@@ -1858,5 +1440,5 @@ SetQueryTimer(g, vifi, to_expire, q_time)
cbk->g = g;
cbk->q_time = q_time;
cbk->vifi = vifi;
- return timer_setTimer(to_expire, SendQuery, cbk);
+ return timer_setTimer(to_expire, (cfunc_t)SendQuery, (void *)cbk);
}
diff --git a/usr.sbin/mrouted/vif.h b/usr.sbin/mrouted/vif.h
index 52062a7eaff5..e0ed7ecab1ec 100644
--- a/usr.sbin/mrouted/vif.h
+++ b/usr.sbin/mrouted/vif.h
@@ -7,92 +7,9 @@
* Leland Stanford Junior University.
*
*
- * $Id: vif.h,v 1.8 1997/02/22 16:07:09 peter Exp $
- * vif.h,v 3.8.4.26 1998/01/14 21:21:19 fenner Exp
+ * $Id$
*/
-
-/*
- * Bitmap handling functions.
- * These should be fast but generic. bytes can be slow to zero and compare,
- * words are hard to make generic. Thus two sets of macros (yuk).
- */
-
-/*
- * The VIFM_ functions should migrate out of <netinet/ip_mroute.h>, since
- * the kernel no longer uses vifbitmaps.
- */
-#ifndef VIFM_SET
-typedef u_long vifbitmap_t;
-
-#define VIFM_SET(n, m) ((m) |= (1 << (n)))
-#define VIFM_CLR(n, m) ((m) &= ~(1 << (n)))
-#define VIFM_ISSET(n, m) ((m) & (1 << (n)))
-#define VIFM_CLRALL(m) ((m) = 0x00000000)
-#define VIFM_COPY(mfrom, mto) ((mto) = (mfrom))
-#define VIFM_SAME(m1, m2) ((m1) == (m2))
-#endif
-/*
- * And <netinet/ip_mroute.h> was missing some required functions anyway
- */
-#ifndef VIFM_SETALL
-#define VIFM_SETALL(m) ((m) = ~0)
-#endif
-#define VIFM_ISSET_ONLY(n, m) ((m) == (1 << (n)))
-#define VIFM_ISEMPTY(m) ((m) == 0)
-#define VIFM_CLR_MASK(m, mask) ((m) &= ~(mask))
-#define VIFM_SET_MASK(m, mask) ((m) |= (mask))
-
-/*
- * Neighbor bitmaps are, for efficiency, implemented as a struct
- * containing two variables of a native machine type. If you
- * have a native type that's bigger than a long, define it below.
- */
-#define NBRTYPE u_long
-#define NBRBITS sizeof(NBRTYPE) * 8
-
-typedef struct {
- NBRTYPE hi;
- NBRTYPE lo;
-} nbrbitmap_t;
-#define MAXNBRS 2 * NBRBITS
-#define NO_NBR MAXNBRS
-
-#define NBRM_SET(n, m) (((n) < NBRBITS) ? ((m).lo |= (1 << (n))) : \
- ((m).hi |= (1 << (n - NBRBITS))))
-#define NBRM_CLR(n, m) (((n) < NBRBITS) ? ((m).lo &= ~(1 << (n))) : \
- ((m).hi &= ~(1 << (n - NBRBITS))))
-#define NBRM_ISSET(n, m) (((n) < NBRBITS) ? ((m).lo & (1 << (n))) : \
- ((m).hi & (1 << ((n) - NBRBITS))))
-#define NBRM_CLRALL(m) ((m).lo = (m).hi = 0)
-#define NBRM_COPY(mfrom, mto) ((mto).lo = (mfrom).lo, (mto).hi = (mfrom).hi)
-#define NBRM_SAME(m1, m2) (((m1).lo == (m2).lo) && ((m1).hi == (m2).hi))
-#define NBRM_ISEMPTY(m) (((m).lo == 0) && ((m).hi == 0))
-#define NBRM_SETMASK(m, mask) (((m).lo |= (mask).lo),((m).hi |= (mask).hi))
-#define NBRM_CLRMASK(m, mask) (((m).lo &= ~(mask).lo),((m).hi &= ~(mask).hi))
-#define NBRM_MASK(m, mask) (((m).lo &= (mask).lo),((m).hi &= (mask).hi))
-#define NBRM_ISSETMASK(m, mask) (((m).lo & (mask).lo) || ((m).hi & (mask).hi))
-#define NBRM_ISSETALLMASK(m, mask)\
- ((((m).lo & (mask).lo) == (mask).lo) && \
- (((m).hi & (mask).hi) == (mask).hi))
-/*
- * This macro is TRUE if all the subordinates have been pruned, or if
- * there are no subordinates on this vif.
- * The arguments is the map of subordinates, the map of neighbors on the
- * vif, and the map of received prunes.
- */
-#define SUBS_ARE_PRUNED(sub, vifmask, prunes) \
- (((sub).lo & (vifmask).lo) == ((prunes).lo & (vifmask).lo & (sub).lo) && \
- ((sub).hi & (vifmask).hi) == ((prunes).hi & (vifmask).hi & (sub).hi))
-
-struct blastinfo {
- char * bi_buf; /* Pointer to malloced storage */
- char * bi_cur; /* The update to process next */
- char * bi_end; /* The place to put the next update */
- int bi_len; /* Size of malloced storage */
- int bi_timer; /* Timer to run process_blaster_report */
-};
-
/*
* User level Virtual Interface structure
*
@@ -101,62 +18,31 @@ struct blastinfo {
* (Note: all addresses, subnet numbers and masks are kept in NETWORK order.)
*/
struct uvif {
- u_int uv_flags; /* VIFF_ flags defined below */
+ u_short uv_flags; /* VIFF_ flags defined below */
u_char uv_metric; /* cost of this vif */
u_char uv_admetric; /* advertised cost of this vif */
- u_char uv_threshold; /* min ttl required to forward on vif */
u_int uv_rate_limit; /* rate limit on this vif */
+ u_char uv_threshold; /* min ttl required to forward on vif */
u_int32 uv_lcl_addr; /* local address of this vif */
u_int32 uv_rmt_addr; /* remote end-point addr (tunnels only) */
- u_int32 uv_dst_addr; /* destination for DVMRP messages */
u_int32 uv_subnet; /* subnet number (phyints only) */
u_int32 uv_subnetmask; /* subnet mask (phyints only) */
u_int32 uv_subnetbcast;/* subnet broadcast addr (phyints only) */
char uv_name[IFNAMSIZ]; /* interface name */
struct listaddr *uv_groups; /* list of local groups (phyints only) */
struct listaddr *uv_neighbors; /* list of neighboring routers */
- nbrbitmap_t uv_nbrmap; /* bitmap of active neighboring routers */
- struct listaddr *uv_querier; /* IGMP querier on vif */
- int uv_igmpv1_warn;/* To rate-limit IGMPv1 warnings */
- int uv_prune_lifetime; /* Prune lifetime or 0 for default */
struct vif_acl *uv_acl; /* access control list of groups */
int uv_leaf_timer; /* time until this vif is considrd leaf */
struct phaddr *uv_addrs; /* Additional subnets on this vif */
- struct vif_filter *uv_filter; /* Route filters on this vif */
- struct blastinfo uv_blaster; /* Info about route blasters */
- int uv_nbrup; /* Counter for neighbor up events */
- int uv_icmp_warn; /* To rate-limit ICMP warnings */
- u_int uv_nroutes; /* # of routes with this vif as parent */
- struct ip *uv_encap_hdr; /* Pre-formed header to encapsulate msgs*/
};
-#define uv_blasterbuf uv_blaster.bi_buf
-#define uv_blastercur uv_blaster.bi_cur
-#define uv_blasterend uv_blaster.bi_end
-#define uv_blasterlen uv_blaster.bi_len
-#define uv_blastertimer uv_blaster.bi_timer
-
#define VIFF_KERNEL_FLAGS (VIFF_TUNNEL|VIFF_SRCRT)
-#define VIFF_DOWN 0x000100 /* kernel state of interface */
-#define VIFF_DISABLED 0x000200 /* administratively disabled */
-#define VIFF_QUERIER 0x000400 /* I am the subnet's querier */
-#define VIFF_ONEWAY 0x000800 /* Maybe one way interface */
-#define VIFF_LEAF 0x001000 /* all neighbors are leaves */
-#define VIFF_IGMPV1 0x002000 /* Act as an IGMPv1 Router */
-#define VIFF_REXMIT_PRUNES 0x004000 /* retransmit prunes */
-#define VIFF_PASSIVE 0x008000 /* passive tunnel */
-#define VIFF_ALLOW_NONPRUNERS 0x010000 /* ok to peer with nonprunrs */
-#define VIFF_NOFLOOD 0x020000 /* don't flood on this vif */
-#define VIFF_NOTRANSIT 0x040000 /* don't transit these vifs */
-#define VIFF_BLASTER 0x080000 /* nbr on vif blasts routes */
-#define VIFF_FORCE_LEAF 0x100000 /* ignore nbrs on this vif */
-#define VIFF_OTUNNEL 0x200000 /* DVMRP msgs "beside" tunnel*/
-
-#define AVOID_TRANSIT(v, r) \
- (((r)->rt_parent != NO_VIF) && \
- ((r)->rt_gateway != 0) && \
- (uvifs[(v)].uv_flags & VIFF_NOTRANSIT) && \
- (uvifs[(r)->rt_parent].uv_flags & VIFF_NOTRANSIT))
+#define VIFF_DOWN 0x0100 /* kernel state of interface */
+#define VIFF_DISABLED 0x0200 /* administratively disabled */
+#define VIFF_QUERIER 0x0400 /* I am the subnet's querier */
+#define VIFF_ONEWAY 0x0800 /* Maybe one way interface */
+#define VIFF_LEAF 0x1000 /* all neighbors are leaves */
+#define VIFF_IGMPV1 0x2000 /* Act as an IGMPv1 Router */
struct phaddr {
struct phaddr *pa_next;
@@ -171,67 +57,23 @@ struct vif_acl {
u_int32 acl_mask; /* Group addr. mask */
};
-struct vif_filter {
- int vf_type;
-#define VFT_ACCEPT 1
-#define VFT_DENY 2
- int vf_flags;
-#define VFF_BIDIR 1
- struct vf_element *vf_filter;
-};
-
-struct vf_element {
- struct vf_element *vfe_next;
- u_int32 vfe_addr;
- u_int32 vfe_mask;
- int vfe_flags;
-#define VFEF_EXACT 0x0001
-};
-
struct listaddr {
struct listaddr *al_next; /* link to next addr, MUST BE FIRST */
u_int32 al_addr; /* local group or neighbor address */
u_long al_timer; /* for timing out group or neighbor */
- time_t al_ctime; /* entry creation time */
- union {
- struct {
- u_int32 alur_genid; /* generation id for neighbor */
- u_int alur_nroutes; /* # of routes w/ nbr as parent */
- u_char alur_pv; /* router protocol version */
- u_char alur_mv; /* router mrouted version */
- u_char alur_index; /* neighbor index */
- } alu_router;
- struct {
- u_int32 alug_reporter; /* a host which reported membership */
- u_long alug_timerid; /* timer for group membership */
- u_long alug_query; /* timer for repeated leave query */
- u_char alug_old; /* time since heard old report */
- } alu_group;
- } al_alu;
- u_short al_flags; /* flags related to this neighbor */
+ time_t al_ctime; /* neighbor creation time */
+ u_int32 al_genid; /* generation id for neighbor */
+ u_char al_pv; /* router protocol version */
+ u_char al_mv; /* router mrouted version */
+ u_long al_timerid; /* returned by set timer */
+ u_long al_query; /* second query in case of leave */
+ u_short al_old; /* time since heard old report */
+ u_char al_flags; /* flags related to this neighbor */
};
-#define al_genid al_alu.alu_router.alur_genid
-#define al_nroutes al_alu.alu_router.alur_nroutes
-#define al_pv al_alu.alu_router.alur_pv
-#define al_mv al_alu.alu_router.alur_mv
-#define al_index al_alu.alu_router.alur_index
-#define al_reporter al_alu.alu_group.alug_reporter
-#define al_old al_alu.alu_group.alug_old
-#define al_timerid al_alu.alu_group.alug_timerid
-#define al_query al_alu.alu_group.alug_query
-#define NBRF_LEAF 0x0001 /* This neighbor is a leaf */
-#define NBRF_GENID 0x0100 /* I know this neighbor's genid */
-#define NBRF_WAITING 0x0200 /* Waiting for peering to come up */
-#define NBRF_ONEWAY 0x0400 /* One-way peering */
-#define NBRF_TOOOLD 0x0800 /* Too old (policy decision) */
-#define NBRF_TOOMANYROUTES 0x1000 /* Neighbor is spouting routes */
-#define NBRF_NOTPRUNING 0x2000 /* Neighbor doesn't appear to prune */
-
-/*
- * Don't peer with neighbors with any of these flags set
- */
-#define NBRF_DONTPEER (NBRF_WAITING|NBRF_ONEWAY|NBRF_TOOOLD| \
- NBRF_TOOMANYROUTES|NBRF_NOTPRUNING)
+#define NF_LEAF 0x01 /* This neighbor is a leaf */
+#define NF_PRUNE 0x02 /* This neighbor understands prunes */
+#define NF_GENID 0x04 /* I supply genid & rtrlist in probe*/
+#define NF_MTRACE 0x08 /* I can understand mtrace requests */
#define NO_VIF ((vifi_t)MAXVIFS) /* An invalid vif index */
diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c
index 47a5e398fef6..af9f50467db9 100644
--- a/usr.sbin/mtree/create.c
+++ b/usr.sbin/mtree/create.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: create.c,v 1.12 1999/01/12 02:58:23 jkoshy Exp $";
+ "$Id: create.c,v 1.10 1998/06/05 14:43:39 peter Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -52,7 +52,6 @@ static const char rcsid[] =
#include <stdio.h>
#include <time.h>
#include <unistd.h>
-#include <vis.h>
#include "mtree.h"
#include "extern.h"
@@ -139,19 +138,11 @@ statf(indent, p)
struct passwd *pw;
u_long len, val;
int fd, offset;
- char *escaped_name;
-
- escaped_name = calloc(1, p->fts_namelen * 4 + 1);
- if (escaped_name == NULL)
- errx(1, "statf(): calloc() failed");
- strvis(escaped_name, p->fts_name, VIS_WHITE | VIS_OCTAL);
if (iflag || S_ISDIR(p->fts_statp->st_mode))
- offset = printf("%*s%s", indent, "", escaped_name);
+ offset = printf("%*s%s", indent, "", p->fts_name);
else
- offset = printf("%*s %s", indent, "", escaped_name);
-
- free(escaped_name);
+ offset = printf("%*s %s", indent, "", p->fts_name);
if (offset > (INDENTNAMELEN + indent))
offset = MAXLINELEN;
diff --git a/usr.sbin/mtree/spec.c b/usr.sbin/mtree/spec.c
index 1e9c5fd47e89..77f54b199334 100644
--- a/usr.sbin/mtree/spec.c
+++ b/usr.sbin/mtree/spec.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)spec.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: spec.c,v 1.8 1998/12/16 04:54:08 imp Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
@@ -49,7 +49,6 @@ static const char rcsid[] =
#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
-#include <vis.h>
#include "mtree.h"
#include "extern.h"
@@ -144,14 +143,10 @@ noparent: errx(1, "line %d: no parent node", lineno);
if ((centry = calloc(1, sizeof(NODE) + strlen(p))) == NULL)
errx(1, "calloc");
*centry = ginfo;
+ (void)strcpy(centry->name, p);
#define MAGIC "?*["
if (strpbrk(p, MAGIC))
centry->flags |= F_MAGIC;
- if (strunvis(centry->name, p) == -1) {
- warnx("filename %s is ill-encoded and literally used",
- p);
- strcpy(centry->name, p);
- }
set(NULL, centry);
if (!root) {
@@ -217,7 +212,6 @@ set(t, ip)
errx(1, "line %d: invalid file mode %s",
lineno, val);
ip->st_mode = getmode(m, 0);
- free(m);
break;
case F_NLINK:
ip->st_nlink = strtoul(val, &ep, 10);
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index faae982740c4..b25c3fe8ed62 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -27,7 +27,7 @@ provided "as is" without express or implied warranty.
#ifndef lint
static const char rcsid[] =
- "$Id: newsyslog.c,v 1.20 1998/06/09 18:24:04 ache Exp $";
+ "$Id: newsyslog.c,v 1.19 1998/05/10 21:13:29 hoek Exp $";
#endif /* not lint */
#ifndef CONF
@@ -94,7 +94,7 @@ int force = 0; /* Force the trim no matter what*/
char *conf = CONF; /* Configuration file to use */
time_t timenow;
#define MIN_PID 5
-#define MAX_PID 99999 /* was lower, see /usr/include/sys/proc.h */
+#define MAX_PID 30000 /* was 65534, see /usr/include/sys/proc.h */
char hostname[MAXHOSTNAMELEN+1]; /* hostname */
char *daytime; /* timenow in human readable form */
diff --git a/usr.sbin/pccard/Makefile b/usr.sbin/pccard/Makefile
index 7b8a0a6b25c4..ad64ec144f6e 100644
--- a/usr.sbin/pccard/Makefile
+++ b/usr.sbin/pccard/Makefile
@@ -1,6 +1,6 @@
#
-# Makefile for pccardc/pccardd.
-# $Id: Makefile,v 1.3 1997/02/22 16:08:32 peter Exp $
+# Makefile for xntpd.
+# $Id$
#
SUBDIR= pccardc pccardd
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c
index ed4f6d2b54ef..377ba0fc9af9 100644
--- a/usr.sbin/pccard/pccardd/cardd.c
+++ b/usr.sbin/pccard/pccardd/cardd.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: cardd.c,v 1.32 1998/04/20 16:24:03 nate Exp $";
+ "$Id: cardd.c,v 1.31 1998/04/20 15:24:28 nate Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -279,14 +279,11 @@ assign_driver(struct card *cp)
for (conf = cp->config; conf; conf = conf->next)
if (conf->inuse == 0 && conf->driver->card == cp &&
- conf->driver->config == conf &&
- conf->driver->inuse == 0) {
+ conf->driver->config == conf) {
#ifdef DEBUG
logmsg("Found existing driver (%s) for %s\n",
conf->driver->name, cp->manuf);
#endif
- conf->driver->inuse = 1;
- conf->inuse = 1;
return (conf);
}
/*
diff --git a/usr.sbin/pciconf/pciconf.8 b/usr.sbin/pciconf/pciconf.8
index 97ea040c5435..a7d6ac4a8848 100644
--- a/usr.sbin/pciconf/pciconf.8
+++ b/usr.sbin/pciconf/pciconf.8
@@ -1,4 +1,4 @@
-.\" $Id: pciconf.8,v 1.3 1997/10/06 11:38:29 charnier Exp $
+.\" $Id: pciconf.8,v 1.2 1997/02/22 16:09:06 peter Exp $
.\" Copyright (c) 1997
.\" Stefan Esser <se@freebsd.org>. All rights reserved.
.\"
@@ -50,22 +50,14 @@ With the
.Fl l
option, it lists all devices found by the boot probe in the following format:
.Bd -literal
-foo0@pci0:4:0: class=0x010000 card=0x00000000 chip=0x000f1000 rev=0x01 hdr=0x00
-bar0@pci0:5:0: class=0x000100 card=0x00000000 chip=0x88c15333 rev=0x00 hdr=0x00
-none0@pci0:6:0: class=0x020000 card=0x00000000 chip=0x802910ec rev=0x00 hdr=0x00
+pci0:4:0: class=0x010000 card=0x00000000 chip=0x000f1000 rev=0x01 hdr=0x00
+pci0:5:0: class=0x000100 card=0x00000000 chip=0x88c15333 rev=0x00 hdr=0x00
+pci0:6:0: class=0x020000 card=0x00000000 chip=0x802910ec rev=0x00 hdr=0x00
.Ed
.Pp
The first column gives the
-device name, unit number, and
-.Ar selector .
-If there is no device configured in the kernel for the
-.Tn PCI
-device in question, the device name will be
-.Dq none .
-Unit numbers for unconfigured devices start at zero and are incremented for
-each unconfigured device that is encountered. The
.Ar selector
-is in a form which may directly be used for the other forms of the command.
+in a form which may directly be used for the other forms of the command.
The second column is the class code, with the class byte printed as two
hex digits, followed by the sub-class and the interface bytes.
The third column gives the contents of the subvendorid register, introduced
diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c
index 1d7954d3fb33..2f2979a2d959 100644
--- a/usr.sbin/pciconf/pciconf.c
+++ b/usr.sbin/pciconf/pciconf.c
@@ -29,7 +29,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: pciconf.c,v 1.6 1998/09/15 08:21:13 gibbs Exp $";
+ "$Id: pciconf.c,v 1.5 1997/10/06 11:38:30 charnier Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -134,7 +134,6 @@ list_devs(void)
int fd;
struct pci_conf_io pc;
struct pci_conf conf[255], *p;
- int none_count = 0;
fd = open(_PATH_DEVPCI, O_RDWR, 0);
if (fd < 0)
@@ -168,13 +167,12 @@ list_devs(void)
return;
}
for (p = conf; p < &conf[pc.num_matches]; p++) {
+ if ((p->pd_name == NULL) || (*p->pd_name == '\0'))
+ continue;
printf("%s%d@pci%d:%d:%d:\tclass=0x%06x card=0x%08lx "
"chip=0x%08lx rev=0x%02x hdr=0x%02x\n",
- (p->pd_name && *p->pd_name) ? p->pd_name :
- "none",
- (p->pd_name && *p->pd_name) ? p->pd_unit :
- none_count++,
+ p->pd_name, p->pd_unit,
p->pc_sel.pc_bus, p->pc_sel.pc_dev,
p->pc_sel.pc_func, (p->pc_class << 16) |
(p->pc_subclass << 8) | p->pc_progif,
diff --git a/usr.sbin/pcvt/Makefile.inc b/usr.sbin/pcvt/Makefile.inc
index 8ed98292cc24..7d4e4f302280 100644
--- a/usr.sbin/pcvt/Makefile.inc
+++ b/usr.sbin/pcvt/Makefile.inc
@@ -1,4 +1,4 @@
-# $Id: Makefile.inc,v 1.4 1998/05/31 11:41:53 bde Exp $
+# $Id$
FONTDIR = /usr/share/misc/pcvtfonts
diff --git a/usr.sbin/pcvt/Misc/Etc/Makefile b/usr.sbin/pcvt/Misc/Etc/Makefile
index 914d39ab51e7..9e95ba76d13e 100644
--- a/usr.sbin/pcvt/Misc/Etc/Makefile
+++ b/usr.sbin/pcvt/Misc/Etc/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.2 1998/03/16 11:46:09 bde Exp $
+# $Id$
FILES= Termcap Terminfo pcvt.el rc.local uemacs.tar.Z.uu xmodmap-german
diff --git a/usr.sbin/pcvt/fonts/Makefile b/usr.sbin/pcvt/fonts/Makefile
index 59ed20b6857a..7a5946ad3fa5 100644
--- a/usr.sbin/pcvt/fonts/Makefile
+++ b/usr.sbin/pcvt/fonts/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.7 1997/12/20 00:40:05 bde Exp $
+# $Id$
.SUFFIXES: .uu
.uu:
diff --git a/usr.sbin/pcvt/kbdio/kbdio.y b/usr.sbin/pcvt/kbdio/kbdio.y
index 8f825f1eec8f..5a8115768694 100644
--- a/usr.sbin/pcvt/kbdio/kbdio.y
+++ b/usr.sbin/pcvt/kbdio/kbdio.y
@@ -34,15 +34,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ident "$Header: /home/ncvs/src/usr.sbin/pcvt/kbdio/Attic/kbdio.y,v 1.2 1995/04/01 17:16:26 joerg Exp $"
+#ident "$Header: /home/ncvs/src/usr.sbin/pcvt/kbdio/kbdio.y,v 1.1.1.1 1995/02/05 13:49:24 jkh Exp $"
/*
* $Log: kbdio.y,v $
- * Revision 1.2 1995/04/01 17:16:26 joerg
- * Update pcvt to 3.20b23
- *
- * Submitted by: Hellmuth Michaelis <hm@altona.hamburg.com>
- *
* Revision 1.1.1.1 1995/02/05 13:49:24 jkh
* PCVT userland utilities.
* Submitted by: hm
diff --git a/usr.sbin/pcvt/kbdio/lex.l b/usr.sbin/pcvt/kbdio/lex.l
index b7592fe054cc..a829dd2dd96b 100644
--- a/usr.sbin/pcvt/kbdio/lex.l
+++ b/usr.sbin/pcvt/kbdio/lex.l
@@ -33,15 +33,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ident "$Header: /home/ncvs/src/usr.sbin/pcvt/kbdio/Attic/lex.l,v 1.2 1995/04/01 17:16:27 joerg Exp $"
+#ident "$Header: /home/ncvs/src/usr.sbin/pcvt/kbdio/lex.l,v 1.1.1.1 1995/02/05 13:49:24 jkh Exp $"
/*
* $Log: lex.l,v $
- * Revision 1.2 1995/04/01 17:16:27 joerg
- * Update pcvt to 3.20b23
- *
- * Submitted by: Hellmuth Michaelis <hm@altona.hamburg.com>
- *
* Revision 1.1.1.1 1995/02/05 13:49:24 jkh
* PCVT userland utilities.
* Submitted by: hm
diff --git a/usr.sbin/pcvt/keycap/man5/keycap.5 b/usr.sbin/pcvt/keycap/man5/keycap.5
index d15cd5bcc170..b3977208e769 100644
--- a/usr.sbin/pcvt/keycap/man5/keycap.5
+++ b/usr.sbin/pcvt/keycap/man5/keycap.5
@@ -34,7 +34,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)keycap.5, 3.00, Last Edit-Date: [Sun Jan 2 13:45:59 1994]
-.\" $Id: keycap.5,v 1.5 1997/02/22 16:09:10 peter Exp $
+.\" $Id$
.\"
.Dd January 3, 1993
.Dt KEYCAP 5
diff --git a/usr.sbin/pcvt/set2061/compiler.h b/usr.sbin/pcvt/set2061/compiler.h
index 4ff14bdfc324..9fbdb56c9159 100644
--- a/usr.sbin/pcvt/set2061/compiler.h
+++ b/usr.sbin/pcvt/set2061/compiler.h
@@ -20,7 +20,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
- * $Header: /home/ncvs/src/usr.sbin/pcvt/set2061/Attic/compiler.h,v 1.2 1995/05/30 03:49:45 rgrimes Exp $
+ * $Header: /home/ncvs/src/usr.sbin/pcvt/set2061/compiler.h,v 1.1.1.1 1995/02/05 13:49:25 jkh Exp $
*/
diff --git a/usr.sbin/pcvt/vgaio/Makefile b/usr.sbin/pcvt/vgaio/Makefile
index 9edd89669043..b49b7e8b9a95 100644
--- a/usr.sbin/pcvt/vgaio/Makefile
+++ b/usr.sbin/pcvt/vgaio/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.9 1998/05/06 15:23:53 bde Exp $
+# $Id$
.if !exists(${.CURDIR}/../Makefile.inc)
error:
diff --git a/usr.sbin/pcvt/vgaio/lex.l b/usr.sbin/pcvt/vgaio/lex.l
index 7fb6ef2adb9b..5ff8622df236 100644
--- a/usr.sbin/pcvt/vgaio/lex.l
+++ b/usr.sbin/pcvt/vgaio/lex.l
@@ -33,14 +33,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ident "$Header: /home/ncvs/src/usr.sbin/pcvt/vgaio/Attic/lex.l,v 1.1.1.1 1995/02/05 13:49:23 jkh Exp $"
+#ident "$Header: /b/source/CVS/src/sys/arch/i386/isa/pcvt/Util/vgaio/lex.l,v 1.1 1994/03/29 02:47:20 mycroft Exp $"
/*
* $Log: lex.l,v $
- * Revision 1.1.1.1 1995/02/05 13:49:23 jkh
- * PCVT userland utilities.
- * Submitted by: hm
- *
* Revision 1.1 1994/03/29 02:47:20 mycroft
* pcvt 3.0, with some performance enhancements by Joerg Wunsch and me.
*
diff --git a/usr.sbin/pcvt/vgaio/vgaio.8 b/usr.sbin/pcvt/vgaio/vgaio.8
index a7a4c0f1b25b..1b350a6af3e0 100644
--- a/usr.sbin/pcvt/vgaio/vgaio.8
+++ b/usr.sbin/pcvt/vgaio/vgaio.8
@@ -31,7 +31,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: vgaio.8,v 1.2 1998/03/23 08:26:31 charnier Exp $
+.\" $Id$
.\" -hm updated 31.12.94
.\"
.Dd December 31, 1994
diff --git a/usr.sbin/pcvt/vgaio/vgaio.h b/usr.sbin/pcvt/vgaio/vgaio.h
index 61b90641817f..e313f861aa1a 100644
--- a/usr.sbin/pcvt/vgaio/vgaio.h
+++ b/usr.sbin/pcvt/vgaio/vgaio.h
@@ -37,9 +37,6 @@
* The author may be reached unter <joerg_wunsch@uriah.sax.de>
*
* $Log: vgaio.h,v $
- * Revision 1.2 1995/03/05 22:46:27 joerg
- * Upgrade to beta 3.20/b22
- *
* Revision 1.1 1994/03/29 02:47:25 mycroft
* pcvt 3.0, with some performance enhancements by Joerg Wunsch and me.
*
diff --git a/usr.sbin/pcvt/vgaio/vgaio.y b/usr.sbin/pcvt/vgaio/vgaio.y
index ec169d81b9b1..0e7dd7924b4a 100644
--- a/usr.sbin/pcvt/vgaio/vgaio.y
+++ b/usr.sbin/pcvt/vgaio/vgaio.y
@@ -33,14 +33,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ident "$Header: /home/ncvs/src/usr.sbin/pcvt/vgaio/Attic/vgaio.y,v 1.1.1.1 1995/02/05 13:49:24 jkh Exp $"
+#ident "$Header: /b/source/CVS/src/sys/arch/i386/isa/pcvt/Util/vgaio/vgaio.y,v 1.1 1994/03/29 02:47:27 mycroft Exp $"
/*
* $Log: vgaio.y,v $
- * Revision 1.1.1.1 1995/02/05 13:49:24 jkh
- * PCVT userland utilities.
- * Submitted by: hm
- *
* Revision 1.1 1994/03/29 02:47:27 mycroft
* pcvt 3.0, with some performance enhancements by Joerg Wunsch and me.
*
diff --git a/usr.sbin/periodic/periodic.8 b/usr.sbin/periodic/periodic.8
index e5aab0cdc4b1..0ccb11bcf2f0 100644
--- a/usr.sbin/periodic/periodic.8
+++ b/usr.sbin/periodic/periodic.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: periodic.8,v 1.7 1998/03/23 08:26:50 charnier Exp $
+.\" $Id: periodic.8,v 1.6 1997/09/29 19:11:44 wosch Exp $
.\"
.Dd 13 August 1997
.Os FreeBSD 3.0
@@ -118,7 +118,7 @@ variable reading:
.Xr cron 8
.Rs
.Sh DIAGNOSTICS
-Exit status is 0 on success and 1 if the command
+Exit status is 0 on success, and 1 if the command
fails for one of the following reasons:
.Bl -diag
.It usage: periodic <directory of files to execute>
diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh
index 08b3c70c6fc5..593d6c5ad8b4 100644
--- a/usr.sbin/periodic/periodic.sh
+++ b/usr.sbin/periodic/periodic.sh
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $Id: periodic.sh,v 1.6 1998/12/29 22:48:54 hoek Exp $
+# $Id: periodic.sh,v 1.4 1997/08/16 17:08:35 pst Exp $
#
# Run nightly periodic scripts
#
@@ -48,7 +48,7 @@ else
dirlist="$*"
fi
-host=`hostname`
+host=`hostname -s`
echo "Subject: $host $run run output"
# Execute each executable file in the directory list. If the x bit is not
@@ -57,7 +57,7 @@ echo "Subject: $host $run run output"
for dir in $dirlist ; do
for file in $dir/* ; do
- if [ -x $file -a ! -d $file ] ; then
+ if [ -x $file ] ; then
$file
fi
done
diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c
index ac8d4bffbb9f..0522f2b9910d 100644
--- a/usr.sbin/pkg_install/add/extract.c
+++ b/usr.sbin/pkg_install/add/extract.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: extract.c,v 1.22 1998/10/12 20:01:48 jkh Exp $";
+ "$Id: extract.c,v 1.21 1998/09/11 07:26:54 jkh Exp $";
#endif
/*
@@ -34,7 +34,7 @@ static const char rcsid[] =
#define PUSHOUT(todir) /* push out string */ \
if (where_count > sizeof(STARTSTRING)-1) { \
- strcat(where_args, "|tar --unlink -xf - -C "); \
+ strcat(where_args, "|tar xf - -C "); \
strcat(where_args, todir); \
if (system(where_args)) { \
cleanup(0); \
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index f64ca526d2dc..4e4fab296bdf 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.19 1999/01/17 01:22:54 billf Exp $";
+ "$Id: main.c,v 1.17 1998/09/08 10:42:19 jkh Exp $";
#endif
/*
@@ -26,16 +26,14 @@ static const char rcsid[] =
#include <err.h>
#include <sys/param.h>
-#include <objformat.h>
#include "lib.h"
#include "add.h"
-static char Options[] = "hvIRfnrp:SMt:";
+static char Options[] = "hvIRfnp:SMt:";
char *Prefix = NULL;
Boolean NoInstall = FALSE;
Boolean NoRecord = FALSE;
-Boolean Remote = FALSE;
char *Mode = NULL;
char *Owner = NULL;
@@ -49,9 +47,6 @@ add_mode_t AddMode = NORMAL;
char pkgnames[MAX_PKGS][MAXPATHLEN];
char *pkgs[MAX_PKGS];
-static char *getpackagesite(char *);
-int getosreldate(void);
-
static void usage __P((void));
int
@@ -61,10 +56,6 @@ main(int argc, char **argv)
char **start;
char *cp;
- char *remotepkg = NULL, *ptr;
- static char binformat[1024];
- static char packageroot[MAXPATHLEN] = "ftp://ftp.FreeBSD.org/pub/FreeBSD/";
-
start = argv;
while ((ch = getopt(argc, argv, Options)) != -1) {
switch(ch) {
@@ -93,10 +84,6 @@ main(int argc, char **argv)
Verbose = TRUE;
break;
- case 'r':
- Remote = TRUE;
- break;
-
case 't':
strcpy(FirstPen, optarg);
break;
@@ -129,24 +116,10 @@ main(int argc, char **argv)
/* Get all the remaining package names, if any */
for (ch = 0; *argv; ch++, argv++) {
- if (Remote) {
- if (getenv("PACKAGESITE") == NULL) {
- getobjformat(binformat, sizeof(binformat), &argc, argv);
- strcat(packageroot, getpackagesite(binformat));
- }
- else
- strcpy(packageroot, (getenv("PACKAGESITE")));
- remotepkg = strcat(packageroot, *argv);
- if (!((ptr = strrchr(remotepkg, '.')) && ptr[1] == 't' &&
- ptr[2] == 'g' && ptr[3] == 'z' && !ptr[4]))
- strcat(remotepkg, ".tgz");
- }
if (!strcmp(*argv, "-")) /* stdin? */
pkgs[ch] = "-";
else if (isURL(*argv)) /* preserve URLs */
pkgs[ch] = strcpy(pkgnames[ch], *argv);
- else if ((Remote) && isURL(remotepkg))
- pkgs[ch] = strcpy(pkgnames[ch], remotepkg);
else { /* expand all pathnames to fullnames */
if (fexists(*argv)) /* refers to a file directly */
pkgs[ch] = realpath(*argv, pkgnames[ch]);
@@ -183,30 +156,11 @@ main(int argc, char **argv)
return 0;
}
-static char *
-getpackagesite(char binform[1024])
-{
- int reldate;
-
- reldate = getosreldate();
-
- if (reldate == 300005)
- return "packages-3.0/Latest/";
- else if (30004 > reldate && reldate >= 300000)
- return "packages-current-aout/Latest/" ;
- else if (30004 < reldate)
- return !strcmp(binform, "elf") ? "packages-current/Latest/" :
- "packages-current-aout/Latest";
-
- return(0);
-
-}
-
static void
usage()
{
fprintf(stderr, "%s\n%s\n",
- "usage: pkg_add [-vInrfRMS] [-t template] [-p prefix]",
+ "usage: pkg_add [-vInfRMS] [-t template] [-p prefix]",
" pkg-name [pkg-name ...]");
exit(1);
}
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 3b5df6112c4d..f7cd122c9991 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: perform.c,v 1.53 1998/09/11 07:26:54 jkh Exp $";
+ "$Id: perform.c,v 1.52 1998/09/08 03:02:45 jkh Exp $";
#endif
/*
@@ -72,11 +72,6 @@ pkg_do(char *pkg)
PackingList p;
struct stat sb;
int inPlace;
- /* support for separate pre/post install scripts */
- int new_m = 0;
- char pre_script[FILENAME_MAX] = INSTALL_FNAME;
- char post_script[FILENAME_MAX];
- char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX];
code = 0;
zapLogDir = 0;
@@ -323,35 +318,17 @@ pkg_do(char *pkg)
}
}
- /* Test whether to use the old method of passing tokens to installation
- * scripts, and set appropriate variables..
- */
-
- if (fexists(POST_INSTALL_FNAME)) {
- new_m = 1;
- sprintf(post_script, "%s", POST_INSTALL_FNAME);
- sprintf(pre_arg, "");
- sprintf(post_arg, "");
- } else {
- if (fexists(INSTALL_FNAME)) {
- sprintf(post_script, "%s", INSTALL_FNAME);
- sprintf(pre_arg, "PRE-INSTALL");
- sprintf(post_arg, "POST-INSTALL");
- }
- }
-
/* If we're really installing, and have an installation file, run it */
- if (!NoInstall && fexists(pre_script)) {
- vsystem("chmod +x %s", pre_script); /* make sure */
+ if (!NoInstall && fexists(INSTALL_FNAME)) {
+ vsystem("chmod +x %s", INSTALL_FNAME); /* make sure */
if (Verbose)
- printf("Running pre-install for %s..\n", PkgName);
- if (!Fake && vsystem("./%s %s %s", pre_script, PkgName, pre_arg)) {
+ printf("Running install with PRE-INSTALL for %s..\n", PkgName);
+ if (!Fake && vsystem("./%s %s PRE-INSTALL", INSTALL_FNAME, PkgName)) {
warnx("install script returned error status");
- unlink(pre_script);
+ unlink(INSTALL_FNAME);
code = 1;
goto success; /* nothing to uninstall yet */
}
- if (new_m) unlink(pre_script);
}
/* Now finally extract the entire show if we're not going direct */
@@ -372,17 +349,16 @@ pkg_do(char *pkg)
}
/* Run the installation script one last time? */
- if (!NoInstall && fexists(post_script)) {
- vsystem("chmod +x %s", post_script); /* make sure */
+ if (!NoInstall && fexists(INSTALL_FNAME)) {
if (Verbose)
- printf("Running post-install for %s..\n", PkgName);
- if (!Fake && vsystem("./%s %s %s", post_script, PkgName, post_arg)) {
+ printf("Running install with POST-INSTALL for %s..\n", PkgName);
+ if (!Fake && vsystem("./%s %s POST-INSTALL", INSTALL_FNAME, PkgName)) {
warnx("install script returned error status");
- unlink(post_script);
+ unlink(INSTALL_FNAME);
code = 1;
goto fail;
}
- unlink(post_script);
+ unlink(INSTALL_FNAME);
}
/* Time to record the deed? */
@@ -413,8 +389,6 @@ pkg_do(char *pkg)
vsystem("chmod a+rx %s", LogDir);
if (fexists(DEINSTALL_FNAME))
move_file(".", DEINSTALL_FNAME, LogDir);
- if (fexists(POST_DEINSTALL_FNAME))
- move_file(".", POST_DEINSTALL_FNAME, LogDir);
if (fexists(REQUIRE_FNAME))
move_file(".", REQUIRE_FNAME, LogDir);
sprintf(contents, "%s/%s", LogDir, CONTENTS_FNAME);
diff --git a/usr.sbin/pkg_install/add/pkg_add.1 b/usr.sbin/pkg_install/add/pkg_add.1
index e4f2b6d11479..9740467f961e 100644
--- a/usr.sbin/pkg_install/add/pkg_add.1
+++ b/usr.sbin/pkg_install/add/pkg_add.1
@@ -15,7 +15,7 @@
.\"
.\"
.\" @(#)pkg_add.1
-.\" $Id: pkg_add.1,v 1.28 1999/01/17 01:22:55 billf Exp $
+.\" $Id$
.\"
.Dd November 25, 1994
.Dt pkg_add 1
@@ -25,7 +25,7 @@
.Nd a utility for installing software package distributions
.Sh SYNOPSIS
.Nm
-.Op Fl vInfrRMS
+.Op Fl vInfRMS
.Op Fl t Ar template
.Op Fl p Ar prefix
.Ar pkg-name [pkg-name ...]
@@ -48,10 +48,10 @@ attacks from miscreants who create dangerous package files.
You are advised to verify the competence and identity of those who
provide installable package files. For extra protection, use the
.Fl M
-flag to extract the package file, and inspect its contents and scripts to
-insure it poses no danger to your system's integrity. Pay particular
-attention to any +INSTALL, +POST-INSTALL, +DEINSTALL, +POST-DEINSTALL,
-+REQUIRE or +MTREE_DIRS files, and inspect the +CONTENTS file for
+flag to extract the package file, and inspect its contents and scripts
+to insure it poses no danger to your system's integrity. Pay particular
+attention to any +INSTALL, +DEINSTALL, +REQUIRE or +MTREE_DIRS files,
+and inspect the +CONTENTS file for
.Cm @cwd ,
.Cm @mode
(check for setuid),
@@ -78,8 +78,7 @@ will search them in each directory named by
.It Fl v
Turn on verbose output.
.It Fl I
-If a installation scripts (pre-install or post-install) exist for a given
-package, do not execute them.
+If an installation script exists for a given package, do not execute it.
.It Fl n
Don't actually install a package, just report the steps that
would be taken if it was.
@@ -87,9 +86,6 @@ would be taken if it was.
Do not record the installation of a package. This means
that you cannot deinstall it later, so only use this option if
you know what you are doing!
-.It Fl r
-Use the remote fetching feature. This will determine the appropriate
-objformat and release and then fetch and install the package.
.It Fl f
Force installation to proceed even if prerequisite packages are not
installed or the requirements script fails. Although
@@ -201,7 +197,7 @@ passive mode
.Ef
ftp.
.Sh TECHNICAL DETAILS
-.Nm pkg_add
+.Nm Pkg_add
is fairly simple. It extracts each package's "packing list"
into a special staging directory, parses it,
and then runs through the following sequence to fully extract the contents:
@@ -248,32 +244,18 @@ is the name of the package in question and the
keyword denotes this as an installation requirements check (useful if
you want to have one script serving multiple functions).
.It
-If a
-.Ar pre-install
-script exists for the package, it is then executed with the following
-arguments:
+If an
+.Ar install
+script exists for the package, it is then executed with the following arguments:
.Bd -filled -offset indent -compact
-.Cm script
.Ar pkg-name
-.Ar PRE-INSTALL
+.Ar PRE-INSTALL
.Ed
-
where
.Ar pkg-name
is the name of the package in question and
.Ar PRE-INSTALL
is a keyword denoting this as the preinstallation phase.
-
-.Cm Note:
-The
-.Ar PRE-INSTALL
-keyword will not appear if separate scripts for pre-install and post-install
-are given during package creation time (using the
-.Cm Fl i
-and
-.Cm Fl I
-flags to
-.Xr pkg_create 1 ).
.It
If
.Cm @option extract-in-place
@@ -307,39 +289,17 @@ flag was specified, the name of the first directory named by a
.Cm @cwd
directive within this package.
.It
-If a
-.Ar post-install
+If an
+.Ar install
script exists for the package, it is then executed as
.Bd -filled -offset indent -compact
.Cm script
.Ar pkg-name
.Ar POST-INSTALL
.Ed
-where
-.Ar pkg-name
-is the name of the package in question and
-.Ar POST-INSTALL
-is a keyword denoting this as the post-installation phase.
-
-.Cm Note:
-The
-.Ar POST-INSTALL
-keyword will not appear if separate scripts for pre-install and post-install
-are given during package creation time (using the
-.Cm Fl i
-and
-.Cm Fl I
-flags to
-.Xr pkg_create 1 ).
-
-Reasoning behind passing keywords such as
-.Ar POST-INSTALL
-and
-.Ar PRE-INSTALL
-is that this allows you to write a single
+This all allows you to write a single
.Ar install
-script that does both ``before and after'' actions. But, separating the
-functionality is more advantageous and easier from a maintainence viewpoint.
+script that does both ``before and after'' actions.
.It
After installation is complete, a copy of the packing list,
.Ar deinstall
@@ -396,17 +356,6 @@ will use the first of
or
.Pa /usr/tmp
with sufficient space.
-.Pp
-The environment variable
-.Ev PACKAGESITE
-specifies an alternate location for
-.Nm
-to fetch from. This variable subverts the automatic directory logic
-that
-.Nm
-uses when the
-.Fl r
-option is invoked.
.Sh FILES
.Bl -tag -width /var/db/pkg -compact
.It Pa /var/tmp
diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h
index 45b90b10ed17..eab822a371e9 100644
--- a/usr.sbin/pkg_install/create/create.h
+++ b/usr.sbin/pkg_install/create/create.h
@@ -1,4 +1,4 @@
-/* $Id: create.h,v 1.13 1997/10/08 07:46:19 charnier Exp $ */
+/* $Id: create.h,v 1.12 1997/06/06 12:19:11 jkh Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@@ -28,9 +28,7 @@ extern char *Comment;
extern char *Desc;
extern char *Display;
extern char *Install;
-extern char *PostInstall;
extern char *DeInstall;
-extern char *PostDeInstall;
extern char *Contents;
extern char *Require;
extern char *SrcDir;
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c
index 55810c2b2531..38fff8a66b0f 100644
--- a/usr.sbin/pkg_install/create/main.c
+++ b/usr.sbin/pkg_install/create/main.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.17 1997/10/08 07:46:23 charnier Exp $";
+ "$Id: main.c,v 1.16 1997/06/06 12:19:11 jkh Exp $";
#endif
/*
@@ -18,7 +18,7 @@ static const char rcsid[] =
#include "lib.h"
#include "create.h"
-static char Options[] = "YNOhvf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:";
+static char Options[] = "YNOhvf:p:P:c:d:i:k:r:t:X:D:m:s:";
char *Prefix = NULL;
char *Comment = NULL;
@@ -26,9 +26,7 @@ char *Desc = NULL;
char *SrcDir = NULL;
char *Display = NULL;
char *Install = NULL;
-char *PostInstall = NULL;
char *DeInstall = NULL;
-char *PostDeInstall = NULL;
char *Contents = NULL;
char *Require = NULL;
char *ExcludeFrom = NULL;
@@ -89,18 +87,10 @@ main(int argc, char **argv)
Install = optarg;
break;
- case 'I':
- PostInstall = optarg;
- break;
-
case 'k':
DeInstall = optarg;
break;
- case 'K':
- PostDeInstall = optarg;
- break;
-
case 'r':
Require = optarg;
break;
@@ -161,11 +151,10 @@ main(int argc, char **argv)
static void
usage()
{
- fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
+ fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: pkg_create [-YNOhv] [-P pkgs] [-p prefix] [-f contents] [-i iscript]",
-" [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ",
-" [-t template] [-X excludefile] [-D displayfile] ",
-" [-m mtreefile] -c comment -d description -f packlist ",
-" pkg-name");
+" [-k dscript] [-r rscript] [-t template] [-X excludefile]",
+" [-D displayfile] [-m mtreefile] -c comment -d description",
+" -f packlist pkg-name");
exit(1);
}
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 5e7443d9a396..6d13be57f7eb 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: perform.c,v 1.46 1998/12/05 06:28:58 asami Exp $";
+ "$Id: perform.c,v 1.44 1998/09/08 10:42:24 jkh Exp $";
#endif
/*
@@ -45,8 +45,6 @@ pkg_perform(char **pkgs)
FILE *pkg_in, *fp;
Package plist;
int len;
- char *suf;
- int compress;
/* Preliminary setup */
sanity_check();
@@ -65,24 +63,10 @@ pkg_perform(char **pkgs)
}
plist.head = plist.tail = NULL;
- /* chop suffix off if already specified, remembering if we want to compress */
+ /* chop suffix off if already specified */
len = strlen(pkg);
- if (len > 4)
- if (!strcmp(&pkg[len - 4], ".tgz")) {
- compress = TRUE;
- pkg[len - 4] = '\0';
- }
- else if (!strcmp(&pkg[len - 4], ".tar")) {
- compress = FALSE;
- pkg[len - 4] = '\0';
- }
- else
- /* default is to compress packages */
- compress = TRUE;
- if (compress)
- suf = "tgz";
- else
- suf = "tar";
+ if (len > 4 && !strcmp(&pkg[len - 4], ".tgz"))
+ pkg[len - 4] = '\0';
/* Stick the dependencies, if any, at the top */
if (Pkgdeps) {
@@ -156,21 +140,11 @@ pkg_perform(char **pkgs)
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, INSTALL_FNAME);
}
- if (PostInstall) {
- copy_file(home, PostInstall, POST_INSTALL_FNAME);
- add_plist(&plist, PLIST_IGNORE, NULL);
- add_plist(&plist, PLIST_FILE, POST_INSTALL_FNAME);
- }
if (DeInstall) {
copy_file(home, DeInstall, DEINSTALL_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, DEINSTALL_FNAME);
}
- if (PostDeInstall) {
- copy_file(home, PostDeInstall, POST_DEINSTALL_FNAME);
- add_plist(&plist, PLIST_IGNORE, NULL);
- add_plist(&plist, PLIST_FILE, POST_DEINSTALL_FNAME);
- }
if (Require) {
copy_file(home, Require, REQUIRE_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
@@ -202,7 +176,7 @@ pkg_perform(char **pkgs)
}
/* And stick it into a tar ball */
- make_dist(home, pkg, suf, &plist);
+ make_dist(home, pkg, "tgz", &plist);
/* Cleanup */
free(Comment);
@@ -280,12 +254,8 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist)
if (Install)
fprintf(totar, "%s\n", INSTALL_FNAME);
- if (PostInstall)
- fprintf(totar, "%s\n", POST_INSTALL_FNAME);
if (DeInstall)
fprintf(totar, "%s\n", DEINSTALL_FNAME);
- if (PostDeInstall)
- fprintf(totar, "%s\n", POST_DEINSTALL_FNAME);
if (Require)
fprintf(totar, "%s\n", REQUIRE_FNAME);
if (Display)
diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1
index 8596261907b3..eaec8fb1143a 100644
--- a/usr.sbin/pkg_install/create/pkg_create.1
+++ b/usr.sbin/pkg_install/create/pkg_create.1
@@ -15,7 +15,7 @@
.\"
.\"
.\" @(#)pkg_create.1
-.\" $Id: pkg_create.1,v 1.26 1998/06/26 07:15:37 jkoshy Exp $
+.\" $Id: pkg_create.1,v 1.25 1998/05/24 03:11:17 steve Exp $
.\"
.\" hacked up by John Kohl for NetBSD--fixed a few bugs, extended keywords,
.\" added dependency tracking, etc.
@@ -36,9 +36,7 @@
.Op Fl p Ar prefix
.Op Fl f Ar contents
.Op Fl i Ar iscript
-.Op Fl I Ar piscript
.Op Fl k Ar dscript
-.Op Fl K Ar pdscript
.Op Fl r Ar rscript
.Op Fl s Ar srcdir
.Op Fl t Ar template
@@ -104,28 +102,9 @@ are dumped, rather than the links themselves.
.It Fl i Ar iscript
Set
.Ar iscript
-to be the pre-install procedure for the package. This can be any executable
-program (or shell script). It will be invoked automatically when the
-package is later installed. It will be passed the package's name as the
-first argument.
-
-.Cm Note:
-if the
-.Cm Fl I
-option is not given, this script will serve as both the pre-install and the
-post-install script for the package, differentiating between the
-functionality by passing the keywords
-.Ar PRE-INSTALL
-and
-.Ar POST-INSTALL
-respectively, along with the package's name.
-.It Fl I Ar piscript
-Set
-.Ar piscript
-to be the post-install procedure for the package. This can be any
+to be the install procedure for the package. This can be any
executable program (or shell script). It will be invoked automatically
-when the package is later installed. It will be passed the package's name as
-the first argument.
+when the package is later installed.
.It Fl P Ar pkgs
Set the initial package dependency list to
.Ar pkgs .
@@ -141,29 +120,9 @@ the package.
.It Fl k Ar dscript
Set
.Ar dscript
-to be the de-install procedure for the package. This can be any executable
-program (or shell script). It will be invoked automatically when the
-package is later (if ever) de-installed. It will be passed the package's
-name as the first argument.
-
-.Cm Note:
-if the
-.Cm Fl K
-option is not given, this script will serve as both the de-install and the
-post-deinstall script for the package, differentiating between the
-functionality by passing the keywords
-.Ar DEINSTALL
-and
-.Ar POST-DEINSTALL
-respectively, along with the package's name.
-.It Fl K Ar pdscript
-Set
-.Ar pdscript
-to be the post-deinstall procedure for the package. This can be any
-executable program (or shell script). It will be invoked automatically when
-the package is later de-installed. It will be passed the package's name as
-the first argument.
-
+to be the de-install procedure for the package. This can be any
+executable program (or shell script). It will be invoked automatically
+when the package is later (if ever) de-installed.
.It Fl r Ar rscript
Set
.Ar rscript
diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c
index dc85e02f341b..97b9528b5402 100644
--- a/usr.sbin/pkg_install/delete/perform.c
+++ b/usr.sbin/pkg_install/delete/perform.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: perform.c,v 1.17 1998/11/11 06:09:04 jkh Exp $";
+ "$Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp $";
#endif
/*
@@ -53,17 +53,6 @@ pkg_do(char *pkg)
char home[FILENAME_MAX];
PackingList p;
char *tmp;
- int len;
- /* support for separate pre/post install scripts */
- int new_m = 0;
- char pre_script[FILENAME_MAX] = DEINSTALL_FNAME;
- char post_script[FILENAME_MAX];
- char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX];
-
- if (!pkg || !(len = strlen(pkg)))
- return 1;
- if (pkg[len - 1] == '/')
- pkg[len - 1] = '\0';
/* Reset some state */
if (Plist.head)
@@ -71,22 +60,18 @@ pkg_do(char *pkg)
sprintf(LogDir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR,
pkg);
-
if (!fexists(LogDir)) {
warnx("no such package '%s' installed", pkg);
return 1;
}
-
if (!getcwd(home, FILENAME_MAX)) {
cleanup(0);
errx(2, "unable to get current working directory!");
}
-
if (chdir(LogDir) == FAIL) {
warnx("unable to change directory to %s! deinstall failed", LogDir);
return 1;
}
-
if (!isemptyfile(REQUIRED_BY_FNAME)) {
char buf[512];
warnx("package `%s' is required by these other packages\n"
@@ -102,29 +87,23 @@ pkg_do(char *pkg)
if (!Force)
return 1;
}
-
sanity_check(LogDir);
cfile = fopen(CONTENTS_FNAME, "r");
-
if (!cfile) {
warnx("unable to open '%s' file", CONTENTS_FNAME);
return 1;
}
-
/* If we have a prefix, add it now */
if (Prefix)
add_plist(&Plist, PLIST_CWD, Prefix);
read_plist(&Plist, cfile);
fclose(cfile);
p = find_plist(&Plist, PLIST_CWD);
-
if (!p) {
warnx("package '%s' doesn't have a prefix", pkg);
return 1;
}
-
setenv(PKG_PREFIX_VNAME, p->name, 1);
-
if (fexists(REQUIRE_FNAME)) {
if (Verbose)
printf("Executing 'require' script.\n");
@@ -136,81 +115,34 @@ pkg_do(char *pkg)
return 1;
}
}
-
- /* Test whether to use the old method of passing tokens to deinstallation
- * scripts, and set appropriate variables..
- */
-
- if (fexists(POST_DEINSTALL_FNAME)) {
- new_m = 1;
- sprintf(post_script, "%s", POST_DEINSTALL_FNAME);
- sprintf(pre_arg, "");
- sprintf(post_arg, "");
- } else {
- if (fexists(DEINSTALL_FNAME)) {
- sprintf(post_script, "%s", DEINSTALL_FNAME);
- sprintf(pre_arg, "DEINSTALL");
- sprintf(post_arg, "POST-DEINSTALL");
- }
- }
-
- if (!NoDeInstall && fexists(pre_script)) {
+ if (!NoDeInstall && fexists(DEINSTALL_FNAME)) {
if (Fake)
printf("Would execute de-install script at this point.\n");
else {
- vsystem("chmod +x %s", pre_script); /* make sure */
- if (vsystem("./%s %s %s", pre_script, pkg, pre_arg)) {
+ vsystem("chmod +x %s", DEINSTALL_FNAME); /* make sure */
+ if (vsystem("./%s %s DEINSTALL", DEINSTALL_FNAME, pkg)) {
warnx("deinstall script returned error status");
if (!Force)
return 1;
}
}
}
-
if (chdir(home) == FAIL) {
cleanup(0);
errx(2, "Toto! This doesn't look like Kansas anymore!");
}
-
if (!Fake) {
/* Some packages aren't packed right, so we need to just ignore delete_package()'s status. Ugh! :-( */
if (delete_package(FALSE, CleanDirs, &Plist) == FAIL)
warnx(
"couldn't entirely delete package (perhaps the packing list is\n"
"incorrectly specified?)");
- }
-
- if (chdir(LogDir) == FAIL) {
- warnx("unable to change directory to %s! deinstall failed", LogDir);
- return 1;
- }
-
- if (!NoDeInstall && fexists(post_script)) {
- if (Fake)
- printf("Would execute post-deinstall script at this point.\n");
- else {
- vsystem("chmod +x %s", post_script); /* make sure */
- if (vsystem("./%s %s %s", post_script, pkg, post_arg)) {
- warnx("post-deinstall script returned error status");
- if (!Force)
- return 1;
- }
- }
- }
-
- if (chdir(home) == FAIL) {
- cleanup(0);
- errx(2, "Toto! This doesn't look like Kansas anymore!");
- }
-
- if (!Fake) {
if (vsystem("%s -r %s", REMOVE_CMD, LogDir)) {
warnx("couldn't remove log entry in %s, deinstall failed", LogDir);
if (!Force)
return 1;
}
}
-
for (p = Plist.head; p ; p = p->next) {
if (p->type != PLIST_PKGDEP)
continue;
diff --git a/usr.sbin/pkg_install/delete/pkg_delete.1 b/usr.sbin/pkg_install/delete/pkg_delete.1
index 9941afe1ce3d..31888e7338c9 100644
--- a/usr.sbin/pkg_install/delete/pkg_delete.1
+++ b/usr.sbin/pkg_install/delete/pkg_delete.1
@@ -47,9 +47,9 @@ You are advised to verify the competence and identity of those who
provide installable package files. For extra protection, examine all
the package control files in the package record directory (
.Pa /var/db/pkg/<pkg-name>/ ).
-Pay particular attention to any +INSTALL, +POST-INSTALL, +DEINSTALL,
-+POST-DEINSTALL, +REQUIRE or +MTREE_DIRS files, and inspect the +CONTENTS
-file for
+Pay particular
+attention to any +INSTALL, +DEINSTALL, +REQUIRE or +MTREE_DIRS files,
+and inspect the +CONTENTS file for
.Cm @cwd ,
.Cm @mode
(check for setuid),
@@ -97,15 +97,10 @@ deinstall or require script fails.
.Pp
.Sh TECHNICAL DETAILS
-.Nm pkg_delete
+.Nm Pkg_delete
does pretty much what it says. It examines installed package records in
.Pa /var/db/pkg/<pkg-name> ,
deletes the package contents, and finally removes the package records.
-If the environment variable
-.Ev PKG_DBDIR
-is set, this overrides the
-.Pa /var/db/pkg/
-path shown above.
.Pp
If a package is required by other installed packages,
.Nm
@@ -145,71 +140,14 @@ The
.Nm deinstall
script is called as:
.Bd -filled -offset indent -compact
-.Cm script
+.Cm deinstall
.Ar <pkg-name>
.Ar DEINSTALL
.Ed
-where
-.Ar pkg-name
-is the name of the package in question and
-.Ar DEINSTALL
-is a keyword denoting this as the pre-deinstallation phase.
-
-.Cm Note:
-The
+Passing the keyword
.Ar DEINSTALL
-keyword will not appear if separate scripts for deinstall and post-deinstall
-are given during package creation time (using the
-.Cm Fl k
-and
-.Cm Fl K
-flags to
-.Xr pkg_create 1 ).
-.Pp
-If a
-.Cm post-deinstall
-script exists for the package, it is executed
-.Cm after
-all files are removed. It is this script's responsibility to clean up any
-additional messy details around the package's installation, and leave the
-system (hopefully) in the same state that it was prior to the installation
-of the package.
-
-The
-.Nm post-deinstall
-script is called as:
-.Bd -filled -offset indent -compact
-.Cm script
-.Ar <pkg-name>
-.Ar POST-DEINSTALL
-.Ed
-where
-.Ar pkg-name
-is the name of the package in question and
-.Ar POST-DEINSTALL
-is a keyword denoting this as the post-deinstallation phase.
-
-.Cm Note:
-The
-.Ar POST-DEINSTALL
-keyword will not appear if separate scripts for deinstall and post-deinstall
-are given during package creation time (using the
-.Cm Fl k
-and
-.Cm Fl K
-flags to
-.Xr pkg_create 1 ).
-
-Reasoning behind passing keywords such as
-.Ar DEINSTALL
-and
-.Ar POST-DEINSTALL
-is that it lets you potentially write only one program/script that handles
-all aspects of installation and deletion.
-
-But experience has proved that this is a lot more difficult to maintain and
-is not as advantageous as having separate scripts that handle each aspect of
-installation and deinstallation.
+lets you potentially write only one program/script that handles all
+aspects of installation and deletion.
.Pp
All scripts are called with the environment variable
.Ev PKG_PREFIX
@@ -223,14 +161,6 @@ option when running
.Nm
or
.Cm pkg_add .
-.Sh ENVIRONMENT
-The environment variable
-.Ev PKG_DBDIR
-specifies an alternative location for the installed package database.
-.Sh FILES
-.Bl -tag -width /var/db/pkg -compact
-.It Pa /var/db/pkg
-Default location of the installed package database.
.Sh SEE ALSO
.Xr pkg_add 1 ,
.Xr pkg_create 1 ,
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index 84a3b9a5253f..c409fe744c1d 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: perform.c,v 1.25 1998/09/11 07:26:58 jkh Exp $";
+ "$Id: perform.c,v 1.24 1998/02/16 17:16:38 jkh Exp $";
#endif
/*
@@ -179,12 +179,8 @@ pkg_do(char *pkg)
show_plist("Packing list:\n", &plist, (plist_t)-1);
if ((Flags & SHOW_INSTALL) && fexists(INSTALL_FNAME))
show_file("Install script:\n", INSTALL_FNAME);
- if ((Flags & SHOW_INSTALL) && fexists(POST_INSTALL_FNAME))
- show_file("Post-Install script:\n", POST_INSTALL_FNAME);
if ((Flags & SHOW_DEINSTALL) && fexists(DEINSTALL_FNAME))
show_file("De-Install script:\n", DEINSTALL_FNAME);
- if ((Flags & SHOW_DEINSTALL) && fexists(POST_DEINSTALL_FNAME))
- show_file("Post-DeInstall script:\n", POST_DEINSTALL_FNAME);
if ((Flags & SHOW_MTREE) && fexists(MTREE_FNAME))
show_file("mtree file:\n", MTREE_FNAME);
if (Flags & SHOW_PREFIX)
diff --git a/usr.sbin/pkg_install/info/pkg_info.1 b/usr.sbin/pkg_install/info/pkg_info.1
index 9105cca41d6d..3c3f5c1228b3 100644
--- a/usr.sbin/pkg_install/info/pkg_info.1
+++ b/usr.sbin/pkg_install/info/pkg_info.1
@@ -15,7 +15,7 @@
.\"
.\"
.\" @(#)pkg_info.1
-.\" $Id: pkg_info.1,v 1.18 1998/07/14 08:28:15 jkoshy Exp $
+.\" $Id$
.\"
.Dd November 25, 1994
.Dt pkg_info 1
@@ -134,7 +134,7 @@ If this variable is not set,
is used. If both are unset, the builtin defaults are used.
.Pp
.Ev PKG_DBDIR
-specifies an alternative location for the installed package database.
+names the location of the installed package database.
.Sh FILES
.Bl -tag -width /var/db/pkg -compact
.It Pa /var/tmp
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
index 9aed73cf3999..c12b35ca03dd 100644
--- a/usr.sbin/pkg_install/lib/file.c
+++ b/usr.sbin/pkg_install/lib/file.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: file.c,v 1.34 1998/10/14 18:52:04 jkh Exp $";
+ "$Id: file.c,v 1.33 1998/10/09 00:01:16 jkh Exp $";
#endif
/*
@@ -487,8 +487,8 @@ unpack(char *pkg, char *flist)
}
}
else
- strcpy(args, "-z");
- strcat(args, " -xpf");
+ strcpy(args, "z");
+ strcat(args, "xpf");
if (vsystem("tar %s %s %s", args, pkg, flist ? flist : "")) {
warnx("tar extract of %s failed!", pkg);
return 1;
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 595b2a1c2f7f..a0de2a459bc9 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -1,4 +1,4 @@
-/* $Id: lib.h,v 1.26 1998/02/16 17:16:47 jkh Exp $ */
+/* $Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@@ -66,9 +66,7 @@
#define COMMENT_FNAME "+COMMENT"
#define DESC_FNAME "+DESC"
#define INSTALL_FNAME "+INSTALL"
-#define POST_INSTALL_FNAME "+POST-INSTALL"
#define DEINSTALL_FNAME "+DEINSTALL"
-#define POST_DEINSTALL_FNAME "+POST-DEINSTALL"
#define REQUIRE_FNAME "+REQUIRE"
#define REQUIRED_BY_FNAME "+REQUIRED_BY"
#define DISPLAY_FNAME "+DISPLAY"
diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile
index 696479e3af8c..d8e1f87eefac 100644
--- a/usr.sbin/ppp/Makefile
+++ b/usr.sbin/ppp/Makefile
@@ -1,8 +1,8 @@
-# $Id: Makefile,v 1.49 1998/10/20 00:19:38 brian Exp $
+# $Id: Makefile,v 1.47 1998/08/31 12:14:31 brian Exp $
PROG= ppp
SRCS= arp.c async.c auth.c bundle.c cbcp.c ccp.c chap.c chat.c command.c \
- datalink.c deflate.c defs.c filter.c fsm.c hdlc.c id.c iface.c ip.c \
+ datalink.c deflate.c defs.c filter.c fsm.c hdlc.c id.c ip.c \
ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c mbuf.c modem.c \
mp.c pap.c physical.c pred.c probe.c prompt.c route.c server.c \
sig.c slcompress.c systems.c throughput.c timer.c tun.c vjcomp.c
@@ -10,7 +10,6 @@ CFLAGS+=-Wall
LDADD+= -lutil -lz
DPADD+= ${LIBUTIL} ${LIBZ}
BINMODE=4554
-BINOWN= root
BINGRP= network
MAN8= ppp.8
LDADD+= -lmd -lcrypt
diff --git a/usr.sbin/ppp/README.changes b/usr.sbin/ppp/README.changes
index b26cbd3882b1..3e4873e5a5f0 100644
--- a/usr.sbin/ppp/README.changes
+++ b/usr.sbin/ppp/README.changes
@@ -71,6 +71,3 @@ o Protocol-compressed packets are accepted even if they were denied
o Passwords aren't logged when logging the ``set server'' line.
o Command line options only need enough characters to uniquely identify
them. -a == -auto, -dd == -ddial etc. -interactive is also allowed.
-o If you don't like seeing additional interface aliases when running in
- -auto -alias mode, add ``iface clear'' to your ppp.linkdown file -
- check the sample file.
diff --git a/usr.sbin/ppp/arp.c b/usr.sbin/ppp/arp.c
index 283d90943fba..b819c9aa5a4e 100644
--- a/usr.sbin/ppp/arp.c
+++ b/usr.sbin/ppp/arp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: arp.c,v 1.30 1998/08/26 17:39:36 brian Exp $
+ * $Id: arp.c,v 1.29 1998/06/16 19:40:34 brian Exp $
*
*/
@@ -87,8 +87,10 @@ static struct {
char extra[128];
} arpmsg;
-static int
-arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add, int s)
+static int arpmsg_valid;
+
+int
+arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
{
int routes;
@@ -96,11 +98,9 @@ arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add, int s)
* Get the hardware address of an interface on the same subnet as our local
* address.
*/
-
memset(&arpmsg, 0, sizeof arpmsg);
if (!get_ether_addr(s, addr, &arpmsg.hwa)) {
- log_Printf(LogWARN, "%s: Cannot determine ethernet address for proxy ARP\n",
- inet_ntoa(addr));
+ log_Printf(LogWARN, "Cannot determine ethernet address for proxy ARP\n");
return 0;
}
routes = ID0socket(PF_ROUTE, SOCK_RAW, AF_INET);
@@ -109,7 +109,7 @@ arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add, int s)
strerror(errno));
return 0;
}
- arpmsg.hdr.rtm_type = add ? RTM_ADD : RTM_DELETE;
+ arpmsg.hdr.rtm_type = RTM_ADD;
arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC;
arpmsg.hdr.rtm_version = RTM_VERSION;
arpmsg.hdr.rtm_seq = ++bundle->routing_seq;
@@ -122,34 +122,44 @@ arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add, int s)
arpmsg.hdr.rtm_msglen = (char *) &arpmsg.hwa - (char *) &arpmsg
+ arpmsg.hwa.sdl_len;
-
-
- if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0 &&
- !(!add && errno == ESRCH)) {
- log_Printf(LogERROR, "%s proxy arp entry %s: %s\n",
- add ? "Add" : "Delete", inet_ntoa(addr), strerror(errno));
+ if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
+ log_Printf(LogERROR, "Add proxy arp entry: %s\n", strerror(errno));
close(routes);
return 0;
}
close(routes);
+ arpmsg_valid = 1;
return 1;
}
-int
-arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
-{
-
- return (arp_ProxySub(bundle, addr, 1, s));
-}
-
/*
* arp_ClearProxy - Delete the proxy ARP entry for the peer.
*/
int
arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
{
+ int routes;
+
+ if (!arpmsg_valid)
+ return 0;
+ arpmsg_valid = 0;
+
+ arpmsg.hdr.rtm_type = RTM_DELETE;
+ arpmsg.hdr.rtm_seq = ++bundle->routing_seq;
- return (arp_ProxySub(bundle, addr, 0, s));
+ routes = ID0socket(PF_ROUTE, SOCK_RAW, AF_INET);
+ if (routes < 0) {
+ log_Printf(LogERROR, "arp_SetProxy: opening routing socket: %s\n",
+ strerror(errno));
+ return 0;
+ }
+ if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
+ log_Printf(LogERROR, "Delete proxy arp entry: %s\n", strerror(errno));
+ close(routes);
+ return 0;
+ }
+ close(routes);
+ return 1;
}
#else /* RTM_VERSION */
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c
index 8d479843fabb..be406d024907 100644
--- a/usr.sbin/ppp/auth.c
+++ b/usr.sbin/ppp/auth.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: auth.c,v 1.33 1998/08/26 17:39:36 brian Exp $
+ * $Id: auth.c,v 1.32 1998/08/07 18:42:47 brian Exp $
*
* TODO:
* o Implement check against with registered IP addresses.
@@ -212,7 +212,7 @@ auth_GetSecret(struct bundle *bundle, const char *system, int len,
FILE *fp;
int n;
char *vector[5];
- static char buff[LINE_LEN];
+ char buff[LINE_LEN];
fp = OpenSecret(SECRETFILE);
if (fp == NULL)
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index 89388b951b6b..569d893f72dd 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.c,v 1.42 1998/12/14 19:24:28 brian Exp $
+ * $Id: bundle.c,v 1.34 1998/08/26 17:39:36 brian Exp $
*/
#include <sys/param.h>
@@ -89,7 +89,6 @@
#include "cbcp.h"
#include "datalink.h"
#include "ip.h"
-#include "iface.h"
#define SCATTER_SEGMENTS 4 /* version, datalink, name, physical */
#define SOCKET_OVERHEAD 100 /* additional buffer space for large */
@@ -149,6 +148,49 @@ bundle_NewPhase(struct bundle *bundle, u_int new)
}
}
+static int
+bundle_CleanInterface(const struct bundle *bundle)
+{
+ int s;
+ struct ifreq ifrq;
+ struct ifaliasreq ifra;
+
+ s = ID0socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ log_Printf(LogERROR, "bundle_CleanInterface: socket(): %s\n",
+ strerror(errno));
+ return (-1);
+ }
+ strncpy(ifrq.ifr_name, bundle->ifp.Name, sizeof ifrq.ifr_name - 1);
+ ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0';
+ while (ID0ioctl(s, SIOCGIFADDR, &ifrq) == 0) {
+ memset(&ifra.ifra_mask, '\0', sizeof ifra.ifra_mask);
+ strncpy(ifra.ifra_name, bundle->ifp.Name, sizeof ifra.ifra_name - 1);
+ ifra.ifra_name[sizeof ifra.ifra_name - 1] = '\0';
+ ifra.ifra_addr = ifrq.ifr_addr;
+ if (ID0ioctl(s, SIOCGIFDSTADDR, &ifrq) < 0) {
+ if (ifra.ifra_addr.sa_family == AF_INET)
+ log_Printf(LogERROR, "Can't get dst for %s on %s !\n",
+ inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr),
+ bundle->ifp.Name);
+ close(s);
+ return 0;
+ }
+ ifra.ifra_broadaddr = ifrq.ifr_dstaddr;
+ if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) {
+ if (ifra.ifra_addr.sa_family == AF_INET)
+ log_Printf(LogERROR, "Can't delete %s address on %s !\n",
+ inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr),
+ bundle->ifp.Name);
+ close(s);
+ return 0;
+ }
+ }
+ close(s);
+
+ return 1;
+}
+
static void
bundle_LayerStart(void *v, struct fsm *fp)
{
@@ -345,14 +387,14 @@ bundle_LayerUp(void *v, struct fsm *fp)
if (bundle->ncp.mp.active) {
struct datalink *dl;
- bundle->ifSpeed = 0;
+ bundle->ifp.Speed = 0;
for (dl = bundle->links; dl; dl = dl->next)
if (dl->state == DATALINK_OPEN)
- bundle->ifSpeed += modem_Speed(dl->physical);
+ bundle->ifp.Speed += modem_Speed(dl->physical);
tun_configure(bundle, bundle->ncp.mp.peer_mrru);
bundle->autoload.running = 1;
} else {
- bundle->ifSpeed = modem_Speed(p);
+ bundle->ifp.Speed = modem_Speed(p);
tun_configure(bundle, fsm2lcp(fp)->his_mru);
}
} else if (fp->proto == PROTO_IPCP) {
@@ -382,15 +424,15 @@ bundle_LayerDown(void *v, struct fsm *fp)
struct datalink *dl;
struct datalink *lost;
- bundle->ifSpeed = 0;
+ bundle->ifp.Speed = 0;
lost = NULL;
for (dl = bundle->links; dl; dl = dl->next)
if (fp == &dl->physical->link.lcp.fsm)
lost = dl;
else if (dl->state == DATALINK_OPEN)
- bundle->ifSpeed += modem_Speed(dl->physical);
+ bundle->ifp.Speed += modem_Speed(dl->physical);
- if (bundle->ifSpeed)
+ if (bundle->ifp.Speed)
/* Don't configure down to a speed of 0 */
tun_configure(bundle, bundle->ncp.mp.link.lcp.his_mru);
@@ -625,6 +667,12 @@ bundle_DescriptorRead(struct descriptor *d, struct bundle *bundle,
if (pri >= 0) {
struct mbuf *bp;
+#ifndef NOALIAS
+ if (bundle->AliasEnabled) {
+ PacketAliasIn(tun.data, sizeof tun.data);
+ n = ntohs(((struct ip *)tun.data)->ip_len);
+ }
+#endif
bp = mbuf_Alloc(n, MB_IPIN);
memcpy(MBUF_CTOP(bp), tun.data, n);
ip_Input(bundle, bp);
@@ -721,11 +769,10 @@ struct bundle *
bundle_Create(const char *prefix, int type, const char **argv)
{
int s, enoentcount, err;
- const char *ifname;
struct ifreq ifrq;
static struct bundle bundle; /* there can be only one */
- if (bundle.iface != NULL) { /* Already allocated ! */
+ if (bundle.ifp.Name != NULL) { /* Already allocated ! */
log_Printf(LogALERT, "bundle_Create: There's only one BUNDLE !\n");
return NULL;
}
@@ -756,8 +803,6 @@ bundle_Create(const char *prefix, int type, const char **argv)
log_SetTun(bundle.unit);
bundle.argv = argv;
- bundle.argv0 = argv[0];
- bundle.argv1 = argv[1];
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0) {
@@ -766,32 +811,24 @@ bundle_Create(const char *prefix, int type, const char **argv)
return NULL;
}
- ifname = strrchr(bundle.dev.Name, '/');
- if (ifname == NULL)
- ifname = bundle.dev.Name;
+ bundle.ifp.Name = strrchr(bundle.dev.Name, '/');
+ if (bundle.ifp.Name == NULL)
+ bundle.ifp.Name = bundle.dev.Name;
else
- ifname++;
-
- bundle.iface = iface_Create(ifname);
- if (bundle.iface == NULL) {
- close(s);
- close(bundle.dev.fd);
- return NULL;
- }
+ bundle.ifp.Name++;
/*
* Now, bring up the interface.
*/
memset(&ifrq, '\0', sizeof ifrq);
- strncpy(ifrq.ifr_name, ifname, sizeof ifrq.ifr_name - 1);
+ strncpy(ifrq.ifr_name, bundle.ifp.Name, sizeof ifrq.ifr_name - 1);
ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0';
if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) {
log_Printf(LogERROR, "bundle_Create: ioctl(SIOCGIFFLAGS): %s\n",
strerror(errno));
close(s);
- iface_Destroy(bundle.iface);
- bundle.iface = NULL;
close(bundle.dev.fd);
+ bundle.ifp.Name = NULL;
return NULL;
}
ifrq.ifr_flags |= IFF_UP;
@@ -799,17 +836,22 @@ bundle_Create(const char *prefix, int type, const char **argv)
log_Printf(LogERROR, "bundle_Create: ioctl(SIOCSIFFLAGS): %s\n",
strerror(errno));
close(s);
- iface_Destroy(bundle.iface);
- bundle.iface = NULL;
close(bundle.dev.fd);
+ bundle.ifp.Name = NULL;
return NULL;
}
close(s);
- log_Printf(LogPHASE, "Using interface: %s\n", ifname);
+ if ((bundle.ifp.Index = GetIfIndex(bundle.ifp.Name)) < 0) {
+ log_Printf(LogERROR, "Can't find interface index.\n");
+ close(bundle.dev.fd);
+ bundle.ifp.Name = NULL;
+ return NULL;
+ }
+ log_Printf(LogPHASE, "Using interface: %s\n", bundle.ifp.Name);
- bundle.ifSpeed = 0;
+ bundle.ifp.Speed = 0;
bundle.routing_seq = 0;
bundle.phase = PHASE_DEAD;
@@ -840,9 +882,8 @@ bundle_Create(const char *prefix, int type, const char **argv)
bundle.links = datalink_Create("deflink", &bundle, type);
if (bundle.links == NULL) {
log_Printf(LogALERT, "Cannot create data link: %s\n", strerror(errno));
- iface_Destroy(bundle.iface);
- bundle.iface = NULL;
close(bundle.dev.fd);
+ bundle.ifp.Name = NULL;
return NULL;
}
@@ -876,7 +917,7 @@ bundle_Create(const char *prefix, int type, const char **argv)
memset(&bundle.choked.timer, '\0', sizeof bundle.choked.timer);
/* Clean out any leftover crud */
- iface_Clear(bundle.iface, IFACE_CLEAR_ALL);
+ bundle_CleanInterface(&bundle);
bundle_LockTun(&bundle);
@@ -898,7 +939,7 @@ bundle_DownInterface(struct bundle *bundle)
}
memset(&ifrq, '\0', sizeof ifrq);
- strncpy(ifrq.ifr_name, bundle->iface->name, sizeof ifrq.ifr_name - 1);
+ strncpy(ifrq.ifr_name, bundle->ifp.Name, sizeof ifrq.ifr_name - 1);
ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0';
if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) {
log_Printf(LogERROR, "bundle_DownInterface: ioctl(SIOCGIFFLAGS): %s\n",
@@ -944,8 +985,7 @@ bundle_Destroy(struct bundle *bundle)
/* In case we never made PHASE_NETWORK */
bundle_Notify(bundle, EX_ERRDEAD);
- iface_Destroy(bundle->iface);
- bundle->iface = NULL;
+ bundle->ifp.Name = NULL;
}
struct rtmsg {
@@ -981,17 +1021,6 @@ bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst,
rtmes.m_rtm.rtm_pid = getpid();
rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC;
- if (cmd == RTM_ADD || cmd == RTM_CHANGE) {
- if (bundle->ncp.ipcp.cfg.sendpipe > 0) {
- rtmes.m_rtm.rtm_rmx.rmx_sendpipe = bundle->ncp.ipcp.cfg.sendpipe;
- rtmes.m_rtm.rtm_inits |= RTV_SPIPE;
- }
- if (bundle->ncp.ipcp.cfg.recvpipe > 0) {
- rtmes.m_rtm.rtm_rmx.rmx_recvpipe = bundle->ncp.ipcp.cfg.recvpipe;
- rtmes.m_rtm.rtm_inits |= RTV_RPIPE;
- }
- }
-
memset(&rtdata, '\0', sizeof rtdata);
rtdata.sin_len = sizeof rtdata;
rtdata.sin_family = AF_INET;
@@ -1003,11 +1032,24 @@ bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst,
cp += rtdata.sin_len;
if (cmd == RTM_ADD) {
if (gateway.s_addr == INADDR_ANY) {
- if (!ssh)
- log_Printf(LogERROR, "bundle_SetRoute: Cannot add a route with"
- " destination 0.0.0.0\n");
- close(s);
- return result;
+ /* Add a route through the interface */
+ struct sockaddr_dl dl;
+ const char *iname;
+ int ilen;
+
+ iname = Index2Nam(bundle->ifp.Index);
+ ilen = strlen(iname);
+ dl.sdl_len = sizeof dl - sizeof dl.sdl_data + ilen;
+ dl.sdl_family = AF_LINK;
+ dl.sdl_index = bundle->ifp.Index;
+ dl.sdl_type = 0;
+ dl.sdl_nlen = ilen;
+ dl.sdl_alen = 0;
+ dl.sdl_slen = 0;
+ strncpy(dl.sdl_data, iname, sizeof dl.sdl_data);
+ memcpy(cp, &dl, dl.sdl_len);
+ cp += dl.sdl_len;
+ rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY;
} else {
rtdata.sin_addr = gateway;
memcpy(cp, &rtdata, rtdata.sin_len);
@@ -1040,7 +1082,7 @@ failed:
(rtmes.m_rtm.rtm_errno == 0 && errno == EEXIST))) {
if (!bang) {
log_Printf(LogWARN, "Add route failed: %s already exists\n",
- dst.s_addr == 0 ? "default" : inet_ntoa(dst));
+ inet_ntoa(dst));
result = 0; /* Don't add to our dynamic list */
} else {
rtmes.m_rtm.rtm_type = cmd = RTM_CHANGE;
@@ -1197,10 +1239,9 @@ bundle_ShowStatus(struct cmdargs const *arg)
int remaining;
prompt_Printf(arg->prompt, "Phase %s\n", bundle_PhaseName(arg->bundle));
- prompt_Printf(arg->prompt, " Title: %s\n", arg->bundle->argv[0]);
prompt_Printf(arg->prompt, " Device: %s\n", arg->bundle->dev.Name);
prompt_Printf(arg->prompt, " Interface: %s @ %lubps\n",
- arg->bundle->iface->name, arg->bundle->ifSpeed);
+ arg->bundle->ifp.Name, arg->bundle->ifp.Speed);
prompt_Printf(arg->prompt, "\nDefaults:\n");
prompt_Printf(arg->prompt, " Label: %s\n", arg->bundle->cfg.label);
@@ -1239,17 +1280,6 @@ bundle_ShowStatus(struct cmdargs const *arg)
else
prompt_Printf(arg->prompt, "unspecified\n");
- prompt_Printf(arg->prompt, " sendpipe: ");
- if (arg->bundle->ncp.ipcp.cfg.sendpipe > 0)
- prompt_Printf(arg->prompt, "%ld\n", arg->bundle->ncp.ipcp.cfg.sendpipe);
- else
- prompt_Printf(arg->prompt, "unspecified\n");
- prompt_Printf(arg->prompt, " recvpipe: ");
- if (arg->bundle->ncp.ipcp.cfg.recvpipe > 0)
- prompt_Printf(arg->prompt, "%ld\n", arg->bundle->ncp.ipcp.cfg.recvpipe);
- else
- prompt_Printf(arg->prompt, "unspecified\n");
-
prompt_Printf(arg->prompt, " Sticky Routes: %s\n",
optval(arg->bundle, OPT_SROUTES));
prompt_Printf(arg->prompt, " ID check: %s\n",
@@ -1260,14 +1290,10 @@ bundle_ShowStatus(struct cmdargs const *arg)
optval(arg->bundle, OPT_PASSWDAUTH));
prompt_Printf(arg->prompt, " Proxy: %s\n",
optval(arg->bundle, OPT_PROXY));
- prompt_Printf(arg->prompt, " Proxyall: %s\n",
- optval(arg->bundle, OPT_PROXYALL));
prompt_Printf(arg->prompt, " Throughput: %s\n",
optval(arg->bundle, OPT_THROUGHPUT));
prompt_Printf(arg->prompt, " Utmp Logging: %s\n",
optval(arg->bundle, OPT_UTMP));
- prompt_Printf(arg->prompt, " Iface-Alias: %s\n",
- optval(arg->bundle, OPT_IFACEALIAS));
return 0;
}
@@ -1610,6 +1636,11 @@ bundle_SetMode(struct bundle *bundle, struct datalink *dl, int mode)
/* Regenerate phys_type and adjust autoload & idle timers */
bundle_LinksRemoved(bundle);
+ if (omode == PHYS_AUTO && !(bundle->phys_type.all & PHYS_AUTO) &&
+ bundle->phase != PHASE_NETWORK)
+ /* No auto links left */
+ ipcp_CleanInterface(&bundle->ncp.ipcp);
+
return 1;
}
@@ -1660,7 +1691,7 @@ bundle_setsid(struct bundle *bundle, int holdsession)
log_Printf(LogPHASE, "%d -> %d: %s session control\n",
(int)orig, (int)getpid(),
holdsession ? "Passed" : "Dropped");
- timer_InitService(0); /* Start the Timer Service */
+ timer_InitService();
break;
default:
close(fds[1]);
@@ -1717,30 +1748,3 @@ bundle_setsid(struct bundle *bundle, int holdsession)
break;
}
}
-
-int
-bundle_HighestState(struct bundle *bundle)
-{
- struct datalink *dl;
- int result = DATALINK_CLOSED;
-
- for (dl = bundle->links; dl; dl = dl->next)
- if (result < dl->state)
- result = dl->state;
-
- return result;
-}
-
-int
-bundle_Exception(struct bundle *bundle, int fd)
-{
- struct datalink *dl;
-
- for (dl = bundle->links; dl; dl = dl->next)
- if (dl->physical->fd == fd) {
- datalink_Down(dl, CLOSE_NORMAL);
- return 1;
- }
-
- return 0;
-}
diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h
index 0eb20e44a748..aee0cc23c594 100644
--- a/usr.sbin/ppp/bundle.h
+++ b/usr.sbin/ppp/bundle.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.h,v 1.19 1998/10/29 02:12:54 brian Exp $
+ * $Id: bundle.h,v 1.12 1998/08/07 18:42:47 brian Exp $
*/
#define PHASE_DEAD 0 /* Link is dead */
@@ -33,15 +33,13 @@
#define PHASE_TERMINATE 4 /* Terminating link */
/* cfg.opt bit settings */
-#define OPT_IDCHECK 0x0001
-#define OPT_IFACEALIAS 0x0002
-#define OPT_LOOPBACK 0x0004
-#define OPT_PASSWDAUTH 0x0008
-#define OPT_PROXY 0x0010
-#define OPT_PROXYALL 0x0020
-#define OPT_SROUTES 0x0040
-#define OPT_THROUGHPUT 0x0080
-#define OPT_UTMP 0x0100
+#define OPT_IDCHECK 0x01
+#define OPT_LOOPBACK 0x02
+#define OPT_PASSWDAUTH 0x04
+#define OPT_PROXY 0x08
+#define OPT_SROUTES 0x10
+#define OPT_THROUGHPUT 0x20
+#define OPT_UTMP 0x40
#define MAX_ENDDISC_CLASS 5
@@ -53,22 +51,22 @@ struct physical;
struct link;
struct server;
struct prompt;
-struct iface;
struct bundle {
struct descriptor desc; /* really all our datalinks */
int unit; /* The device/interface unit number */
const char **argv; /* From main() */
- const char *argv0; /* Original */
- const char *argv1; /* Original */
struct {
char Name[20]; /* The /dev/XXXX name */
int fd; /* The /dev/XXXX descriptor */
} dev;
- u_long ifSpeed; /* struct tuninfo speed */
- struct iface *iface; /* Interface information */
+ struct {
+ u_long Speed; /* struct tuninfo speed */
+ int Index; /* The interface index */
+ char *Name; /* The interface name */
+ } ifp;
int routing_seq; /* The current routing sequence number */
u_int phase; /* Curent phase */
@@ -183,5 +181,3 @@ extern int bundle_RenameDatalink(struct bundle *, struct datalink *,
const char *);
extern void bundle_setsid(struct bundle *, int);
extern void bundle_LockTun(struct bundle *);
-extern int bundle_HighestState(struct bundle *);
-extern int bundle_Exception(struct bundle *, int);
diff --git a/usr.sbin/ppp/cbcp.c b/usr.sbin/ppp/cbcp.c
index defa43186dd2..27f83e9f204d 100644
--- a/usr.sbin/ppp/cbcp.c
+++ b/usr.sbin/ppp/cbcp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cbcp.c,v 1.7 1998/10/31 17:38:48 brian Exp $
+ * $Id: cbcp.c,v 1.1 1998/08/07 18:44:16 brian Exp $
*/
#include <sys/types.h>
@@ -293,7 +293,7 @@ cbcp_SendReq(struct cbcp *cbcp)
break;
default:
- data.length = (char *)&data.delay - (char *)&data;
+ data.length = 2;
break;
}
@@ -354,12 +354,10 @@ cbcp_AdjustResponse(struct cbcp *cbcp, struct cbcp_data *data)
switch (data->type) {
case CBCP_NONUM:
- /*
- * If the callee offers no callback, we send our desired response
- * anyway. This is what Win95 does - although I can't find this
- * behaviour documented in the spec....
- */
- return 1;
+ if (cbcp->fsm.type == CBCP_NONUM)
+ return 1;
+ log_Printf(LogPHASE, "CBCP: server wants no callback !\n");
+ return 0;
case CBCP_CLIENTNUM:
if (cbcp->fsm.type == CBCP_CLIENTNUM) {
@@ -473,9 +471,7 @@ cbcp_SendResponse(struct cbcp *cbcp)
data.type = cbcp->fsm.type;
data.delay = cbcp->fsm.delay;
addr = (struct cbcp_addr *)data.addr_start;
- if (data.type == CBCP_NONUM)
- data.length = (char *)&data.delay - (char *)&data;
- else if (*cbcp->fsm.phone) {
+ if (*cbcp->fsm.phone) {
addr->type = CBCP_ADDR_PSTN;
strcpy(addr->addr, cbcp->fsm.phone);
data.length = (addr->addr + strlen(addr->addr) + 1) - (char *)&data;
@@ -552,13 +548,6 @@ cbcp_CheckResponse(struct cbcp *cbcp, struct cbcp_data *data)
log_Printf(LogPHASE, "Internal CBCP error - agreed on %d ??!?\n",
(int)cbcp->fsm.type);
return CBCP_ACTION_DOWN;
- } else if (data->type == CBCP_NONUM && cbcp->fsm.type == CBCP_CLIENTNUM) {
- /*
- * Client doesn't want CBCP after all....
- * We only allow this when ``set cbcp *'' has been specified.
- */
- cbcp->fsm.type = CBCP_NONUM;
- return CBCP_ACTION_ACK;
}
log_Printf(LogCBCP, "Invalid peer RESPONSE\n");
return CBCP_ACTION_REQ;
@@ -568,7 +557,6 @@ static void
cbcp_SendAck(struct cbcp *cbcp)
{
struct cbcp_data data;
- struct cbcp_addr *addr;
/* Only callees send ACKs */
@@ -576,22 +564,8 @@ cbcp_SendAck(struct cbcp *cbcp)
cbcp->fsm.id, cbcpstate(cbcp->fsm.state));
data.type = cbcp->fsm.type;
- switch (data.type) {
- case CBCP_NONUM:
- data.length = (char *)&data.delay - (char *)&data;
- break;
- case CBCP_CLIENTNUM:
- addr = (struct cbcp_addr *)data.addr_start;
- addr->type = CBCP_ADDR_PSTN;
- strcpy(addr->addr, cbcp->fsm.phone);
- data.delay = cbcp->fsm.delay;
- data.length = addr->addr + strlen(addr->addr) + 1 - (char *)&data;
- break;
- default:
- data.delay = cbcp->fsm.delay;
- data.length = data.addr_start - (char *)&data;
- break;
- }
+ data.delay = cbcp->fsm.delay;
+ data.length = data.addr_start - (char *)&data;
cbcp_data_Show(&data);
cbcp_Output(cbcp, CBCP_ACK, &data);
@@ -636,7 +610,6 @@ cbcp_Input(struct physical *p, struct mbuf *bp)
timer_Stop(&cbcp->fsm.timer);
if (cbcp_AdjustResponse(cbcp, data)) {
cbcp->fsm.restart = DEF_REQs;
- cbcp->fsm.id = head->id;
cbcp_SendResponse(cbcp);
} else
datalink_CBCPFailed(cbcp->p->dl);
@@ -648,11 +621,6 @@ cbcp_Input(struct physical *p, struct mbuf *bp)
log_Printf(LogCBCP, "%s: RecvResponse(%d) state = %s\n",
p->dl->name, head->id, cbcpstate(cbcp->fsm.state));
cbcp_data_Show(data);
- if (cbcp->fsm.id != head->id) {
- log_Printf(LogCBCP, "Warning: Expected id was %d, not %d\n",
- cbcp->fsm.id, head->id);
- cbcp->fsm.id = head->id;
- }
if (cbcp->fsm.state == CBCP_REQSENT || cbcp->fsm.state == CBCP_ACKSENT) {
timer_Stop(&cbcp->fsm.timer);
switch (cbcp_CheckResponse(cbcp, data)) {
@@ -685,11 +653,6 @@ cbcp_Input(struct physical *p, struct mbuf *bp)
log_Printf(LogCBCP, "%s: RecvAck(%d) state = %s\n",
p->dl->name, head->id, cbcpstate(cbcp->fsm.state));
cbcp_data_Show(data);
- if (cbcp->fsm.id != head->id) {
- log_Printf(LogCBCP, "Warning: Expected id was %d, not %d\n",
- cbcp->fsm.id, head->id);
- cbcp->fsm.id = head->id;
- }
if (cbcp->fsm.state == CBCP_RESPSENT) {
timer_Stop(&cbcp->fsm.timer);
datalink_CBCPComplete(cbcp->p->dl);
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index 8c41aa21f49b..fa81677b5820 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: chat.c,v 1.51 1998/08/07 18:42:47 brian Exp $
+ * $Id: chat.c,v 1.50 1998/06/27 14:18:01 brian Exp $
*/
#include <sys/types.h>
@@ -429,7 +429,6 @@ chat_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
if (begin >= ebegin && begin < eend &&
!strncmp(begin, c->argptr, c->arglen)) {
/* Got it ! */
- timer_Stop(&c->timeout);
if (memchr(begin + c->arglen - 1, '\n',
c->bufend - begin - c->arglen + 1) == NULL) {
/* force it into the log */
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index f31cb8b242c8..1b74fc55afda 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.c,v 1.176 1998/11/05 21:59:47 brian Exp $
+ * $Id: command.c,v 1.165 1998/08/29 23:02:42 brian Exp $
*
*/
#include <sys/types.h>
@@ -83,7 +83,6 @@
#include "chap.h"
#include "cbcp.h"
#include "datalink.h"
-#include "iface.h"
/* ``set'' values */
#define VAR_AUTHKEY 0
@@ -113,8 +112,6 @@
#define VAR_CALLBACK 24
#define VAR_CBCP 25
#define VAR_CHOKED 26
-#define VAR_SENDPIPE 27
-#define VAR_RECVPIPE 28
/* ``accept|deny|disable|enable'' masks */
#define NEG_HISMASK (1)
@@ -134,7 +131,7 @@
#define NEG_DNS 50
const char Version[] = "2.0";
-const char VersionDate[] = "$Date: 1998/11/05 21:59:47 $";
+const char VersionDate[] = "$Date: 1998/08/29 23:02:42 $";
static int ShowCommand(struct cmdargs const *);
static int TerminalCommand(struct cmdargs const *);
@@ -142,18 +139,15 @@ static int QuitCommand(struct cmdargs const *);
static int OpenCommand(struct cmdargs const *);
static int CloseCommand(struct cmdargs const *);
static int DownCommand(struct cmdargs const *);
+static int AllowCommand(struct cmdargs const *);
static int SetCommand(struct cmdargs const *);
static int LinkCommand(struct cmdargs const *);
static int AddCommand(struct cmdargs const *);
static int DeleteCommand(struct cmdargs const *);
static int NegotiateCommand(struct cmdargs const *);
static int ClearCommand(struct cmdargs const *);
-static int RunListCommand(struct cmdargs const *);
-static int IfaceAddCommand(struct cmdargs const *);
-static int IfaceDeleteCommand(struct cmdargs const *);
-static int IfaceClearCommand(struct cmdargs const *);
-static int SetProcTitle(struct cmdargs const *);
#ifndef NOALIAS
+static int AliasCommand(struct cmdargs const *);
static int AliasEnable(struct cmdargs const *);
static int AliasOption(struct cmdargs const *);
#endif
@@ -209,9 +203,7 @@ HelpCommand(struct cmdargs const *arg)
if (cmd->name && (cmd->lauth & arg->prompt->auth)) {
cx = showcx(cmd);
cxlen = cmax - strlen(cmd->name);
- if (n % cols != 0)
- prompt_Printf(arg->prompt, " ");
- prompt_Printf(arg->prompt, "%s%-*.*s: %-*.*s",
+ prompt_Printf(arg->prompt, " %s%-*.*s: %-*.*s",
cmd->name, cxlen, cxlen, cx, dmax, dmax, cmd->helpmes);
if (++n % cols == 0)
prompt_Printf(arg->prompt, "\n");
@@ -274,32 +266,29 @@ RenameCommand(struct cmdargs const *arg)
int
LoadCommand(struct cmdargs const *arg)
{
- const char *err;
- int n, mode;
+ const char *name;
- mode = arg->bundle->phys_type.all;
-
- if (arg->argn < arg->argc) {
- for (n = arg->argn; n < arg->argc; n++)
- if ((err = system_IsValid(arg->argv[n], arg->prompt, mode)) != NULL) {
- log_Printf(LogWARN, "%s: %s\n", arg->argv[n], err);
- return 1;
- }
+ if (arg->argc > arg->argn)
+ name = arg->argv[arg->argn];
+ else
+ name = "default";
- for (n = arg->argn; n < arg->argc; n++) {
- bundle_SetLabel(arg->bundle, arg->argv[arg->argc - 1]);
- system_Select(arg->bundle, arg->argv[n], CONFFILE, arg->prompt, arg->cx);
- }
- bundle_SetLabel(arg->bundle, arg->argv[arg->argc - 1]);
- } else if ((err = system_IsValid("default", arg->prompt, mode)) != NULL) {
- log_Printf(LogWARN, "default: %s\n", err);
+ if (!system_IsValid(name, arg->prompt, arg->bundle->phys_type.all)) {
+ log_Printf(LogWARN, "%s: Label not allowed\n", name);
return 1;
} else {
- bundle_SetLabel(arg->bundle, "default");
- system_Select(arg->bundle, "default", CONFFILE, arg->prompt, arg->cx);
- bundle_SetLabel(arg->bundle, "default");
+ /*
+ * Set the label before & after so that `set enddisc' works and
+ * we handle nested `load' commands.
+ */
+ bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
+ if (system_Select(arg->bundle, name, CONFFILE, arg->prompt, arg->cx) < 0) {
+ bundle_SetLabel(arg->bundle, NULL);
+ log_Printf(LogWARN, "%s: label not found.\n", name);
+ return -1;
+ }
+ bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
}
-
return 0;
}
@@ -385,25 +374,17 @@ subst(char *tgt, const char *oldstr, const char *newstr)
}
static void
-expand(char **nargv, int argc, char const *const *oargv, struct bundle *bundle,
- int inc0)
+expand(char **nargv, int argc, char const *const *oargv, struct bundle *bundle)
{
int arg;
- char pid[12];
- if (inc0)
- arg = 0; /* Start at arg 0 */
- else {
- nargv[0] = strdup(oargv[0]);
- arg = 1;
- }
- snprintf(pid, sizeof pid, "%d", getpid());
- for (; arg < argc; arg++) {
+ nargv[0] = strdup(oargv[0]);
+ for (arg = 1; arg < argc; arg++) {
nargv[arg] = strdup(oargv[arg]);
nargv[arg] = subst(nargv[arg], "HISADDR",
inet_ntoa(bundle->ncp.ipcp.peer_ip));
nargv[arg] = subst(nargv[arg], "AUTHNAME", bundle->cfg.auth.name);
- nargv[arg] = subst(nargv[arg], "INTERFACE", bundle->iface->name);
+ nargv[arg] = subst(nargv[arg], "INTERFACE", bundle->ifp.Name);
nargv[arg] = subst(nargv[arg], "MYADDR", inet_ntoa(bundle->ncp.ipcp.my_ip));
nargv[arg] = subst(nargv[arg], "USER", bundle->ncp.mp.peer.authname);
nargv[arg] = subst(nargv[arg], "PEER_ENDDISC",
@@ -414,7 +395,6 @@ expand(char **nargv, int argc, char const *const *oargv, struct bundle *bundle,
mp_Enddisc(bundle->ncp.mp.cfg.enddisc.class,
bundle->ncp.mp.cfg.enddisc.address,
bundle->ncp.mp.cfg.enddisc.len));
- nargv[arg] = subst(nargv[arg], "PROCESSID", pid);
nargv[arg] = subst(nargv[arg], "LABEL", bundle_GetLabel(bundle));
}
nargv[arg] = NULL;
@@ -480,7 +460,7 @@ ShellCommand(struct cmdargs const *arg, int bg)
argc = sizeof argv / sizeof argv[0] - 1;
log_Printf(LogWARN, "Truncating shell command to %d args\n", argc);
}
- expand(argv, argc, arg->argv + arg->argn, arg->bundle, 0);
+ expand(argv, argc, arg->argv + arg->argn, arg->bundle);
if (bg) {
pid_t p;
@@ -499,9 +479,8 @@ ShellCommand(struct cmdargs const *arg, int bg)
execl(shell, shell, NULL);
}
- log_Printf(LogWARN, "exec() of %s failed: %s\n",
- arg->argc > arg->argn ? arg->argv[arg->argn] : shell,
- strerror(errno));
+ log_Printf(LogWARN, "exec() of %s failed\n",
+ arg->argc > arg->argn ? arg->argv[arg->argn] : shell);
exit(255);
}
@@ -532,69 +511,6 @@ FgShellCommand(struct cmdargs const *arg)
return ShellCommand(arg, 0);
}
-#ifndef NOALIAS
-static struct cmdtab const AliasCommands[] =
-{
- {"addr", NULL, alias_RedirectAddr, LOCAL_AUTH,
- "static address translation", "alias addr [addr_local addr_alias]"},
- {"deny_incoming", NULL, AliasOption, LOCAL_AUTH,
- "stop incoming connections", "alias deny_incoming [yes|no]",
- (const void *) PKT_ALIAS_DENY_INCOMING},
- {"enable", NULL, AliasEnable, LOCAL_AUTH,
- "enable IP aliasing", "alias enable [yes|no]"},
- {"log", NULL, AliasOption, LOCAL_AUTH,
- "log aliasing link creation", "alias log [yes|no]",
- (const void *) PKT_ALIAS_LOG},
- {"port", NULL, alias_RedirectPort, LOCAL_AUTH,
- "port redirection", "alias port [proto addr_local:port_local port_alias]"},
- {"same_ports", NULL, AliasOption, LOCAL_AUTH,
- "try to leave port numbers unchanged", "alias same_ports [yes|no]",
- (const void *) PKT_ALIAS_SAME_PORTS},
- {"unregistered_only", NULL, AliasOption, LOCAL_AUTH,
- "alias unregistered (private) IP address space only",
- "alias unregistered_only [yes|no]",
- (const void *) PKT_ALIAS_UNREGISTERED_ONLY},
- {"use_sockets", NULL, AliasOption, LOCAL_AUTH,
- "allocate host sockets", "alias use_sockets [yes|no]",
- (const void *) PKT_ALIAS_USE_SOCKETS},
- {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
- "Display this message", "alias help|? [command]", AliasCommands},
- {NULL, NULL, NULL},
-};
-#endif
-
-static struct cmdtab const AllowCommands[] = {
- {"modes", "mode", AllowModes, LOCAL_AUTH,
- "Only allow certain ppp modes", "allow modes mode..."},
- {"users", "user", AllowUsers, LOCAL_AUTH,
- "Only allow ppp access to certain users", "allow users logname..."},
- {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
- "Display this message", "allow help|? [command]", AllowCommands},
- {NULL, NULL, NULL},
-};
-
-static struct cmdtab const IfaceCommands[] =
-{
- {"add", NULL, IfaceAddCommand, LOCAL_AUTH,
- "Add iface address", "iface add addr[/bits| mask] peer", NULL},
- {NULL, "add!", IfaceAddCommand, LOCAL_AUTH,
- "Add or change an iface address", "iface add! addr[/bits| mask] peer",
- (void *)1},
- {"clear", NULL, IfaceClearCommand, LOCAL_AUTH,
- "Clear iface address(es)", "iface clear"},
- {"delete", "rm", IfaceDeleteCommand, LOCAL_AUTH,
- "Delete iface address", "iface delete addr", NULL},
- {NULL, "rm!", IfaceDeleteCommand, LOCAL_AUTH,
- "Delete iface address", "iface delete addr", (void *)1},
- {NULL, "delete!", IfaceDeleteCommand, LOCAL_AUTH,
- "Delete iface address", "iface delete addr", (void *)1},
- {"show", NULL, iface_Show, LOCAL_AUTH,
- "Show iface address(es)", "iface show"},
- {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
- "Display this message", "alias help|? [command]", IfaceCommands},
- {NULL, NULL, NULL},
-};
-
static struct cmdtab const Commands[] = {
{"accept", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"accept option request", "accept option .."},
@@ -603,11 +519,11 @@ static struct cmdtab const Commands[] = {
{NULL, "add!", AddCommand, LOCAL_AUTH,
"add or change route", "add! dest mask gateway", (void *)1},
#ifndef NOALIAS
- {"alias", NULL, RunListCommand, LOCAL_AUTH,
- "alias control", "alias option [yes|no]", AliasCommands},
+ {"alias", NULL, AliasCommand, LOCAL_AUTH,
+ "alias control", "alias option [yes|no]"},
#endif
- {"allow", "auth", RunListCommand, LOCAL_AUTH,
- "Allow ppp access", "allow users|modes ....", AllowCommands},
+ {"allow", "auth", AllowCommand, LOCAL_AUTH,
+ "Allow ppp access", "allow users|modes ...."},
{"bg", "!bg", BgShellCommand, LOCAL_AUTH,
"Run a background command", "[!]bg command"},
{"clear", NULL, ClearCommand, LOCAL_AUTH | LOCAL_CX_OPT,
@@ -623,19 +539,17 @@ static struct cmdtab const Commands[] = {
{"deny", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"Deny option request", "deny option .."},
{"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT,
- "Dial and login", "dial|call [system ...]", NULL},
+ "Dial and login", "dial|call [remote]", NULL},
{"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"Disable option", "disable option .."},
{"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"Generate a down event", "down"},
{"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"Enable option", "enable option .."},
- {"iface", "interface", RunListCommand, LOCAL_AUTH,
- "interface control", "iface option ...", IfaceCommands},
{"link", "datalink", LinkCommand, LOCAL_AUTH,
"Link specific commands", "link name command ..."},
{"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT,
- "Load settings", "load [system ...]"},
+ "Load settings", "load [remote]"},
{"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"Open an FSM", "open! [lcp|ccp|ipcp]", (void *)1},
{"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
@@ -739,8 +653,6 @@ static struct cmdtab const ShowCommands[] = {
"packet filters", "show filter [in|out|dial|alive]"},
{"hdlc", NULL, hdlc_ReportStatus, LOCAL_AUTH | LOCAL_CX,
"HDLC errors", "show hdlc"},
- {"iface", "interface", iface_Show, LOCAL_AUTH,
- "Interface status", "show iface"},
{"ipcp", NULL, ipcp_Show, LOCAL_AUTH,
"IPCP status", "show ipcp"},
{"lcp", NULL, lcp_ReportStatus, LOCAL_AUTH | LOCAL_CX,
@@ -1286,12 +1198,13 @@ SetInterfaceAddr(struct cmdargs const *arg)
struct ipcp *ipcp = &arg->bundle->ncp.ipcp;
const char *hisaddr;
- if (arg->argc > arg->argn + 4)
- return -1;
-
hisaddr = NULL;
ipcp->cfg.my_range.ipaddr.s_addr = INADDR_ANY;
ipcp->cfg.peer_range.ipaddr.s_addr = INADDR_ANY;
+
+ if (arg->argc > arg->argn + 4)
+ return -1;
+
ipcp->cfg.HaveTriggerAddress = 0;
ipcp->cfg.netmask.s_addr = INADDR_ANY;
iplist_reset(&ipcp->cfg.peer_list);
@@ -1313,13 +1226,20 @@ SetInterfaceAddr(struct cmdargs const *arg)
}
}
- /* 0.0.0.0 means any address (0 bits) */
+ /*
+ * For backwards compatibility, 0.0.0.0 means any address.
+ */
if (ipcp->cfg.my_range.ipaddr.s_addr == INADDR_ANY) {
ipcp->cfg.my_range.mask.s_addr = INADDR_ANY;
ipcp->cfg.my_range.width = 0;
}
ipcp->my_ip.s_addr = ipcp->cfg.my_range.ipaddr.s_addr;
+ if (ipcp->cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
+ ipcp->cfg.peer_range.mask.s_addr = INADDR_ANY;
+ ipcp->cfg.peer_range.width = 0;
+ }
+
if (hisaddr && !ipcp_UseHisaddr(arg->bundle, hisaddr,
arg->bundle->phys_type.all & PHYS_AUTO))
return 4;
@@ -1355,32 +1275,24 @@ SetVariable(struct cmdargs const *arg)
switch (param) {
case VAR_AUTHKEY:
- switch (bundle_Phase(arg->bundle)) {
- case PHASE_DEAD:
- case PHASE_ESTABLISH:
- strncpy(arg->bundle->cfg.auth.key, argp,
- sizeof arg->bundle->cfg.auth.key - 1);
- arg->bundle->cfg.auth.key[sizeof arg->bundle->cfg.auth.key - 1] = '\0';
- break;
- default:
- err = "set authkey: Only available at phase DEAD/ESTABLISH\n";
- log_Printf(LogWARN, err);
- break;
+ if (bundle_Phase(arg->bundle) == PHASE_DEAD) {
+ strncpy(arg->bundle->cfg.auth.key, argp,
+ sizeof arg->bundle->cfg.auth.key - 1);
+ arg->bundle->cfg.auth.key[sizeof arg->bundle->cfg.auth.key - 1] = '\0';
+ } else {
+ err = "set authkey: Only available at phase DEAD\n";
+ log_Printf(LogWARN, err);
}
break;
case VAR_AUTHNAME:
- switch (bundle_Phase(arg->bundle)) {
- case PHASE_DEAD:
- case PHASE_ESTABLISH:
- strncpy(arg->bundle->cfg.auth.name, argp,
- sizeof arg->bundle->cfg.auth.name - 1);
- arg->bundle->cfg.auth.name[sizeof arg->bundle->cfg.auth.name-1] = '\0';
- break;
- default:
- err = "set authname: Only available at phase DEAD/ESTABLISH\n";
- log_Printf(LogWARN, err);
- break;
+ if (bundle_Phase(arg->bundle) == PHASE_DEAD) {
+ strncpy(arg->bundle->cfg.auth.name, argp,
+ sizeof arg->bundle->cfg.auth.name - 1);
+ arg->bundle->cfg.auth.name[sizeof arg->bundle->cfg.auth.name - 1] = '\0';
+ } else {
+ err = "set authname: Only available at phase DEAD\n";
+ log_Printf(LogWARN, err);
}
break;
@@ -1463,19 +1375,9 @@ SetVariable(struct cmdargs const *arg)
break;
case VAR_MRRU:
- switch (bundle_Phase(arg->bundle)) {
- case PHASE_DEAD:
- break;
- case PHASE_ESTABLISH:
- /* Make sure none of our links are DATALINK_LCP or greater */
- if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) {
- log_Printf(LogWARN, "mrru: Only changable before LCP negotiations\n");
- return 1;
- }
- break;
- default:
- log_Printf(LogWARN, "mrru: Only changable at phase DEAD/ESTABLISH\n");
- return 1;
+ if (bundle_Phase(arg->bundle) != PHASE_DEAD) {
+ log_Printf(LogWARN, "mrru: Only changable at phase DEAD\n");
+ return 1;
}
long_val = atol(argp);
if (long_val && long_val < MIN_MRU) {
@@ -1681,16 +1583,7 @@ SetVariable(struct cmdargs const *arg)
if (arg->bundle->cfg.choked.timeout <= 0)
arg->bundle->cfg.choked.timeout = CHOKED_TIMEOUT;
break;
-
- case VAR_SENDPIPE:
- long_val = atol(argp);
- arg->bundle->ncp.ipcp.cfg.sendpipe = long_val;
- break;
-
- case VAR_RECVPIPE:
- long_val = atol(argp);
- arg->bundle->ncp.ipcp.cfg.recvpipe = long_val;
- break;
+
}
return err ? 1 : 0;
@@ -1786,16 +1679,10 @@ static struct cmdtab const SetCommands[] = {
"modem parity", "set parity [odd|even|none]"},
{"phone", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "telephone number(s)",
"set phone phone1[:phone2[...]]", (const void *)VAR_PHONE},
- {"proctitle", "title", SetProcTitle, LOCAL_AUTH,
- "Process title", "set proctitle [value]"},
{"reconnect", NULL, datalink_SetReconnect, LOCAL_AUTH | LOCAL_CX,
"Reconnect timeout", "set reconnect value ntries"},
- {"recvpipe", NULL, SetVariable, LOCAL_AUTH,
- "RECVPIPE value", "set recvpipe value", (const void *)VAR_RECVPIPE},
{"redial", NULL, datalink_SetRedial, LOCAL_AUTH | LOCAL_CX,
"Redial timeout", "set redial value|random[.value|random] [attempts]"},
- {"sendpipe", NULL, SetVariable, LOCAL_AUTH,
- "SENDPIPE value", "set sendpipe value", (const void *)VAR_SENDPIPE},
{"server", "socket", SetServer, LOCAL_AUTH,
"server port", "set server|socket TcpPort|LocalName|none password [mask]"},
{"speed", NULL, SetModemSpeed, LOCAL_AUTH | LOCAL_CX,
@@ -1828,6 +1715,7 @@ SetCommand(struct cmdargs const *arg)
return 0;
}
+
static int
AddCommand(struct cmdargs const *arg)
{
@@ -1869,7 +1757,9 @@ AddCommand(struct cmdargs const *arg)
if (strcasecmp(arg->argv[arg->argn+gw], "HISADDR") == 0) {
gateway = arg->bundle->ncp.ipcp.peer_ip;
addrs |= ROUTE_GWHISADDR;
- } else
+ } else if (strcasecmp(arg->argv[arg->argn+gw], "INTERFACE") == 0)
+ gateway.s_addr = INADDR_ANY;
+ else
gateway = GetIpAddr(arg->argv[arg->argn+gw]);
if (bundle_SetRoute(arg->bundle, RTM_ADD, dest, gateway, netmask,
@@ -1916,6 +1806,51 @@ DeleteCommand(struct cmdargs const *arg)
}
#ifndef NOALIAS
+static struct cmdtab const AliasCommands[] =
+{
+ {"addr", NULL, alias_RedirectAddr, LOCAL_AUTH,
+ "static address translation", "alias addr [addr_local addr_alias]"},
+ {"deny_incoming", NULL, AliasOption, LOCAL_AUTH,
+ "stop incoming connections", "alias deny_incoming [yes|no]",
+ (const void *) PKT_ALIAS_DENY_INCOMING},
+ {"enable", NULL, AliasEnable, LOCAL_AUTH,
+ "enable IP aliasing", "alias enable [yes|no]"},
+ {"log", NULL, AliasOption, LOCAL_AUTH,
+ "log aliasing link creation", "alias log [yes|no]",
+ (const void *) PKT_ALIAS_LOG},
+ {"port", NULL, alias_RedirectPort, LOCAL_AUTH,
+ "port redirection", "alias port [proto addr_local:port_local port_alias]"},
+ {"same_ports", NULL, AliasOption, LOCAL_AUTH,
+ "try to leave port numbers unchanged", "alias same_ports [yes|no]",
+ (const void *) PKT_ALIAS_SAME_PORTS},
+ {"unregistered_only", NULL, AliasOption, LOCAL_AUTH,
+ "alias unregistered (private) IP address space only",
+ "alias unregistered_only [yes|no]",
+ (const void *) PKT_ALIAS_UNREGISTERED_ONLY},
+ {"use_sockets", NULL, AliasOption, LOCAL_AUTH,
+ "allocate host sockets", "alias use_sockets [yes|no]",
+ (const void *) PKT_ALIAS_USE_SOCKETS},
+ {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
+ "Display this message", "alias help|? [command]", AliasCommands},
+ {NULL, NULL, NULL},
+};
+
+
+static int
+AliasCommand(struct cmdargs const *arg)
+{
+ if (arg->argc > arg->argn)
+ FindExec(arg->bundle, AliasCommands, arg->argc, arg->argn, arg->argv,
+ arg->prompt, arg->cx);
+ else if (arg->prompt)
+ prompt_Printf(arg->prompt, "Use `alias help' to get a list or `alias help"
+ " <option>' for syntax help.\n");
+ else
+ log_Printf(LogWARN, "alias command must have arguments\n");
+
+ return 0;
+}
+
static int
AliasEnable(struct cmdargs const *arg)
{
@@ -1925,8 +1860,6 @@ AliasEnable(struct cmdargs const *arg)
return 0;
} else if (strcasecmp(arg->argv[arg->argn], "no") == 0) {
arg->bundle->AliasEnabled = 0;
- arg->bundle->cfg.opt &= ~OPT_IFACEALIAS;
- /* Don't iface_Clear() - there may be manually configured addresses */
return 0;
}
}
@@ -1959,6 +1892,32 @@ AliasOption(struct cmdargs const *arg)
}
#endif /* #ifndef NOALIAS */
+static struct cmdtab const AllowCommands[] = {
+ {"modes", "mode", AllowModes, LOCAL_AUTH,
+ "Only allow certain ppp modes", "allow modes mode..."},
+ {"users", "user", AllowUsers, LOCAL_AUTH,
+ "Allow users access to ppp", "allow users logname..."},
+ {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
+ "Display this message", "allow help|? [command]", AllowCommands},
+ {NULL, NULL, NULL},
+};
+
+static int
+AllowCommand(struct cmdargs const *arg)
+{
+ /* arg->bundle may be NULL (see system_IsValid()) ! */
+ if (arg->argc > arg->argn)
+ FindExec(arg->bundle, AllowCommands, arg->argc, arg->argn, arg->argv,
+ arg->prompt, arg->cx);
+ else if (arg->prompt)
+ prompt_Printf(arg->prompt, "Use `allow ?' to get a list or `allow ? <cmd>'"
+ " for syntax help.\n");
+ else
+ log_Printf(LogWARN, "allow command must have arguments\n");
+
+ return 0;
+}
+
static int
LinkCommand(struct cmdargs const *arg)
{
@@ -2086,22 +2045,6 @@ OptSet(struct cmdargs const *arg)
}
static int
-IfaceAliasOptSet(struct cmdargs const *arg)
-{
- unsigned save = arg->bundle->cfg.opt;
- int result = OptSet(arg);
-
- if (result == 0)
- if (Enabled(arg->bundle, OPT_IFACEALIAS) && !arg->bundle->AliasEnabled) {
- arg->bundle->cfg.opt = save;
- log_Printf(LogWARN, "Cannot enable iface-alias without IP aliasing\n");
- result = 2;
- }
-
- return result;
-}
-
-static int
NegotiateSet(struct cmdargs const *arg)
{
long param = (long)arg->cmd->args;
@@ -2162,24 +2105,12 @@ NegotiateSet(struct cmdargs const *arg)
cx->physical->link.lcp.cfg.protocomp |= add;
break;
case NEG_SHORTSEQ:
- switch (bundle_Phase(arg->bundle)) {
- case PHASE_DEAD:
- break;
- case PHASE_ESTABLISH:
- /* Make sure none of our links are DATALINK_LCP or greater */
- if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) {
- log_Printf(LogWARN, "shortseq: Only changable before"
- " LCP negotiations\n");
- return 1;
- }
- break;
- default:
- log_Printf(LogWARN, "shortseq: Only changable at phase"
- " DEAD/ESTABLISH\n");
- return 1;
+ if (bundle_Phase(arg->bundle) != PHASE_DEAD)
+ log_Printf(LogWARN, "shortseq: Only changable at phase DEAD\n");
+ else {
+ arg->bundle->ncp.mp.cfg.shortseq &= keep;
+ arg->bundle->ncp.mp.cfg.shortseq |= add;
}
- arg->bundle->ncp.mp.cfg.shortseq &= keep;
- arg->bundle->ncp.mp.cfg.shortseq |= add;
break;
case NEG_VJCOMP:
arg->bundle->ncp.ipcp.cfg.vj.neg &= keep;
@@ -2193,17 +2124,12 @@ NegotiateSet(struct cmdargs const *arg)
static struct cmdtab const NegotiateCommands[] = {
{"idcheck", NULL, OptSet, LOCAL_AUTH, "Check FSM reply ids",
"disable|enable", (const void *)OPT_IDCHECK},
- {"iface-alias", NULL, IfaceAliasOptSet, LOCAL_AUTH,
- "retain interface addresses", "disable|enable",
- (const void *)OPT_IFACEALIAS},
{"loopback", NULL, OptSet, LOCAL_AUTH, "Loop packets for local iface",
"disable|enable", (const void *)OPT_LOOPBACK},
{"passwdauth", NULL, OptSet, LOCAL_AUTH, "Use passwd file",
"disable|enable", (const void *)OPT_PASSWDAUTH},
- {"proxy", NULL, OptSet, LOCAL_AUTH, "Create a proxy ARP entry",
+ {"proxy", NULL, OptSet, LOCAL_AUTH, "Create proxy ARP entry",
"disable|enable", (const void *)OPT_PROXY},
- {"proxyall", NULL, OptSet, LOCAL_AUTH, "Proxy ARP for all remote hosts",
- "disable|enable", (const void *)OPT_PROXYALL},
{"sroutes", NULL, OptSet, LOCAL_AUTH, "Use sticky routes",
"disable|enable", (const void *)OPT_SROUTES},
{"throughput", NULL, OptSet, LOCAL_AUTH, "Rolling throughput",
@@ -2211,7 +2137,7 @@ static struct cmdtab const NegotiateCommands[] = {
{"utmp", NULL, OptSet, LOCAL_AUTH, "Log connections in utmp",
"disable|enable", (const void *)OPT_UTMP},
-#define OPT_MAX 9 /* accept/deny allowed below and not above */
+#define OPT_MAX 7 /* accept/deny allowed below and not above */
{"acfcomp", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
"Address & Control field compression", "accept|deny|disable|enable",
@@ -2330,144 +2256,3 @@ ClearCommand(struct cmdargs const *arg)
throughput_clear(t, clear_type, arg->prompt);
return 0;
}
-
-static int
-RunListCommand(struct cmdargs const *arg)
-{
- const char *cmd = arg->argc ? arg->argv[arg->argc - 1] : "???";
-
- if (arg->argc > arg->argn)
- FindExec(arg->bundle, arg->cmd->args, arg->argc, arg->argn, arg->argv,
- arg->prompt, arg->cx);
- else if (arg->prompt)
- prompt_Printf(arg->prompt, "Use `%s help' to get a list or `%s help"
- " <option>' for syntax help.\n", cmd, cmd);
- else
- log_Printf(LogWARN, "%s command must have arguments\n", cmd);
-
- return 0;
-}
-
-static int
-IfaceAddCommand(struct cmdargs const *arg)
-{
- int bits, n, how;
- struct in_addr ifa, mask, brd;
-
- if (arg->argc == arg->argn + 1) {
- if (!ParseAddr(NULL, 1, arg->argv + arg->argn, &ifa, NULL, NULL))
- return -1;
- mask.s_addr = brd.s_addr = INADDR_BROADCAST;
- } else {
- if (arg->argc == arg->argn + 2) {
- if (!ParseAddr(NULL, 1, arg->argv + arg->argn, &ifa, &mask, &bits))
- return -1;
- n = 1;
- } else if (arg->argc == arg->argn + 3) {
- if (!ParseAddr(NULL, 1, arg->argv + arg->argn, &ifa, NULL, NULL))
- return -1;
- if (!ParseAddr(NULL, 1, arg->argv + arg->argn + 1, &mask, NULL, NULL))
- return -1;
- n = 2;
- } else
- return -1;
-
- if (!ParseAddr(NULL, 1, arg->argv + arg->argn + n, &brd, NULL, NULL))
- return -1;
- }
-
- how = IFACE_ADD_LAST;
- if (arg->cmd->args)
- how |= IFACE_FORCE_ADD;
-
- return !iface_inAdd(arg->bundle->iface, ifa, mask, brd, how);
-}
-
-static int
-IfaceDeleteCommand(struct cmdargs const *arg)
-{
- struct in_addr ifa;
- int ok;
-
- if (arg->argc != arg->argn + 1)
- return -1;
-
- if (!ParseAddr(NULL, 1, arg->argv + arg->argn, &ifa, NULL, NULL))
- return -1;
-
- if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED &&
- arg->bundle->ncp.ipcp.my_ip.s_addr == ifa.s_addr) {
- log_Printf(LogWARN, "%s: Cannot remove active interface address\n",
- inet_ntoa(ifa));
- return 1;
- }
-
- ok = iface_inDelete(arg->bundle->iface, ifa);
- if (!ok) {
- if (arg->cmd->args)
- ok = 1;
- else if (arg->prompt)
- prompt_Printf(arg->prompt, "%s: No such address\n", inet_ntoa(ifa));
- else
- log_Printf(LogWARN, "%s: No such address\n", inet_ntoa(ifa));
- }
-
- return !ok;
-}
-
-static int
-IfaceClearCommand(struct cmdargs const *arg)
-{
- int how;
-
- if (arg->argc != arg->argn)
- return -1;
-
- how = arg->bundle->ncp.ipcp.fsm.state == ST_OPENED ||
- arg->bundle->phys_type.all & PHYS_AUTO ?
- IFACE_CLEAR_ALIASES : IFACE_CLEAR_ALL;
- iface_Clear(arg->bundle->iface, how);
-
- return 0;
-}
-
-static int
-SetProcTitle(struct cmdargs const *arg)
-{
- static char title[LINE_LEN];
- char *argv[MAXARGS], *ptr;
- int len, remaining, f, argc = arg->argc - arg->argn;
-
- if (arg->argc == arg->argn) {
- arg->bundle->argv[0] = arg->bundle->argv0;
- arg->bundle->argv[1] = arg->bundle->argv1;
- return 0;
- }
-
- if (argc >= sizeof argv / sizeof argv[0]) {
- argc = sizeof argv / sizeof argv[0] - 1;
- log_Printf(LogWARN, "Truncating proc title to %d args\n", argc);
- }
- expand(argv, argc, arg->argv + arg->argn, arg->bundle, 1);
-
- ptr = title;
- remaining = sizeof title - 1;
- for (f = 0; f < argc && remaining; f++) {
- if (f) {
- *ptr++ = ' ';
- remaining--;
- }
- len = strlen(argv[f]);
- if (len > remaining)
- len = remaining;
- memcpy(ptr, argv[f], len);
- remaining -= len;
- ptr += len;
- }
- *ptr = '\0';
-
- arg->bundle->argv[0] = title;
- arg->bundle->argv[1] = NULL;
-
- return 0;
-}
diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c
index 7e7f8f9fb129..cd6bd0ad3002 100644
--- a/usr.sbin/ppp/datalink.c
+++ b/usr.sbin/ppp/datalink.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: datalink.c,v 1.24 1999/01/12 21:50:20 brian Exp $
+ * $Id: datalink.c,v 1.18 1998/08/09 15:34:11 brian Exp $
*/
#include <sys/types.h>
@@ -256,9 +256,9 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
log_Printf(LogCHAT, "%s: Dial attempt %u of %d\n",
dl->name, dl->cfg.dial.max - dl->dial_tries,
dl->cfg.dial.max);
+ return datalink_UpdateSet(d, r, w, e, n);
} else
datalink_LoginDone(dl);
- return datalink_UpdateSet(d, r, w, e, n);
} else {
if (!(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)) &&
dl->cfg.dial.max)
@@ -303,9 +303,8 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
chat_Init(&dl->chat, dl->physical, dl->cfg.script.login, 0, NULL);
return datalink_UpdateSet(d, r, w, e, n);
case DATALINK_LOGIN:
- dl->phone.alt = NULL;
datalink_LoginDone(dl);
- return datalink_UpdateSet(d, r, w, e, n);
+ break;
}
break;
case CHAT_FAILED:
@@ -553,17 +552,13 @@ datalink_CBCPFailed(struct datalink *dl)
void
datalink_AuthOk(struct datalink *dl)
{
- if ((dl->physical->link.lcp.his_callback.opmask &
- CALLBACK_BIT(CALLBACK_CBCP) ||
- dl->physical->link.lcp.want_callback.opmask &
- CALLBACK_BIT(CALLBACK_CBCP)) &&
- !(dl->physical->link.lcp.want_callback.opmask &
- CALLBACK_BIT(CALLBACK_AUTH))) {
- /* We must have agreed CBCP if AUTH isn't there any more */
+ if (dl->physical->link.lcp.his_callback.opmask ==
+ CALLBACK_BIT(CALLBACK_CBCP) ||
+ dl->physical->link.lcp.want_callback.opmask ==
+ CALLBACK_BIT(CALLBACK_CBCP)) {
datalink_NewState(dl, DATALINK_CBCP);
cbcp_Up(&dl->cbcp);
} else if (dl->physical->link.lcp.want_callback.opmask) {
- /* It's not CBCP */
log_Printf(LogPHASE, "%s: Shutdown and await peer callback\n", dl->name);
datalink_NewState(dl, DATALINK_LCP);
fsm_Close(&dl->physical->link.lcp.fsm);
@@ -816,7 +811,6 @@ datalink_Destroy(struct datalink *dl)
}
}
- timer_Stop(&dl->dial_timer);
result = dl->next;
modem_Destroy(dl->physical);
free(dl->name);
@@ -990,14 +984,8 @@ datalink_Show(struct cmdargs const *arg)
prompt_Printf(arg->prompt, "%scbcp\n", comma ? ", " : "");
prompt_Printf(arg->prompt, " CBCP: delay: %ds\n",
arg->cx->cfg.cbcp.delay);
- prompt_Printf(arg->prompt, " phone: ");
- if (!strcmp(arg->cx->cfg.cbcp.phone, "*")) {
- if (arg->cx->physical->type & PHYS_DIRECT)
- prompt_Printf(arg->prompt, "Caller decides\n");
- else
- prompt_Printf(arg->prompt, "Dialback server decides\n");
- } else
- prompt_Printf(arg->prompt, "%s\n", arg->cx->cfg.cbcp.phone);
+ prompt_Printf(arg->prompt, " phone: %s\n",
+ arg->cx->cfg.cbcp.phone);
prompt_Printf(arg->prompt, " timeout: %lds\n",
arg->cx->cfg.cbcp.fsmretry);
} else
diff --git a/usr.sbin/ppp/filter.c b/usr.sbin/ppp/filter.c
index cd5a6443eb4f..3437d11ae874 100644
--- a/usr.sbin/ppp/filter.c
+++ b/usr.sbin/ppp/filter.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: filter.c,v 1.25 1998/06/27 12:03:48 brian Exp $
+ * $Id: filter.c,v 1.24 1998/06/15 19:06:07 brian Exp $
*
* TODO: Shoud send ICMP error message when we discard packets.
*/
@@ -90,9 +90,9 @@ ParseAddr(struct ipcp *ipcp, int argc, char const *const *argv,
cp = pmask || pwidth ? strchr(*argv, '/') : NULL;
len = cp ? cp - *argv : strlen(*argv);
- if (ipcp && strncasecmp(*argv, "HISADDR", len) == 0)
+ if (strncasecmp(*argv, "HISADDR", len) == 0)
*paddr = ipcp->peer_ip;
- else if (ipcp && strncasecmp(*argv, "MYADDR", len) == 0)
+ else if (strncasecmp(*argv, "MYADDR", len) == 0)
*paddr = ipcp->my_ip;
else if (len > 15)
log_Printf(LogWARN, "ParseAddr: %s: Bad address\n", *argv);
@@ -121,12 +121,8 @@ ParseAddr(struct ipcp *ipcp, int argc, char const *const *argv,
if (pwidth)
*pwidth = bits;
- if (pmask) {
- if (paddr->s_addr == INADDR_ANY)
- pmask->s_addr = INADDR_ANY;
- else
- pmask->s_addr = htonl(netmasks[bits]);
- }
+ if (pmask)
+ pmask->s_addr = htonl(netmasks[bits]);
return (1);
}
diff --git a/usr.sbin/ppp/filter.h b/usr.sbin/ppp/filter.h
index 0505e7d6e300..f96af409ada6 100644
--- a/usr.sbin/ppp/filter.h
+++ b/usr.sbin/ppp/filter.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: filter.h,v 1.12 1998/05/21 21:45:16 brian Exp $
+ * $Id: filter.h,v 1.11.2.7 1998/05/01 19:24:30 brian Exp $
*
* TODO:
*/
@@ -66,7 +66,7 @@ struct filterent {
} opt;
};
-#define MAXFILTERS 40 /* in each filter set */
+#define MAXFILTERS 20 /* in each filter set */
struct filter {
struct filterent rule[MAXFILTERS]; /* incoming packet filter */
diff --git a/usr.sbin/ppp/iface.c b/usr.sbin/ppp/iface.c
deleted file mode 100644
index bca10ee0c3c6..000000000000
--- a/usr.sbin/ppp/iface.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/*-
- * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: iface.c,v 1.1 1998/10/22 02:32:49 brian Exp $
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/route.h>
-#include <arpa/inet.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <sys/un.h>
-
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/sysctl.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "defs.h"
-#include "command.h"
-#include "mbuf.h"
-#include "log.h"
-#include "id.h"
-#include "timer.h"
-#include "fsm.h"
-#include "iplist.h"
-#include "lqr.h"
-#include "hdlc.h"
-#include "throughput.h"
-#include "slcompress.h"
-#include "filter.h"
-#include "descriptor.h"
-#include "ipcp.h"
-#include "lcp.h"
-#include "ccp.h"
-#include "link.h"
-#include "mp.h"
-#include "bundle.h"
-#include "prompt.h"
-#include "iface.h"
-
-
-static int
-bitsinmask(struct in_addr mask)
-{
- u_int32_t bitmask, maskaddr;
- int bits;
-
- bitmask = 0xffffffff;
- maskaddr = ntohl(mask.s_addr);
- for (bits = 32; bits >= 0; bits--) {
- if (maskaddr == bitmask)
- break;
- bitmask &= ~(1 << (32 - bits));
- }
-
- return bits;
-}
-
-struct iface *
-iface_Create(const char *name)
-{
- int mib[6], i, s;
- size_t needed;
- char *buf, *ptr, *end, *cp, *lim;
- struct if_msghdr *ifm;
- struct ifa_msghdr *ifam;
- struct sockaddr_dl *dl;
- struct rt_addrinfo rti;
- struct iface *iface;
- struct iface_addr *addr;
-
- s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0) {
- fprintf(stderr, "iface_Create: socket(): %s\n", strerror(errno));
- return NULL;
- }
-
- mib[0] = CTL_NET;
- mib[1] = PF_ROUTE;
- mib[2] = 0;
- mib[3] = 0;
- mib[4] = NET_RT_IFLIST;
- mib[5] = 0;
-
- if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
- fprintf(stderr, "clean: sysctl: estimate: %s\n",
- strerror(errno));
- close(s);
- return NULL;
- }
-
- if ((buf = (char *)malloc(needed)) == NULL) {
- close(s);
- return NULL;
- }
-
- if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
- free(buf);
- close(s);
- return NULL;
- }
-
- ptr = buf;
- end = buf + needed;
- iface = NULL;
-
- while (ptr < end && iface == NULL) {
- ifm = (struct if_msghdr *)ptr; /* On if_msghdr */
- if (ifm->ifm_type != RTM_IFINFO)
- break;
- dl = (struct sockaddr_dl *)(ifm + 1); /* Single _dl at end */
- if (!strncmp(name, dl->sdl_data, dl->sdl_nlen)) {
- iface = (struct iface *)malloc(sizeof *iface);
- if (iface == NULL) {
- fprintf(stderr, "iface_Create: malloc: %s\n", strerror(errno));
- return NULL;
- }
- iface->name = strdup(name);
- iface->flags = ifm->ifm_flags;
- iface->index = ifm->ifm_index;
- iface->in_addrs = 0;
- iface->in_addr = NULL;
- }
- ptr += ifm->ifm_msglen; /* First ifa_msghdr */
- for (; ptr < end; ptr += ifam->ifam_msglen) {
- ifam = (struct ifa_msghdr *)ptr; /* Next if address */
-
- if (ifam->ifam_type != RTM_NEWADDR) /* finished this if */
- break;
-
- if (iface == NULL) /* Keep wading */
- continue;
-
- /* Found an address ! */
-
- if (ifam->ifam_addrs & (1 << RTAX_IFA)) {
- /* *And* it's configured ! */
- rti.rti_addrs = ifam->ifam_addrs;
- lim = (char *)ifam + ifam->ifam_msglen;
- cp = (char *)(ifam + 1);
- memset(rti.rti_info, '\0', sizeof(rti.rti_info));
- for (i = 0; i < RTAX_MAX && cp < lim; i++) {
- if ((rti.rti_addrs & (1 << i)) == 0)
- continue;
- rti.rti_info[i] = (struct sockaddr *)cp;
-#define ROUNDUP(x) \
- ((x) > 0 ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
- cp += ROUNDUP(rti.rti_info[i]->sa_len);
- }
-
- if (rti.rti_info[RTAX_IFA] &&
- rti.rti_info[RTAX_IFA]->sa_family == AF_INET) {
- /* Record the iface address rti */
-
- addr = (struct iface_addr *)realloc
- (iface->in_addr, (iface->in_addrs + 1) * sizeof iface->in_addr[0]);
- if (addr == NULL)
- break;
- iface->in_addr = addr;
-
- addr += iface->in_addrs;
- iface->in_addrs++;
-
- addr->ifa.s_addr = ((struct sockaddr_in *)rti.rti_info[RTAX_IFA])->
- sin_addr.s_addr;
- addr->brd.s_addr = rti.rti_info[RTAX_BRD] ?
- ((struct sockaddr_in *)rti.rti_info[RTAX_BRD])->sin_addr.s_addr :
- INADDR_ANY;
- addr->mask.s_addr = rti.rti_info[RTAX_NETMASK] ?
- ((struct sockaddr_in *)rti.rti_info[RTAX_NETMASK])->sin_addr.s_addr:
- INADDR_ANY;
-
- addr->bits = bitsinmask(addr->mask);
- }
- }
- }
- }
-
- free(buf);
- close(s);
-
- return iface;
-}
-
-static void
-iface_addr_Zap(const char *name, struct iface_addr *addr)
-{
- struct ifaliasreq ifra;
- struct sockaddr_in *me, *peer;
- int s;
-
- s = ID0socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0)
- log_Printf(LogERROR, "iface_addr_Zap: socket(): %s\n", strerror(errno));
- else {
- memset(&ifra, '\0', sizeof ifra);
- strncpy(ifra.ifra_name, name, sizeof ifra.ifra_name - 1);
- me = (struct sockaddr_in *)&ifra.ifra_addr;
- peer = (struct sockaddr_in *)&ifra.ifra_broadaddr;
- me->sin_family = peer->sin_family = AF_INET;
- me->sin_len = peer->sin_len = sizeof(struct sockaddr_in);
- me->sin_addr = addr->ifa;
- peer->sin_addr = addr->brd;
- log_Printf(LogDEBUG, "Delete %s\n", inet_ntoa(addr->ifa));
- if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0)
- log_Printf(LogWARN, "iface_addr_Zap: ioctl(SIOCDIFADDR, %s): %s\n",
- inet_ntoa(addr->ifa), strerror(errno));
- close(s);
- }
-}
-
-void
-iface_inClear(struct iface *iface, int how)
-{
- int n, addrs;
-
- addrs = n = how == IFACE_CLEAR_ALL ? 0 : 1;
- for (; n < iface->in_addrs; n++)
- iface_addr_Zap(iface->name, iface->in_addr + n);
-
- iface->in_addrs = addrs;
- /* Don't bother realloc()ing - we have little to gain */
-}
-
-int
-iface_inAdd(struct iface *iface, struct in_addr ifa, struct in_addr mask,
- struct in_addr brd, int how)
-{
- int slot, s, chg;
- struct ifaliasreq ifra;
- struct sockaddr_in *me, *peer, *msk;
- struct iface_addr *addr;
-
- for (slot = 0; slot < iface->in_addrs; slot++)
- if (iface->in_addr[slot].ifa.s_addr == ifa.s_addr) {
- if (how & IFACE_FORCE_ADD)
- break;
- else
- /* errno = EEXIST; */
- return 0;
- }
-
- addr = (struct iface_addr *)realloc
- (iface->in_addr, (iface->in_addrs + 1) * sizeof iface->in_addr[0]);
- if (addr == NULL) {
- log_Printf(LogERROR, "iface_inAdd: realloc: %s\n", strerror(errno));
- return 0;
- }
- iface->in_addr = addr;
-
- s = ID0socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0) {
- log_Printf(LogERROR, "iface_inAdd: socket(): %s\n", strerror(errno));
- return 0;
- }
-
- /*
- * We've gotta be careful here. If we try to add an address with the
- * same destination as an existing interface, nothing will work.
- * Instead, we tweak all previous address entries that match the
- * to-be-added destination to 255.255.255.255 (w/ a similar netmask).
- * There *may* be more than one - if the user has ``iface add''ed
- * stuff previously.
- */
- for (chg = 0; chg < iface->in_addrs; chg++) {
- if ((iface->in_addr[chg].brd.s_addr == brd.s_addr &&
- brd.s_addr != INADDR_BROADCAST) || chg == slot) {
- memset(&ifra, '\0', sizeof ifra);
- strncpy(ifra.ifra_name, iface->name, sizeof ifra.ifra_name - 1);
- me = (struct sockaddr_in *)&ifra.ifra_addr;
- msk = (struct sockaddr_in *)&ifra.ifra_mask;
- peer = (struct sockaddr_in *)&ifra.ifra_broadaddr;
- me->sin_family = msk->sin_family = peer->sin_family = AF_INET;
- me->sin_len = msk->sin_len = peer->sin_len = sizeof(struct sockaddr_in);
- me->sin_addr = iface->in_addr[chg].ifa;
- msk->sin_addr = iface->in_addr[chg].mask;
- peer->sin_addr = iface->in_addr[chg].brd;
- log_Printf(LogDEBUG, "Delete %s\n", inet_ntoa(me->sin_addr));
- ID0ioctl(s, SIOCDIFADDR, &ifra); /* Don't care if it fails... */
- if (chg != slot) {
- peer->sin_addr.s_addr = iface->in_addr[chg].brd.s_addr =
- msk->sin_addr.s_addr = iface->in_addr[chg].mask.s_addr =
- INADDR_BROADCAST;
- iface->in_addr[chg].bits = 32;
- log_Printf(LogDEBUG, "Add %s -> 255.255.255.255\n",
- inet_ntoa(me->sin_addr));
- if (ID0ioctl(s, SIOCAIFADDR, &ifra) < 0 && errno != EEXIST) {
- /* Oops - that's bad(ish) news ! We've lost an alias ! */
- log_Printf(LogERROR, "iface_inAdd: ioctl(SIOCAIFADDR): %s: %s\n",
- inet_ntoa(me->sin_addr), strerror(errno));
- iface->in_addrs--;
- bcopy(iface->in_addr + chg + 1, iface->in_addr + chg,
- (iface->in_addrs - chg) * sizeof iface->in_addr[0]);
- if (slot > chg)
- slot--;
- chg--;
- }
- }
- }
- }
-
- memset(&ifra, '\0', sizeof ifra);
- strncpy(ifra.ifra_name, iface->name, sizeof ifra.ifra_name - 1);
- me = (struct sockaddr_in *)&ifra.ifra_addr;
- msk = (struct sockaddr_in *)&ifra.ifra_mask;
- peer = (struct sockaddr_in *)&ifra.ifra_broadaddr;
- me->sin_family = msk->sin_family = peer->sin_family = AF_INET;
- me->sin_len = msk->sin_len = peer->sin_len = sizeof(struct sockaddr_in);
- me->sin_addr = ifa;
- msk->sin_addr = mask;
- peer->sin_addr = brd;
-
- if (log_IsKept(LogDEBUG)) {
- char buf[16];
-
- strncpy(buf, inet_ntoa(brd), sizeof buf-1);
- buf[sizeof buf - 1] = '\0';
- log_Printf(LogDEBUG, "Add %s -> %s\n", inet_ntoa(ifa), buf);
- }
-
- /* An EEXIST failure w/ brd == INADDR_BROADCAST is ok (and works!) */
- if (ID0ioctl(s, SIOCAIFADDR, &ifra) < 0 &&
- (brd.s_addr != INADDR_BROADCAST || errno != EEXIST)) {
- log_Printf(LogERROR, "iface_inAdd: ioctl(SIOCAIFADDR): %s: %s\n",
- inet_ntoa(ifa), strerror(errno));
- ID0ioctl(s, SIOCDIFADDR, &ifra); /* EEXIST ? */
- close(s);
- return 0;
- }
- close(s);
-
- if (slot == iface->in_addrs) {
- /* We're adding a new interface address */
-
- if (how & IFACE_ADD_FIRST) {
- /* Stuff it at the start of our list */
- slot = 0;
- bcopy(iface->in_addr, iface->in_addr + 1,
- iface->in_addrs * sizeof iface->in_addr[0]);
- }
-
- iface->in_addrs++;
- } else if (how & IFACE_ADD_FIRST) {
- /* Shift it up to the first slot */
- bcopy(iface->in_addr, iface->in_addr + 1, slot * sizeof iface->in_addr[0]);
- slot = 0;
- }
-
- iface->in_addr[slot].ifa = ifa;
- iface->in_addr[slot].mask = mask;
- iface->in_addr[slot].brd = brd;
- iface->in_addr[slot].bits = bitsinmask(iface->in_addr[slot].mask);
-
- return 1;
-}
-
-int
-iface_inDelete(struct iface *iface, struct in_addr ip)
-{
- int n;
-
- for (n = 0; n < iface->in_addrs; n++)
- if (iface->in_addr[n].ifa.s_addr == ip.s_addr) {
- iface_addr_Zap(iface->name, iface->in_addr + n);
- bcopy(iface->in_addr + n + 1, iface->in_addr + n,
- (iface->in_addrs - n - 1) * sizeof iface->in_addr[0]);
- iface->in_addrs--;
- return 1;
- }
-
- return 0;
-}
-
-void
-iface_Destroy(struct iface *iface)
-{
- /*
- * iface_Clear(iface, IFACE_CLEAR_ALL) must be called manually
- * if that's what the user wants. It's better to leave the interface
- * allocated so that existing connections can continue to work.
- */
-
- if (iface != NULL) {
- free(iface->name);
- free(iface->in_addr);
- free(iface);
- }
-}
-
-#define if_entry(x) { IFF_##x, #x }
-
-struct {
- int flag;
- const char *value;
-} if_flags[] = {
- if_entry(UP),
- if_entry(BROADCAST),
- if_entry(DEBUG),
- if_entry(LOOPBACK),
- if_entry(POINTOPOINT),
- if_entry(RUNNING),
- if_entry(NOARP),
- if_entry(PROMISC),
- if_entry(ALLMULTI),
- if_entry(OACTIVE),
- if_entry(SIMPLEX),
- if_entry(LINK0),
- if_entry(LINK1),
- if_entry(LINK2),
- if_entry(MULTICAST),
- { 0, "???" }
-};
-
-int
-iface_Show(struct cmdargs const *arg)
-{
- struct iface *iface = arg->bundle->iface, *current;
- int f, flags;
-
- current = iface_Create(iface->name);
- flags = iface->flags = current->flags;
- iface_Destroy(current);
-
- prompt_Printf(arg->prompt, "%s (idx %d) <", iface->name, iface->index);
- for (f = 0; f < sizeof if_flags / sizeof if_flags[0]; f++)
- if ((if_flags[f].flag & flags) || (!if_flags[f].flag && flags)) {
- prompt_Printf(arg->prompt, "%s%s", flags == iface->flags ? "" : ",",
- if_flags[f].value);
- flags &= ~if_flags[f].flag;
- }
- prompt_Printf(arg->prompt, "> has %d address%s:\n", iface->in_addrs,
- iface->in_addrs == 1 ? "" : "es");
-
- for (f = 0; f < iface->in_addrs; f++) {
- prompt_Printf(arg->prompt, " %s", inet_ntoa(iface->in_addr[f].ifa));
- if (iface->in_addr[f].bits >= 0)
- prompt_Printf(arg->prompt, "/%d", iface->in_addr[f].bits);
- if (iface->flags & IFF_POINTOPOINT)
- prompt_Printf(arg->prompt, " -> %s", inet_ntoa(iface->in_addr[f].brd));
- else if (iface->flags & IFF_BROADCAST)
- prompt_Printf(arg->prompt, " broadcast %s",
- inet_ntoa(iface->in_addr[f].brd));
- if (iface->in_addr[f].bits < 0)
- prompt_Printf(arg->prompt, " (mask %s)",
- inet_ntoa(iface->in_addr[f].mask));
- prompt_Printf(arg->prompt, "\n");
- }
-
- return 0;
-}
diff --git a/usr.sbin/ppp/iface.h b/usr.sbin/ppp/iface.h
deleted file mode 100644
index f3b1dade5ee9..000000000000
--- a/usr.sbin/ppp/iface.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id:$
- */
-
-struct iface_addr {
- struct in_addr ifa; /* local address */
- struct in_addr mask; /* netmask */
- int bits; /* netmask bits - -1 if not contiguous */
- struct in_addr brd; /* peer address */
-};
-
-struct iface {
- char *name; /* Interface name (malloc'd) */
- int index; /* Interface index */
- int flags; /* Interface flags (IFF_*) */
-
- int in_addrs; /* How many in_addr's */
- struct iface_addr *in_addr; /* Array of addresses (malloc'd) */
-};
-
-#define IFACE_CLEAR_ALL 0 /* Nuke 'em all */
-#define IFACE_CLEAR_ALIASES 1 /* Leave the IPCP address */
-
-#define IFACE_ADD_LAST 0 /* Just another alias */
-#define IFACE_ADD_FIRST 1 /* The IPCP address */
-#define IFACE_FORCE_ADD 2 /* OR'd with IFACE_ADD_{FIRST,LAST} */
-
-#define iface_Clear iface_inClear /* Same for now */
-
-extern struct iface *iface_Create(const char *name);
-extern void iface_inClear(struct iface *, int);
-extern int iface_inAdd(struct iface *, struct in_addr, struct in_addr,
- struct in_addr, int);
-extern int iface_inDelete(struct iface *, struct in_addr);
-extern int iface_Show(struct cmdargs const *);
-extern void iface_Destroy(struct iface *);
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
index aa7207de1d88..a7ffb306e63d 100644
--- a/usr.sbin/ppp/ip.c
+++ b/usr.sbin/ppp/ip.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ip.c,v 1.53 1998/09/17 00:45:26 brian Exp $
+ * $Id: ip.c,v 1.52 1998/08/26 17:39:37 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@@ -160,14 +160,10 @@ FilterCheck(struct ip *pip, struct filter *filter)
estab = (th->th_flags & TH_ACK);
syn = (th->th_flags & TH_SYN);
finrst = (th->th_flags & (TH_FIN|TH_RST));
- if (log_IsKept(LogDEBUG)) {
- if (!estab)
- snprintf(dbuff, sizeof dbuff,
- "flags = %02x, sport = %d, dport = %d",
- th->th_flags, sport, dport);
- else
- *dbuff = '\0';
- }
+ if (log_IsKept(LogDEBUG) && !estab)
+ snprintf(dbuff, sizeof dbuff,
+ "flags = %02x, sport = %d, dport = %d",
+ th->th_flags, sport, dport);
break;
default:
return (A_DENY); /* We'll block unknown type of packet */
diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c
index eae5f4c93ed1..40e1dfa2313d 100644
--- a/usr.sbin/ppp/ipcp.c
+++ b/usr.sbin/ppp/ipcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.c,v 1.67 1998/10/22 02:32:49 brian Exp $
+ * $Id: ipcp.c,v 1.65 1998/09/04 18:25:59 brian Exp $
*
* TODO:
* o More RFC1772 backward compatibility
@@ -28,12 +28,10 @@
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <sys/socket.h>
-#include <net/route.h>
#include <netdb.h>
#include <net/if.h>
#include <sys/sockio.h>
#include <sys/un.h>
-#include <arpa/nameser.h>
#include <fcntl.h>
#include <resolv.h>
@@ -79,7 +77,6 @@
#include "systems.h"
#include "prompt.h"
#include "route.h"
-#include "iface.h"
#undef REJECTED
#define REJECTED(p, x) ((p)->peer_reject & (1<<(x)))
@@ -357,8 +354,11 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l,
memset(&ipcp->cfg.my_range, '\0', sizeof ipcp->cfg.my_range);
if (gethostname(name, sizeof name) == 0) {
hp = gethostbyname(name);
- if (hp && hp->h_addrtype == AF_INET)
+ if (hp && hp->h_addrtype == AF_INET) {
memcpy(&ipcp->cfg.my_range.ipaddr.s_addr, hp->h_addr, hp->h_length);
+ ipcp->cfg.peer_range.mask.s_addr = INADDR_BROADCAST;
+ ipcp->cfg.peer_range.width = 32;
+ }
}
ipcp->cfg.netmask.s_addr = INADDR_ANY;
memset(&ipcp->cfg.peer_range, '\0', sizeof ipcp->cfg.peer_range);
@@ -376,6 +376,9 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l,
memset(&ipcp->vj, '\0', sizeof ipcp->vj);
+ ipcp->my_ifip.s_addr = INADDR_ANY;
+ ipcp->peer_ifip.s_addr = INADDR_ANY;
+
throughput_init(&ipcp->throughput);
memset(ipcp->Queue, '\0', sizeof ipcp->Queue);
ipcp_Setup(ipcp);
@@ -390,26 +393,17 @@ ipcp_SetLink(struct ipcp *ipcp, struct link *l)
void
ipcp_Setup(struct ipcp *ipcp)
{
- struct iface *iface = ipcp->fsm.bundle->iface;
- int pos, n;
+ int pos;
ipcp->fsm.open_mode = 0;
ipcp->fsm.maxconfig = 10;
if (iplist_isvalid(&ipcp->cfg.peer_list)) {
- /* Try to give the peer a previously configured IP address */
- for (n = 0; n < iface->in_addrs; n++) {
- pos = iplist_ip2pos(&ipcp->cfg.peer_list, iface->in_addr[n].brd);
- if (pos != -1) {
- ipcp->cfg.peer_range.ipaddr =
- iplist_setcurpos(&ipcp->cfg.peer_list, pos);
- break;
- }
- }
- if (n == iface->in_addrs)
- /* Ok, so none of 'em fit.... pick a random one */
+ if (ipcp->my_ifip.s_addr != INADDR_ANY &&
+ (pos = iplist_ip2pos(&ipcp->cfg.peer_list, ipcp->my_ifip)) != -1)
+ ipcp->cfg.peer_range.ipaddr = iplist_setcurpos(&ipcp->cfg.peer_list, pos);
+ else
ipcp->cfg.peer_range.ipaddr = iplist_setrandpos(&ipcp->cfg.peer_list);
-
ipcp->cfg.peer_range.mask.s_addr = INADDR_BROADCAST;
ipcp->cfg.peer_range.width = 32;
}
@@ -428,23 +422,17 @@ ipcp_Setup(struct ipcp *ipcp)
ipcp->my_ip = ipcp->cfg.TriggerAddress;
log_Printf(LogIPCP, "Using trigger address %s\n",
inet_ntoa(ipcp->cfg.TriggerAddress));
- } else {
+ } else if ((ipcp->my_ifip.s_addr & ipcp->cfg.my_range.mask.s_addr) ==
+ (ipcp->cfg.my_range.ipaddr.s_addr &
+ ipcp->cfg.my_range.mask.s_addr))
/*
- * Otherwise, if we've used an IP number before and it's still within
- * the network specified on the ``set ifaddr'' line, we really
- * want to keep that IP number so that we can keep any existing
- * connections that are bound to that IP (assuming we're not
- * ``iface-alias''ing).
+ * Otherwise, if we've been assigned an IP number before, we really
+ * want to keep the same IP number so that we can keep any existing
+ * connections that are bound to that IP.
*/
- for (n = 0; n < iface->in_addrs; n++)
- if ((iface->in_addr[n].ifa.s_addr & ipcp->cfg.my_range.mask.s_addr) ==
- (ipcp->cfg.my_range.ipaddr.s_addr & ipcp->cfg.my_range.mask.s_addr)) {
- ipcp->my_ip = iface->in_addr[n].ifa;
- break;
- }
- if (n == iface->in_addrs)
- ipcp->my_ip = ipcp->cfg.my_range.ipaddr;
- }
+ ipcp->my_ip = ipcp->my_ifip;
+ else
+ ipcp->my_ip = ipcp->cfg.my_range.ipaddr;
if (IsEnabled(ipcp->cfg.vj.neg))
ipcp->my_compproto = (PROTO_VJCOMP << 16) +
@@ -459,90 +447,84 @@ ipcp_Setup(struct ipcp *ipcp)
}
static int
-ipcp_doproxyall(struct bundle *bundle,
- int (*proxyfun)(struct bundle *, struct in_addr, int), int s)
+ipcp_SetIPaddress(struct bundle *bundle, struct in_addr myaddr,
+ struct in_addr hisaddr, int silent)
{
- int n, ret;
- struct sticky_route *rp;
- struct in_addr addr;
- struct ipcp *ipcp;
+ struct sockaddr_in *sock_in;
+ int s;
+ u_int32_t mask, addr;
+ struct ifaliasreq ifra;
- ipcp = &bundle->ncp.ipcp;
- for (rp = ipcp->route; rp != NULL; rp = rp->next) {
- if (ntohl(rp->mask.s_addr) == INADDR_BROADCAST)
- continue;
- n = INADDR_BROADCAST - ntohl(rp->mask.s_addr) - 1;
- if (n > 0 && n <= 254 && rp->dst.s_addr != INADDR_ANY) {
- addr = rp->dst;
- while (n--) {
- addr.s_addr = htonl(ntohl(addr.s_addr) + 1);
- log_Printf(LogDEBUG, "ipcp_doproxyall: %s\n", inet_ntoa(addr));
- ret = (*proxyfun)(bundle, addr, s);
- if (!ret)
- return ret;
- }
- }
+ /* If given addresses are alreay set, then ignore this request */
+ if (bundle->ncp.ipcp.my_ifip.s_addr == myaddr.s_addr &&
+ bundle->ncp.ipcp.peer_ifip.s_addr == hisaddr.s_addr)
+ return 0;
+
+ ipcp_CleanInterface(&bundle->ncp.ipcp);
+
+ s = ID0socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ log_Printf(LogERROR, "SetIPaddress: socket(): %s\n", strerror(errno));
+ return (-1);
}
- return 0;
-}
+ memset(&ifra, '\0', sizeof ifra);
+ strncpy(ifra.ifra_name, bundle->ifp.Name, sizeof ifra.ifra_name - 1);
+ ifra.ifra_name[sizeof ifra.ifra_name - 1] = '\0';
-static int
-ipcp_SetIPaddress(struct bundle *bundle, struct in_addr myaddr,
- struct in_addr hisaddr, int silent)
-{
- static struct in_addr none = { INADDR_ANY };
- struct in_addr mask, oaddr;
- u_int32_t addr;
+ /* Set interface address */
+ sock_in = (struct sockaddr_in *)&ifra.ifra_addr;
+ sock_in->sin_family = AF_INET;
+ sock_in->sin_addr = myaddr;
+ sock_in->sin_len = sizeof *sock_in;
+
+ /* Set destination address */
+ sock_in = (struct sockaddr_in *)&ifra.ifra_broadaddr;
+ sock_in->sin_family = AF_INET;
+ sock_in->sin_addr = hisaddr;
+ sock_in->sin_len = sizeof *sock_in;
- addr = htonl(myaddr.s_addr);
+ addr = ntohl(myaddr.s_addr);
if (IN_CLASSA(addr))
- mask.s_addr = htonl(IN_CLASSA_NET);
+ mask = IN_CLASSA_NET;
else if (IN_CLASSB(addr))
- mask.s_addr = htonl(IN_CLASSB_NET);
+ mask = IN_CLASSB_NET;
else
- mask.s_addr = htonl(IN_CLASSC_NET);
+ mask = IN_CLASSC_NET;
+ /* if subnet mask is given, use it instead of class mask */
if (bundle->ncp.ipcp.cfg.netmask.s_addr != INADDR_ANY &&
- (ntohl(bundle->ncp.ipcp.cfg.netmask.s_addr) & mask.s_addr) == mask.s_addr)
- mask.s_addr = htonl(bundle->ncp.ipcp.cfg.netmask.s_addr);
+ (ntohl(bundle->ncp.ipcp.cfg.netmask.s_addr) & mask) == mask)
+ mask = ntohl(bundle->ncp.ipcp.cfg.netmask.s_addr);
- oaddr.s_addr = bundle->iface->in_addrs ?
- bundle->iface->in_addr[0].ifa.s_addr : INADDR_ANY;
- if (!iface_inAdd(bundle->iface, myaddr, mask, hisaddr,
- IFACE_ADD_FIRST|IFACE_FORCE_ADD))
- return -1;
-
- if (!Enabled(bundle, OPT_IFACEALIAS) && bundle->iface->in_addrs > 1
- && myaddr.s_addr != oaddr.s_addr)
- /* Nuke the old one */
- iface_inDelete(bundle->iface, oaddr);
+ sock_in = (struct sockaddr_in *)&ifra.ifra_mask;
+ sock_in->sin_family = AF_INET;
+ sock_in->sin_addr.s_addr = htonl(mask);
+ sock_in->sin_len = sizeof *sock_in;
- if (bundle->ncp.ipcp.cfg.sendpipe > 0 || bundle->ncp.ipcp.cfg.recvpipe > 0)
- bundle_SetRoute(bundle, RTM_CHANGE, hisaddr, myaddr, none, 0, 0);
+ if (ID0ioctl(s, SIOCAIFADDR, &ifra) < 0) {
+ if (!silent)
+ log_Printf(LogERROR, "SetIPaddress: ioctl(SIOCAIFADDR): %s\n",
+ strerror(errno));
+ close(s);
+ return (-1);
+ }
if (Enabled(bundle, OPT_SROUTES))
route_Change(bundle, bundle->ncp.ipcp.route, myaddr, hisaddr);
- if (Enabled(bundle, OPT_PROXY) || Enabled(bundle, OPT_PROXYALL)) {
- int s = ID0socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0)
- log_Printf(LogERROR, "ipcp_SetIPaddress: socket(): %s\n",
- strerror(errno));
- else {
- if (Enabled(bundle, OPT_PROXYALL))
- ipcp_doproxyall(bundle, arp_SetProxy, s);
- else if (Enabled(bundle, OPT_PROXY))
- arp_SetProxy(bundle, hisaddr, s);
- close(s);
- }
- }
+ bundle->ncp.ipcp.peer_ifip.s_addr = hisaddr.s_addr;
+ bundle->ncp.ipcp.my_ifip.s_addr = myaddr.s_addr;
- return 0;
+ if (Enabled(bundle, OPT_PROXY))
+ arp_SetProxy(bundle, bundle->ncp.ipcp.peer_ifip, s);
+
+ close(s);
+ return (0);
}
static struct in_addr
-ChooseHisAddr(struct bundle *bundle, struct in_addr gw)
+ChooseHisAddr(struct bundle *bundle, const struct in_addr gw)
{
struct in_addr try;
u_long f;
@@ -657,26 +639,40 @@ IpcpLayerFinish(struct fsm *fp)
void
ipcp_CleanInterface(struct ipcp *ipcp)
{
- struct iface *iface = ipcp->fsm.bundle->iface;
+ struct ifaliasreq ifra;
+ struct sockaddr_in *me, *peer;
+ int s;
+
+ s = ID0socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ log_Printf(LogERROR, "ipcp_CleanInterface: socket: %s\n", strerror(errno));
+ return;
+ }
route_Clean(ipcp->fsm.bundle, ipcp->route);
- if (iface->in_addrs && (Enabled(ipcp->fsm.bundle, OPT_PROXY) ||
- Enabled(ipcp->fsm.bundle, OPT_PROXYALL))) {
- int s = ID0socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0)
- log_Printf(LogERROR, "ipcp_CleanInterface: socket: %s\n",
- strerror(errno));
- else {
- if (Enabled(ipcp->fsm.bundle, OPT_PROXYALL))
- ipcp_doproxyall(ipcp->fsm.bundle, arp_ClearProxy, s);
- else if (Enabled(ipcp->fsm.bundle, OPT_PROXY))
- arp_ClearProxy(ipcp->fsm.bundle, iface->in_addr[0].brd, s);
- close(s);
- }
+ if (Enabled(ipcp->fsm.bundle, OPT_PROXY))
+ arp_ClearProxy(ipcp->fsm.bundle, ipcp->peer_ifip, s);
+
+ if (ipcp->my_ifip.s_addr != INADDR_ANY ||
+ ipcp->peer_ifip.s_addr != INADDR_ANY) {
+ memset(&ifra, '\0', sizeof ifra);
+ strncpy(ifra.ifra_name, ipcp->fsm.bundle->ifp.Name,
+ sizeof ifra.ifra_name - 1);
+ ifra.ifra_name[sizeof ifra.ifra_name - 1] = '\0';
+ me = (struct sockaddr_in *)&ifra.ifra_addr;
+ peer = (struct sockaddr_in *)&ifra.ifra_broadaddr;
+ me->sin_family = peer->sin_family = AF_INET;
+ me->sin_len = peer->sin_len = sizeof(struct sockaddr_in);
+ me->sin_addr = ipcp->my_ifip;
+ peer->sin_addr = ipcp->peer_ifip;
+ if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0)
+ log_Printf(LogERROR, "ipcp_CleanInterface: ioctl(SIOCDIFADDR): %s\n",
+ strerror(errno));
+ ipcp->my_ifip.s_addr = ipcp->peer_ifip.s_addr = INADDR_ANY;
}
- iface_inClear(ipcp->fsm.bundle->iface, IFACE_CLEAR_ALL);
+ close(s);
}
static void
@@ -686,10 +682,7 @@ IpcpLayerDown(struct fsm *fp)
struct ipcp *ipcp = fsm2ipcp(fp);
const char *s;
- if (ipcp->fsm.bundle->iface->in_addrs)
- s = inet_ntoa(ipcp->fsm.bundle->iface->in_addr[0].ifa);
- else
- s = "Interface configuration error !";
+ s = inet_ntoa(ipcp->peer_ifip);
log_Printf(LogIPCP, "%s: LayerDown: %s\n", fp->link->name, s);
/*
@@ -705,6 +698,9 @@ IpcpLayerDown(struct fsm *fp)
system_Select(fp->bundle, "MYADDR", LINKDOWNFILE, NULL, NULL);
}
+ if (!(ipcp->fsm.bundle->phys_type.all & PHYS_AUTO))
+ ipcp_CleanInterface(ipcp);
+
ipcp_Setup(ipcp);
}
@@ -729,12 +725,11 @@ IpcpLayerUp(struct fsm *fp)
{
/* We're now up */
struct ipcp *ipcp = fsm2ipcp(fp);
- char tbuff[16];
+ char tbuff[100];
log_Printf(LogIPCP, "%s: LayerUp.\n", fp->link->name);
- snprintf(tbuff, sizeof tbuff, "%s", inet_ntoa(ipcp->my_ip));
- log_Printf(LogIPCP, "myaddr %s hisaddr = %s\n",
- tbuff, inet_ntoa(ipcp->peer_ip));
+ snprintf(tbuff, sizeof tbuff, "myaddr = %s ", inet_ntoa(ipcp->my_ip));
+ log_Printf(LogIPCP, " %s hisaddr = %s\n", tbuff, inet_ntoa(ipcp->peer_ip));
if (ipcp->peer_compproto >> 16 == PROTO_VJCOMP)
sl_compress_init(&ipcp->vj.cslc, (ipcp->peer_compproto >> 8) & 255);
@@ -746,7 +741,8 @@ IpcpLayerUp(struct fsm *fp)
* XXX this stuff should really live in the FSM. Our config should
* associate executable sections in files with events.
*/
- if (system_Select(fp->bundle, tbuff, LINKUPFILE, NULL, NULL) < 0) {
+ if (system_Select(fp->bundle, inet_ntoa(ipcp->my_ifip), LINKUPFILE,
+ NULL, NULL) < 0) {
if (bundle_GetLabel(fp->bundle)) {
if (system_Select(fp->bundle, bundle_GetLabel(fp->bundle),
LINKUPFILE, NULL, NULL) < 0)
@@ -760,7 +756,7 @@ IpcpLayerUp(struct fsm *fp)
}
static int
-AcceptableAddr(const struct in_range *prange, struct in_addr ipaddr)
+AcceptableAddr(struct in_range *prange, struct in_addr ipaddr)
{
/* Is the given IP in the given range ? */
return (prange->ipaddr.s_addr & prange->mask.s_addr) ==
@@ -772,13 +768,13 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
struct fsm_decode *dec)
{
/* Deal with incoming PROTO_IPCP */
- struct iface *iface = fp->bundle->iface;
struct ipcp *ipcp = fsm2ipcp(fp);
- int type, length, gotdns, gotdnsnak, n;
+ int type, length;
u_int32_t compproto;
struct compreq *pcomp;
struct in_addr ipaddr, dstipaddr, have_ip, dns[2], dnsnak[2];
char tbuff[100], tbuff2[100];
+ int gotdns, gotdnsnak;
gotdns = 0;
gotdnsnak = 0;
@@ -814,19 +810,14 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
ipaddr, 1)) {
log_Printf(LogIPCP, "%s: Address invalid or already in use\n",
inet_ntoa(ipaddr));
- /*
- * If we've already had a valid address configured for the peer,
- * try NAKing with that so that we don't have to upset things
- * too much.
- */
- for (n = 0; n < iface->in_addrs; n++)
- if (iplist_ip2pos(&ipcp->cfg.peer_list, iface->in_addr[n].brd)
- >=0) {
- ipcp->peer_ip = iface->in_addr[n].brd;
- break;
- }
-
- if (n == iface->in_addrs)
+ if (iplist_ip2pos(&ipcp->cfg.peer_list, ipcp->peer_ifip) >= 0)
+ /*
+ * If we've already got a valid address configured for the peer
+ * (in AUTO mode), try NAKing with that so that we don't
+ * have to upset things too much.
+ */
+ ipcp->peer_ip = ipcp->peer_ifip;
+ else
/* Just pick an IP number from our list */
ipcp->peer_ip = ChooseHisAddr
(fp->bundle, ipcp->cfg.my_range.ipaddr);
@@ -836,7 +827,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
dec->rejend += length;
} else {
memcpy(dec->nakend, cp, 2);
- memcpy(dec->nakend + 2, &ipcp->peer_ip.s_addr, length - 2);
+ memcpy(dec->nakend+2, &ipcp->peer_ip.s_addr, length - 2);
dec->nakend += length;
}
break;
@@ -847,20 +838,13 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
* want to use.
*/
memcpy(dec->nakend, cp, 2);
- for (n = 0; n < iface->in_addrs; n++)
- if ((iface->in_addr[n].brd.s_addr &
- ipcp->cfg.peer_range.mask.s_addr)
- == (ipcp->cfg.peer_range.ipaddr.s_addr &
- ipcp->cfg.peer_range.mask.s_addr)) {
- /* We prefer the already-configured address */
- memcpy(dec->nakend + 2, &iface->in_addr[n].brd.s_addr,
- length - 2);
- break;
- }
-
- if (n == iface->in_addrs)
- memcpy(dec->nakend + 2, &ipcp->peer_ip.s_addr, length - 2);
-
+ if ((ipcp->peer_ifip.s_addr & ipcp->cfg.peer_range.mask.s_addr) ==
+ (ipcp->cfg.peer_range.ipaddr.s_addr &
+ ipcp->cfg.peer_range.mask.s_addr))
+ /* We prefer the already-configured address */
+ memcpy(dec->nakend+2, &ipcp->peer_ifip.s_addr, length - 2);
+ else
+ memcpy(dec->nakend+2, &ipcp->peer_ip.s_addr, length - 2);
dec->nakend += length;
break;
}
@@ -868,7 +852,6 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
memcpy(dec->ackend, cp, length);
dec->ackend += length;
break;
-
case MODE_NAK:
if (AcceptableAddr(&ipcp->cfg.my_range, ipaddr)) {
/* Use address suggested by peer */
@@ -882,13 +865,11 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
fsm_Close(&ipcp->fsm);
}
break;
-
case MODE_REJ:
ipcp->peer_reject |= (1 << type);
break;
}
break;
-
case TY_COMPPROTO:
memcpy(&compproto, cp + 2, 4);
log_Printf(LogIPCP, "%s %s\n", tbuff, vj2asc(compproto));
@@ -939,19 +920,16 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
}
}
break;
-
case MODE_NAK:
log_Printf(LogIPCP, "%s changing compproto: %08x --> %08x\n",
tbuff, ipcp->my_compproto, compproto);
ipcp->my_compproto = compproto;
break;
-
case MODE_REJ:
ipcp->peer_reject |= (1 << type);
break;
}
break;
-
case TY_IPADDRS: /* RFC1172 */
memcpy(&ipaddr.s_addr, cp + 2, 4);
memcpy(&dstipaddr.s_addr, cp + 6, 4);
@@ -965,7 +943,6 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
memcpy(dec->ackend, cp, length);
dec->ackend += length;
break;
-
case MODE_NAK:
snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s", tbuff,
inet_ntoa(ipcp->my_ip));
@@ -973,7 +950,6 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
ipcp->my_ip = ipaddr;
ipcp->peer_ip = dstipaddr;
break;
-
case MODE_REJ:
ipcp->peer_reject |= (1 << type);
break;
@@ -1019,14 +995,12 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
dec->ackend += length;
}
break;
-
case MODE_NAK: /* what does this mean?? */
if (IsEnabled(ipcp->cfg.ns.dns_neg)) {
gotdnsnak = 1;
memcpy(&dnsnak[type == TY_PRIMARY_DNS ? 0 : 1].s_addr, cp + 2, 4);
}
break;
-
case MODE_REJ: /* Can't do much, stop asking */
ipcp->peer_reject |= (1 << (type - TY_ADJUST_NS));
break;
@@ -1060,11 +1034,9 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
dec->ackend += length;
}
break;
-
case MODE_NAK:
log_Printf(LogIPCP, "MS NBNS req %d - NAK??\n", type);
break;
-
case MODE_REJ:
log_Printf(LogIPCP, "MS NBNS req %d - REJ??\n", type);
break;
@@ -1144,8 +1116,11 @@ ipcp_UseHisaddr(struct bundle *bundle, const char *hisaddr, int setaddr)
ipcp->peer_ip.s_addr = ipcp->cfg.peer_range.ipaddr.s_addr;
if (setaddr && ipcp_SetIPaddress(bundle, ipcp->cfg.my_range.ipaddr,
- ipcp->cfg.peer_range.ipaddr, 0) < 0)
+ ipcp->cfg.peer_range.ipaddr, 0) < 0) {
+ ipcp->cfg.my_range.ipaddr.s_addr = INADDR_ANY;
+ ipcp->cfg.peer_range.ipaddr.s_addr = INADDR_ANY;
return 0;
+ }
} else
return 0;
diff --git a/usr.sbin/ppp/ipcp.h b/usr.sbin/ppp/ipcp.h
index 5b5fc9bccd50..c0a025ec5deb 100644
--- a/usr.sbin/ppp/ipcp.h
+++ b/usr.sbin/ppp/ipcp.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.h,v 1.21 1998/10/22 02:32:49 brian Exp $
+ * $Id: ipcp.h,v 1.19 1998/05/21 21:45:49 brian Exp $
*
* TODO:
*/
@@ -57,9 +57,6 @@ struct ipcp {
struct in_range peer_range; /* HISADDR spec */
struct iplist peer_list; /* Ranges of HISADDR values */
- u_long sendpipe; /* route sendpipe size */
- u_long recvpipe; /* route recvpipe size */
-
struct in_addr TriggerAddress; /* Address to suggest in REQ */
unsigned HaveTriggerAddress : 1; /* Trigger address specified */
@@ -90,6 +87,9 @@ struct ipcp {
u_int32_t peer_reject; /* Request codes rejected by peer */
u_int32_t my_reject; /* Request codes I have rejected */
+ struct in_addr my_ifip; /* My configured interface address */
+ struct in_addr peer_ifip; /* My congigured destination address */
+
struct pppThroughput throughput; /* throughput statistics */
struct mqueue Queue[PRI_FAST + 1]; /* Output packet queues */
};
diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c
index 10165fd1d24b..9591aef4a923 100644
--- a/usr.sbin/ppp/lcp.c
+++ b/usr.sbin/ppp/lcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: lcp.c,v 1.65 1998/10/17 12:28:02 brian Exp $
+ * $Id: lcp.c,v 1.63 1998/09/04 18:25:59 brian Exp $
*
* TODO:
* o Limit data field length by MRU
@@ -663,24 +663,13 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
#ifdef HAVE_DES
link2physical(fp->link)->dl->chap.using_MSChap = cp[4] == 0x80;
#endif
- } else {
- if (IsAccepted(lcp->cfg.chap)) {
-#ifndef HAVE_DES
- if (cp[4] == 0x80)
- log_Printf(LogWARN, "Chap 0x80 not available without DES\n");
- else
-#endif
- log_Printf(LogWARN, "Chap 0x%02x not supported\n",
- (unsigned)cp[4]);
- }
- if (IsAccepted(lcp->cfg.pap)) {
- *dec->nakend++ = *cp;
- *dec->nakend++ = 4;
- *dec->nakend++ = (unsigned char) (PROTO_PAP >> 8);
- *dec->nakend++ = (unsigned char) PROTO_PAP;
- } else
- goto reqreject;
- }
+ } else if (IsAccepted(lcp->cfg.pap)) {
+ *dec->nakend++ = *cp;
+ *dec->nakend++ = 4;
+ *dec->nakend++ = (unsigned char) (PROTO_PAP >> 8);
+ *dec->nakend++ = (unsigned char) PROTO_PAP;
+ } else
+ goto reqreject;
break;
default:
@@ -921,7 +910,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
goto reqreject;
break;
case MODE_NAK:
- /* We don't do what he NAKs with, we do things in our preferred order */
+ /* We don't do what he NAKs want, we do things in our preferred order */
if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_AUTH))
lcp->want_callback.opmask &= ~CALLBACK_BIT(CALLBACK_AUTH);
else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_CBCP))
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index b9cf61d4f0fd..e092574fb071 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.145 1998/10/31 17:38:46 brian Exp $
+ * $Id: main.c,v 1.142 1998/08/09 09:13:54 brian Exp $
*
* TODO:
*/
@@ -75,7 +75,6 @@
#include "chap.h"
#include "cbcp.h"
#include "datalink.h"
-#include "iface.h"
#ifndef O_NONBLOCK
#ifdef O_NDELAY
@@ -179,27 +178,27 @@ Usage(void)
#ifndef NOALIAS
" [ -alias ]"
#endif
- " [system ...]\n");
+ " [system]\n");
exit(EX_START);
}
-static int
+static char *
ProcessArgs(int argc, char **argv, int *mode, int *alias)
{
- int optc, newmode, arg;
+ int optc, labelrequired, newmode;
char *cp;
- optc = 0;
+ optc = labelrequired = 0;
*mode = PHYS_INTERACTIVE;
*alias = 0;
- for (arg = 1; arg < argc && *argv[arg] == '-'; arg++, optc++) {
- cp = argv[arg] + 1;
+ while (argc > 0 && **argv == '-') {
+ cp = *argv + 1;
newmode = Nam2mode(cp);
switch (newmode) {
case PHYS_NONE:
if (strcmp(cp, "alias") == 0) {
#ifdef NOALIAS
- log_Printf(LogWARN, "Cannot load alias library (compiled out)\n");
+ log_Printf(LogWARN, "Cannot load alias library\n");
#else
*alias = 1;
#endif
@@ -212,9 +211,23 @@ ProcessArgs(int argc, char **argv, int *mode, int *alias)
Usage();
break;
+ case PHYS_AUTO:
+ case PHYS_BACKGROUND:
+ case PHYS_DDIAL:
+ labelrequired = 1;
+ /* fall through */
+
default:
*mode = newmode;
}
+ optc++;
+ argv++;
+ argc--;
+ }
+
+ if (argc > 1) {
+ fprintf(stderr, "You may specify only one system label.\n");
+ exit(EX_START);
}
if (optc > 1) {
@@ -222,36 +235,20 @@ ProcessArgs(int argc, char **argv, int *mode, int *alias)
exit(EX_START);
}
- if (*mode == PHYS_AUTO && arg == argc) {
- fprintf(stderr, "A system must be specified in auto mode.\n");
+ if (labelrequired && argc != 1) {
+ fprintf(stderr, "Destination system must be specified in"
+ " auto, background or ddial mode.\n");
exit(EX_START);
}
- return arg; /* Don't SetLabel yet ! */
+ return argc == 1 ? *argv : NULL; /* Don't SetLabel yet ! */
}
-static void
-CheckLabel(const char *label, struct prompt *prompt, int mode)
-{
- const char *err;
-
- if ((err = system_IsValid(label, prompt, mode)) != NULL) {
- fprintf(stderr, "You may not use ppp in this mode with this label\n");
- fprintf(stderr, "%s: %s\n", label, err);
- if (mode == PHYS_DIRECT)
- log_Printf(LogWARN, "Label %s rejected -direct connection: %s\n",
- label, err);
- log_Close();
- exit(1);
- }
-}
-
-
int
main(int argc, char **argv)
{
- char *name;
- int nfds, mode, alias, label, arg;
+ char *name, *label;
+ int nfds, mode, alias;
struct bundle *bundle;
struct prompt *prompt;
@@ -271,7 +268,7 @@ main(int argc, char **argv)
#ifndef NOALIAS
PacketAliasInit();
#endif
- label = ProcessArgs(argc, argv, &mode, &alias);
+ label = ProcessArgs(argc - 1, argv + 1, &mode, &alias);
#ifdef __FreeBSD__
/*
@@ -315,11 +312,16 @@ main(int argc, char **argv)
} while (ptr >= conf);
}
- if (label < argc)
- for (arg = label; arg < argc; arg++)
- CheckLabel(argv[arg], prompt, mode);
- else
- CheckLabel("default", prompt, mode);
+ if (!system_IsValid(label, prompt, mode)) {
+ fprintf(stderr, "You may not use ppp in this mode with this label\n");
+ if (mode == PHYS_DIRECT) {
+ const char *l;
+ l = label ? label : "default";
+ log_Printf(LogWARN, "Label %s rejected -direct connection\n", l);
+ }
+ log_Close();
+ return 1;
+ }
if ((bundle = bundle_Create(TUN_PREFIX, mode, (const char **)argv)) == NULL) {
log_Printf(LogWARN, "bundle_Create: %s\n", strerror(errno));
@@ -327,12 +329,10 @@ main(int argc, char **argv)
}
if (prompt) {
prompt->bundle = bundle; /* couldn't do it earlier */
- prompt_Printf(prompt, "Using interface: %s\n", bundle->iface->name);
+ prompt_Printf(prompt, "Using interface: %s\n", bundle->ifp.Name);
}
SignalBundle = bundle;
bundle->AliasEnabled = alias;
- if (alias)
- bundle->cfg.opt |= OPT_IFACEALIAS;
if (system_Select(bundle, "default", CONFFILE, prompt, NULL) < 0)
prompt_Printf(prompt, "Warning: No default entry found in config file.\n");
@@ -349,21 +349,25 @@ main(int argc, char **argv)
sig_signal(SIGUSR2, BringDownServer);
- for (arg = label; arg < argc; arg++) {
- /* In case we use LABEL or ``set enddisc label'' */
- bundle_SetLabel(bundle, argv[argc - 1]);
- system_Select(bundle, argv[arg], CONFFILE, prompt, NULL);
- }
-
- if (label < argc)
- /* In case the last label did a ``load'' */
- bundle_SetLabel(bundle, argv[argc - 1]);
-
- if (mode == PHYS_AUTO &&
- bundle->ncp.ipcp.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
- prompt_Printf(prompt, "You must ``set ifaddr'' with a peer address "
- "in auto mode.\n");
- AbortProgram(EX_START);
+ if (label) {
+ /*
+ * Set label both before and after system_Select !
+ * This way, "set enddisc label" works during system_Select, and we
+ * also end up with the correct label if we have embedded load
+ * commands.
+ */
+ bundle_SetLabel(bundle, label);
+ if (system_Select(bundle, label, CONFFILE, prompt, NULL) < 0) {
+ prompt_Printf(prompt, "Destination system (%s) not found.\n", label);
+ AbortProgram(EX_START);
+ }
+ bundle_SetLabel(bundle, label);
+ if (mode == PHYS_AUTO &&
+ bundle->ncp.ipcp.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
+ prompt_Printf(prompt, "You must \"set ifaddr\" with a peer address "
+ "in label %s for auto mode.\n", label);
+ AbortProgram(EX_START);
+ }
}
if (mode != PHYS_INTERACTIVE) {
@@ -515,12 +519,8 @@ DoLoop(struct bundle *bundle)
for (i = 0; i <= nfds; i++)
if (FD_ISSET(i, &efds)) {
- log_Printf(LogPHASE, "Exception detected on descriptor %d\n", i);
- /* We deal gracefully with link descriptor exceptions */
- if (!bundle_Exception(bundle, i)) {
- log_Printf(LogERROR, "Exception cannot be handled !\n");
- break;
- }
+ log_Printf(LogERROR, "Exception detected on descriptor %d\n", i);
+ break;
}
if (i <= nfds)
diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c
index 6ffb5650632c..3c894929d06e 100644
--- a/usr.sbin/ppp/modem.c
+++ b/usr.sbin/ppp/modem.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: modem.c,v 1.99 1998/08/26 18:07:56 brian Exp $
+ * $Id: modem.c,v 1.98 1998/08/09 15:34:11 brian Exp $
*
* TODO:
*/
@@ -115,7 +115,7 @@ modem_Create(struct datalink *dl, int type)
p->fd = -1;
p->mbits = 0;
- p->isatty = 0;
+ p->dev_is_modem = 0;
p->out = NULL;
p->connect_count = 0;
p->dl = dl;
@@ -276,7 +276,7 @@ modem_Timeout(void *data)
timer_Stop(&modem->Timer);
timer_Start(&modem->Timer);
- if (modem->isatty || physical_IsSync(modem)) {
+ if (modem->dev_is_modem) {
if (modem->fd >= 0) {
if (ioctl(modem->fd, TIOCMGET, &modem->mbits) < 0) {
log_Printf(LogPHASE, "%s: ioctl error (%s)!\n", modem->link.name,
@@ -617,8 +617,8 @@ modem_Open(struct physical *modem, struct bundle *bundle)
* for further operation.
*/
modem->mbits = 0;
- modem->isatty = isatty(modem->fd);
- if (modem->isatty) {
+ modem->dev_is_modem = isatty(modem->fd) || physical_IsSync(modem);
+ if (modem->dev_is_modem && !physical_IsSync(modem)) {
tcgetattr(modem->fd, &rstio);
modem->ios = rstio;
log_Printf(LogDEBUG, "%s: Open: modem (get): fd = %d, iflag = %lx, "
@@ -679,7 +679,7 @@ modem_Speed(struct physical *modem)
{
struct termios rstio;
- if (!modem->isatty)
+ if (!physical_IsATTY(modem))
return 115200;
tcgetattr(modem->fd, &rstio);
@@ -697,7 +697,7 @@ modem_Raw(struct physical *modem, struct bundle *bundle)
log_Printf(LogDEBUG, "%s: Entering modem_Raw\n", modem->link.name);
- if (!modem->isatty || physical_IsSync(modem))
+ if (!isatty(modem->fd) || physical_IsSync(modem))
return 0;
if (modem->type != PHYS_DIRECT && modem->fd >= 0 && !Online(modem))
@@ -721,8 +721,7 @@ modem_Raw(struct physical *modem, struct bundle *bundle)
return (-1);
fcntl(modem->fd, F_SETFL, oldflag | O_NONBLOCK);
- if ((modem->isatty || physical_IsSync(modem)) &&
- ioctl(modem->fd, TIOCMGET, &modem->mbits) == 0 &&
+ if (modem->dev_is_modem && ioctl(modem->fd, TIOCMGET, &modem->mbits) == 0 &&
(modem->mbits & TIOCM_CD)) {
modem_StartTimer(bundle, modem);
modem_Timeout(modem);
@@ -738,7 +737,7 @@ modem_Unraw(struct physical *modem)
{
int oldflag;
- if (modem->isatty && !physical_IsSync(modem)) {
+ if (isatty(modem->fd) && !physical_IsSync(modem)) {
tcsetattr(modem->fd, TCSAFLUSH, &modem->ios);
oldflag = fcntl(modem->fd, F_GETFL, 0);
if (oldflag < 0)
@@ -776,7 +775,7 @@ modem_Offline(struct physical *modem)
timer_Stop(&modem->Timer);
modem->mbits &= ~TIOCM_DTR;
- if (modem->isatty && Online(modem)) {
+ if (isatty(modem->fd) && Online(modem)) {
tcgetattr(modem->fd, &tio);
if (cfsetspeed(&tio, B0) == -1)
log_Printf(LogWARN, "%s: Unable to set modem to speed 0\n",
@@ -797,7 +796,7 @@ modem_Close(struct physical *modem)
log_Printf(LogDEBUG, "%s: Close\n", modem->link.name);
- if (!modem->isatty) {
+ if (!isatty(modem->fd)) {
modem_PhysicalClose(modem);
*modem->name.full = '\0';
modem->name.base = modem->name.full;
@@ -877,7 +876,7 @@ modem_ShowStatus(struct cmdargs const *arg)
prompt_Printf(arg->prompt, "Name: %s\n", modem->link.name);
prompt_Printf(arg->prompt, " State: ");
if (modem->fd >= 0) {
- if (modem->isatty)
+ if (isatty(modem->fd))
prompt_Printf(arg->prompt, "open, %s carrier\n",
Online(modem) ? "with" : "no");
else
diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c
index 201ce6692bd6..e9d38baafeac 100644
--- a/usr.sbin/ppp/mp.c
+++ b/usr.sbin/ppp/mp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp.c,v 1.16 1998/09/04 18:25:59 brian Exp $
+ * $Id: mp.c,v 1.15 1998/08/26 17:39:37 brian Exp $
*/
#include <sys/types.h>
@@ -774,20 +774,9 @@ mp_SetEnddisc(struct cmdargs const *arg)
struct mp *mp = &arg->bundle->ncp.mp;
struct in_addr addr;
- switch (bundle_Phase(arg->bundle)) {
- case PHASE_DEAD:
- break;
- case PHASE_ESTABLISH:
- /* Make sure none of our links are DATALINK_LCP or greater */
- if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) {
- log_Printf(LogWARN, "enddisc: Only changable before"
- " LCP negotiations\n");
- return 1;
- }
- break;
- default:
- log_Printf(LogWARN, "enddisc: Only changable at phase DEAD/ESTABLISH\n");
- return 1;
+ if (bundle_Phase(arg->bundle) != PHASE_DEAD) {
+ log_Printf(LogWARN, "set enddisc: Only available at phase DEAD\n");
+ return 1;
}
if (arg->argc == arg->argn) {
diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c
index 875c4596e4df..680f487bcbbd 100644
--- a/usr.sbin/ppp/physical.c
+++ b/usr.sbin/ppp/physical.c
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.c,v 1.6 1998/08/25 17:48:43 brian Exp $
+ * $Id: physical.c,v 1.5 1998/08/07 18:42:50 brian Exp $
*
*/
@@ -54,6 +54,11 @@ physical_GetFD(struct physical *phys) {
}
int
+physical_IsATTY(struct physical *phys) {
+ return isatty(phys->fd);
+}
+
+int
physical_IsSync(struct physical *phys) {
return phys->cfg.speed == 0;
}
@@ -180,7 +185,7 @@ physical_IsSet(struct descriptor *d, const fd_set *fdset)
void
physical_Login(struct physical *phys, const char *name)
{
- if (phys->type == PHYS_DIRECT && phys->isatty) {
+ if (phys->type == PHYS_DIRECT && physical_IsATTY(phys)) {
if (phys->Utmp)
log_Printf(LogERROR, "Oops, already logged in on %s\n", phys->name.base);
else {
diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h
index bfd1c74aef33..2803248b407d 100644
--- a/usr.sbin/ppp/physical.h
+++ b/usr.sbin/ppp/physical.h
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.h,v 1.4 1998/08/25 17:48:43 brian Exp $
+ * $Id: physical.h,v 1.3 1998/05/29 18:33:10 brian Exp $
*
*/
@@ -30,7 +30,11 @@ struct physical {
struct hdlc hdlc; /* Our hdlc state */
int fd; /* File descriptor for this device */
int mbits; /* Current DCD status */
- unsigned isatty : 1;
+ unsigned dev_is_modem : 1; /* Is the device an actual modem?
+ Faked for sync devices, though...
+ (Possibly this should be
+ dev_is_not_tcp?) XXX-ML */
+
struct mbuf *out; /* mbuf that suffered a short write */
int connect_count;
struct datalink *dl; /* my owner */
@@ -68,6 +72,7 @@ struct physical {
((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
extern int physical_GetFD(struct physical *);
+extern int physical_IsATTY(struct physical *);
extern int physical_IsSync(struct physical *);
extern const char *physical_GetDevice(struct physical *);
extern void physical_SetDeviceList(struct physical *, int, const char *const *);
diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8
index 31d12095a8ea..4ed85beb200a 100644
--- a/usr.sbin/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp.8
@@ -1,6 +1,5 @@
-.\" $Id: ppp.8,v 1.141 1999/01/19 22:15:41 brian Exp $
+.\" $Id: ppp.8,v 1.125 1998/09/17 00:45:12 brian Exp $
.Dd 20 September 1995
-.nr XX \w'\fC00'
.Os FreeBSD
.Dt PPP 8
.Sh NAME
@@ -16,7 +15,7 @@
.Fl dedicated
.Oc
.Op Fl alias
-.Op Ar system ...
+.Op Ar system
.Sh DESCRIPTION
This is a user process
.Em PPP
@@ -95,7 +94,7 @@ scripts that wish to execute certain commands only if the connection
is successfully established.
.It Supports server-side PPP connections.
In direct mode,
-.Nm
+.nm
acts as server which accepts incoming
.Em PPP
connections on stdin/stdout.
@@ -187,122 +186,6 @@ Refer to the
logging facility if you're interested in what exactly is done as user id
zero.
.Sh GETTING STARTED
-The following command line switches are understood by
-.Nm ppp :
-.Bl -tag -width XXX -offset XXX
-.It Fl auto
-.Nm Ppp
-opens the tun interface, configures it then goes into the background.
-The link isn't brought up until outgoing data is detected on the tun
-interface at which point
-.Nm
-attempts to bring up the link. Packets received (including the first one)
-while
-.Nm
-is trying to bring the link up will remain queued for a default of
-2 minutes. See the
-.Dq set choked
-command below.
-.Pp
-At least one
-.Dq system
-must be given on the command line (see below) and a
-.Dq set ifaddr
-must be done in the system profile that specifies a peer IP address to
-use when configuring the interface. Something like
-.Dq 10.0.0.1/0
-is usually appropriate. See the
-.Dq pmdemand
-system in
-.Pa /etc/ppp/ppp.conf.sample
-for an example.
-.It Fl background
-Here,
-.Nm
-attempts to establish a connection with the peer immediately. If it
-succeeds,
-.Nm
-goes into the background and the parent process returns an exit code
-of 0. If it fails,
-.Nm
-exits with a non-zero result.
-.It Fl direct
-This is used for receiving incoming connections.
-.Nm Ppp
-ignores the ``set device'' line and uses descriptor 0 as the link.
-.Pp
-If callback is configured,
-.Nm
-will use the
-.Dq set device
-information when dialing back.
-.It Fl dedicated
-This option is designed for machines connected with a dedicated
-wire.
-.Nm Ppp
-will always keep the device open and will never use any configured
-chat scripts.
-.It Fl ddial
-This mode is equivalent to
-.Fl auto
-mode except that
-.Nm
-will bring the link back up any time it's dropped for any reason.
-.It Fl interactive
-This is a no-op, and gives the same behaviour as if none of the above
-flags have been specified.
-.Nm Ppp
-loads any systems specified on the command line then provides an
-interactive prompt.
-.It Fl alias
-This flag doesn't control
-.Nm ppp Ns No 's
-mode. It does the equivalent of an
-.Dq enable alias yes .
-Additionally, if the
-.Fl auto
-flag is also specified, an implicit
-.Dq enable iface-alias
-is done.
-See below for details.
-.Pp
-Enabling IP aliasing allows
-.Nm ppp
-to act as a NAT or masquerading engine for all machines on an internal
-LAN. Refer to
-.Xr libalias 3
-for details.
-.El
-.Pp
-Additionally, one or more systems may be specified on the command line.
-A
-.Sq system
-is a configuration entry in
-.Pa /etc/ppp/ppp.conf .
-.Nm Ppp
-will read the
-.Dq default
-system from
-.Pa /etc/ppp/ppp.conf
-at startup, followed by each of the systems specifed on the command line.
-.Pp
-Only one of the
-.Fl auto ,
-.Fl background ,
-.Fl ddial ,
-.Fl direct ,
-.Fl dedicated
-and
-.Fl interactive
-switches may be specified.
-.Nm Ppp Ns No 's
-.Sq mode
-may subsequently be changed with the
-.Dq set mode
-command (see below).
-.Pp
-For now, we'll stick to using interactive mode.
-.Pp
When you first run
.Nm
you may need to deal with some initial configuration details.
@@ -340,7 +223,7 @@ file and that that group contains the names of all users expected to use
.Nm ppp .
Refer to the
.Xr group 5
-manual page for details. Each of these users must also be given access
+manual page for details. Each of these uses must also be given access
using the
.Dq allow users
command in
@@ -467,22 +350,16 @@ When the peer starts to talk in
.Nm
detects this automatically and returns to command mode.
.Bd -literal -offset indent
-ppp ON awfulhak> # No link has been established
-Ppp ON awfulhak> # We've connected & finished LCP
-PPp ON awfulhak> # We've authenticated
-PPP ON awfulhak> # We've agreed IP numbers
+ppp ON awfulhak>
+Ppp ON awfulhak>
+PPp ON awfulhak>
+PPP ON awfulhak>
.Ed
.Pp
If it does not, it's possible that the peer is waiting for your end to
-start negotiating or that
-.Nm ppp
-can't identify the incoming packets as being
-.Em PPP
-packets, perhaps due to your parity settings. To force
+start negotiating. To force
.Nm
-to start sending
-.Em PPP
-configuration packets to the peer, use the
+to start sending PPP configuration packets to the peer, use the
.Dq ~p
command to enter packet mode.
.Pp
@@ -531,10 +408,13 @@ PPP ON awfulhak> add default HISADDR
.Pp
The string
.Sq HISADDR
-represents the IP address of the connected peer.
-If the
-.Dq add
-command fails due to an existing route, you can overwrite the existing
+represents the IP address of the connected peer. It is possible to
+use the keyword
+.Sq INTERFACE
+in place of
+.Sq HISADDR .
+This will create a direct route on the tun interface.
+If it fails due to an existing route, you can overwrite the existing
route using
.Bd -literal -offset indent
PPP ON awfulhak> add! default HISADDR
@@ -609,7 +489,7 @@ portion of the prompt will change to
.Sq PPP :
.Bd -literal -offset indent
# ppp MyISP
-\&...
+...
ppp ON awfulhak> dial
Ppp ON awfulhak>
PPp ON awfulhak>
@@ -634,15 +514,18 @@ connection is established. See the provided
.Dq pmdemand
example in
.Pa /etc/ppp/ppp.conf.sample
-which runs a script in the background after the connection is established
-(refer to the
-.Dq shell
+which runs a script in the background after the connection is established.
+The literal strings
+.Dv HISADDR ,
+.Dv MYADDR
and
-.Dq bg
-commands below for a description of possible substition strings). Similarly,
-when a connection is closed, the contents of the
+.Dv INTERFACE
+may be used, and will be replaced with the relevant IP addresses and interface
+name. Similarly, when a connection is closed, the
+contents of the
.Pa /etc/ppp/ppp.linkdown
-file are executed. Both of these files have the same format as
+file are executed.
+Both of these files have the same format as
.Pa /etc/ppp/ppp.conf .
.Pp
In previous versions of
@@ -1286,7 +1169,7 @@ and represent the TH_ACK, TH_SYN and TH_FIN or TH_RST TCP flags respectively.
.El
.Pp
.It
-Each filter can hold up to 40 rules, starting from rule 0.
+Each filter can hold up to 20 rules, starting from rule 0.
The entire rule set is not effective until rule 0 is defined,
ie. the default is to allow everything through.
.It
@@ -1299,7 +1182,7 @@ to flush all rules.
.El
.Pp
See
-.Pa /etc/ppp/ppp.conf.sample .
+.Pa /etc/ppp/ppp.conf.example .
.Sh SETTING THE IDLE TIMER
To check/set the idle timer, use the
.Dq show bundle
@@ -1321,7 +1204,7 @@ ppp ON awfulhak> set timeout 0
In
.Fl ddial
and
-.Fl dedicated
+.Fl direct
modes, the idle timeout is ignored. In
.Fl auto
mode, when the idle timeout causes the
@@ -1668,7 +1551,7 @@ required a similar entry in the
.Pa /etc/ppp/ppp.linkup
file. Since the advent of
.Sq sticky routes ,
-this is no longer required.
+his is no longer required.
.It
If your provider requests that you use PAP/CHAP authentication methods, add
the next lines to your
@@ -1709,57 +1592,28 @@ ISPs.
is able to generate the following log info either via
.Xr syslog 3
or directly to the screen:
-.Pp
-.Bl -tag -width XXXXXXXXX -offset XXX -compact
-.It Li Async
-Dump async level packet in hex.
-.It Li CBCP
-Generate CBCP (CallBack Control Protocol) logs.
-.It Li CCP
-Generate a CCP packet trace.
-.It Li Chat
-Generate
-.Sq dial ,
-.Sq login
-and
-.Sq hangup
-chat script trace logs.
-.It Li Command
-Log commands executed either from the command line or any of the configuration
-files.
-.It Li Connect
-Log Chat lines containing the string "CONNECT".
-.It Li Debug
-Log debug information.
-.It Li HDLC
-Dump HDLC packet in hex.
-.It Li ID0
-Log all function calls specifically made as user id 0.
-.It Li IPCP
-Generate an IPCP packet trace.
-.It Li LCP
-Generate an LCP packet trace.
-.It Li LQM
-Generate LQR reports.
-.It Li Phase
-Phase transition log output.
-.It Li TCP/IP
-Dump all TCP/IP packets.
-.It Li Timer
-Log timer manipulation.
-.It Li TUN
-Include the tun device on each log line.
-.It Li Warning
-Output to the terminal device. If there is currently no terminal,
-output is sent to the log file using syslogs
-.Dv LOG_WARNING .
-.It Li Error
-Output to both the terminal device
-and the log file using syslogs
-.Dv LOG_ERROR .
-.It Li Alert
-Output to the log file using
-.Dv LOG_ALERT .
+.Bl -column SMMMMMM -offset indent
+.It Li Async Dump async level packet in hex
+.It Li CBCP Generate CBCP (CallBack Control Protocol) logs
+.It Li CCP Generate a CCP packet trace
+.It Li Chat Generate Chat script trace log
+.It Li Command Log commands executed
+.It Li Connect Generate complete Chat log
+.It Li Debug Log debug information
+.It Li HDLC Dump HDLC packet in hex
+.It Li ID0 Log all function calls specifically made as user id 0.
+.It Li IPCP Generate an IPCP packet trace
+.It Li LCP Generate an LCP packet trace
+.It Li LQM Generate LQR report
+.It Li Phase Phase transition log output
+.It Li TCP/IP Dump all TCP/IP packets
+.It Li Timer Log timer manipulation
+.It Li TUN Include the tun device on each log line
+.It Li Warning Output to the terminal device. If there is currently no
+terminal, output is sent to the log file using LOG_WARNING.
+.It Li Error Output to both the terminal device and the log file using
+LOG_ERROR.
+.It Li Alert Output to the log file using LOG_ALERT
.El
.Pp
The
@@ -2236,11 +2090,6 @@ as the client password in
Default: Disabled. Enabling this option will tell
.Nm
to proxy ARP for the peer.
-.It proxyall
-Default: Disabled. Enabling this will tell
-.Nm
-to add proxy arp entries for every IP address in all class C or
-smaller subnets routed via the tun interface.
.It sroutes
Default: Enabled. When the
.Dq add
@@ -2285,28 +2134,6 @@ this option will tell
.Nm
not to make any utmp or wtmp entries. This is usually only necessary if
you require the user to both login and authenticate themselves.
-.It iface-alias
-Default: Enabled if
-.Fl alias
-is specified. This option simply tells
-.Nm
-to add new interface addresses to the interface rather than replacing them.
-The option can only be enabled if IP aliasing is enabled
-.Pq Dq alias enable yes .
-.Pp
-With this option enabled,
-.Nm
-will pass traffic for old interface addresses through the IP alias engine
-.Pq see Xr libalias 5 ,
-resulting in the ability (in
-.Fl auto
-mode) to properly connect the process that caused the PPP link to
-come up in the first place.
-.Pp
-Disabling IP aliasing with
-.Dq alias enable off
-will also disable
-.Sq iface-alias .
.El
.Pp
.It add[!] Ar dest[/nn] [mask] gateway
@@ -2335,14 +2162,24 @@ It is possible to use the symbolic names
.Sq MYADDR
or
.Sq HISADDR
-as the destination, and
+as the destination, and either
.Sq HISADDR
+or
+.Sq INTERFACE
as the
.Ar gateway .
.Sq MYADDR
-is replaced with the interface address and
+is replaced with the interface address,
.Sq HISADDR
-is replaced with the interface destination (peer) address.
+is replaced with the interface destination address and
+.Sq INTERFACE
+is replaced with the current interface name. If the interfaces destination
+address has not yet been assigned
+.Pq via Dq set ifaddr ,
+the current
+.Sq INTERFACE
+is used instead of
+.Sq HISADDR .
.Pp
If the
.Ar add!
@@ -2533,18 +2370,12 @@ file.
This is replaced with the IP number assigned to the local interface.
.It Li PEER_ENDDISC
This is replaced with the value of the peers endpoint discriminator.
-.It Li PROCESSID
-This is replaced with the current process id.
.It Li USER
This is replaced with the username that has been authenticated with PAP or
CHAP. Normally, this variable is assigned only in -direct mode. This value
is available irrespective of whether utmp logging is enabled.
.El
.Pp
-These substitutions are also done by the
-.Dq set proctitle
-command.
-.Pp
If you wish to pause
.Nm
while the command executes, use the
@@ -2623,7 +2454,7 @@ will not complain if the route does not already exist.
.It dial|call Op Ar label
When used with no argument, this command is the same as the
.Dq open
-command. When one or more
+command. When
.Ar label
is specified, a
.Dq load
@@ -2645,70 +2476,6 @@ is specified, only the relevant compression layer(s) are terminated.
Show a list of available commands. If
.Ar command
is specified, show the usage string for that command.
-.It iface Ar command Op args
-This command is used to control the interface used by
-.Nm ppp .
-.Ar Command
-may be one of the following:
-.Bl -tag -width XX
-.It iface add[!] Ar addr[[/bits| mask] peer]
-Add the given
-.Ar addr mask peer
-combination to the interface. Instead of specifying
-.Ar mask ,
-.Ar /bits
-can be used
-.Pq with no space between \&it and Ar addr .
-If the given address already exists, the command fails unless the
-.Dq \&!
-is used - in which case the previous interface address entry is overwritten
-with the new one, allowing a change of netmask or peer address.
-.Pp
-If only
-.Ar addr
-is specified,
-.Ar bits
-defaults to
-.Dq 32
-and
-.Ar peer
-defaults to
-.Dq 255.255.255.255 .
-This address (the broadcast address) is the only duplicate peer address that
-.Nm
-allows.
-.It iface clear
-If this command is used while
-.Nm
-is in the OPENED state or while in
-.Fl auto
-mode, all addresses except for the IPCP negotiated address are deleted
-from the interface. If
-.Nm
-is not in the OPENED state and is not in
-.Fl auto
-mode, all interface addresses are deleted.
-.Pp
-.It iface delete[!]|rm[!] Ar addr
-This command deletes the given
-.Ar addr
-from the interface. If the
-.Dq \&!
-is used, no error is given if the address isn't currently assigned to
-the interface (and no deletion takes place).
-.It iface show
-Shows the current state and current addresses for the interface. It is
-much the same as running
-.Dq ifconfig INTERFACE .
-.It iface help Op Ar sub-command
-This command, when invoked without
-.Ar sub-command ,
-will show a list of possbile
-.Dq iface
-sub-commands and a brief synopsis for each. When invoked with
-.Ar sub-command ,
-only the synopsis for the given sub-command is shown.
-.El
.It [data]link Ar name[,name...] command Op Ar args
This command may prefix any other command if the user wishes to
specify which link the command should affect. This is only
@@ -2728,9 +2495,9 @@ is
.Dq * ,
.Ar command
is executed on all links.
-.It load Op Ar label ...
+.It load Op Ar label
Load the given
-.Ar label(s)
+.Ar label
from the
.Pa ppp.conf
file. If
@@ -2799,8 +2566,8 @@ ppp will exit after closing all connections. Otherwise, if the user
is connected to a diagnostic socket, the connection is simply dropped.
.Pp
If the
-.Ar all
-argument is given,
+.Ar
+all argument is given,
.Nm
will exit despite the source of the command after closing all existing
connections.
@@ -2892,20 +2659,12 @@ links will stay active until the bundle idle timer expires.
If no arguments are given, callback is disabled, otherwise,
.Nm
will request (or in
-.Fl direct
-mode, will accept) one of the given protocols. In client mode, if a
-request is NAK'd
+.Ar direct
+mode, will accept) one of the given protocols. If a request is NAK'd
.Nm
will request another, until no options remain at which point
.Nm
-will terminate negotiations. In server mode,
-.Nm
-will accept any of the given protocols - but the client
-.Em must
-request one of them. If you wish callback to be optional, you must include
-.Ar none
-as an option.
-.Pp
+will terminate negotiations.
The options are as follows (in this order of preference):
.Pp
.Bl -tag
@@ -2943,7 +2702,7 @@ themselves.
If the peer does not wish to do callback at all,
.Nm
will accept the fact and continue without callback rather than terminating
-the connection. This is required if you wish callback to be optional.
+the connection.
.El
.Pp
.It set cbcp Op *|number[,number]... Op delay Op retry
@@ -3263,7 +3022,7 @@ Filtering is done prior to any IP alterations that might be done by the
alias engine. By default all filter sets allow all packets to pass.
Rules are processed in order according to
.Ar rule-no .
-Up to 40 rules may be given for each set. If a packet doesn't match
+Up to 20 rules may be given for each set. If a packet doesn't match
any of the rules in a given set, it is discarded. In the case of
.Em in
and
@@ -3401,16 +3160,6 @@ It is not possible to change a link that is
.Sq direct
or
.Sq dedicated .
-.Pp
-Note: If you issue the command
-.Dq set mode auto ,
-and have IP aliasing enabled, it may be useful to
-.Dq enable iface-alias
-afterwards. This will allow
-.Nm
-to do the necessary address translations to enable the process that
-triggers the connection to connect once the link is up despite the
-peer assigning us a new (dynamic) IP address.
.It set mrru Op Ar value
Setting this option enables Multi-link PPP negotiations, also known as
Multi-link Protocol or MP. There is no default MRRU (Maximum
@@ -3479,25 +3228,6 @@ the maximum number of times specified by
below. In
.Fl background
mode, each number is attempted at most once.
-.It set [proc]title Op Ar value
-The current process title as displayed by
-.Xr ps 1
-is changed according to
-.Ar value .
-If
-.Ar value
-is not specified, the original process title is restored. All the
-word replacements done by the shell commands (see the
-.Dq bg
-command above) are done here too.
-.Pp
-Note, if USER is required in the process title, the
-.Dq set proctitle
-command must appear in
-.Pa ppp.linkup ,
-as it is not known when the commands in
-.Pa ppp.conf
-are executed.
.It set reconnect Ar timeout ntries
Should the line drop unexpectedly (due to loss of CD or LQR
failure), a connection will be re-established after the given
@@ -3511,11 +3241,6 @@ defaults to zero. A value of
for
.Ar timeout
will result in a variable pause, somewhere between 0 and 30 seconds.
-.It set recvpipe Op Ar value
-This sets the routing table RECVPIPE value. The optimum value is
-just over twice the MTU value. If
-.Ar value
-is unspecified or zero, the default kernel controlled value is used.
.It set redial Ar seconds[.nseconds] [attempts]
.Nm Ppp
can be instructed to attempt to redial
@@ -3544,11 +3269,6 @@ should immediately follow the
keyword. See the
.Dq open
description above for further details.
-.It set sendpipe Op Ar value
-This sets the routing table SENDPIPE value. The optimum value is
-just over twice the MTU value. If
-.Ar value
-is unspecified or zero, the default kernel controlled value is used.
.It set server|socket Ar TcpPort|LocalName|none password Op Ar mask
This command tells
.Nm
@@ -3689,9 +3409,6 @@ is not specified, all filters are shown.
Show the current HDLC statistics.
.It show help|?
Give a summary of available show commands.
-.It show iface
-Show the current interface information
-.Pq the same \&as Dq iface show .
.It show ipcp
Show the current IPCP statistics.
.It show lcp
@@ -3736,11 +3453,11 @@ Read the example configuration files. They are a good source of information.
.It
Use
.Dq help ,
+.Dq show ? ,
.Dq alias ? ,
-.Dq enable ? ,
.Dq set ?
and
-.Dq show ?
+.Dq set ? <var>
to get online information about what's available.
.It
The following urls contain useful information:
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c
index 7f70efb7bd53..a80204d1be25 100644
--- a/usr.sbin/ppp/route.c
+++ b/usr.sbin/ppp/route.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: route.c,v 1.53 1998/08/17 06:42:40 brian Exp $
+ * $Id: route.c,v 1.52 1998/07/28 21:54:54 brian Exp $
*
*/
@@ -61,7 +61,6 @@
#include "bundle.h"
#include "route.h"
#include "prompt.h"
-#include "iface.h"
static void
p_sockaddr(struct prompt *prompt, struct sockaddr *phost,
@@ -362,7 +361,7 @@ route_IfDelete(struct bundle *bundle, int all)
char *sp, *cp, *ep;
int mib[6];
- log_Printf(LogDEBUG, "route_IfDelete (%d)\n", bundle->iface->index);
+ log_Printf(LogDEBUG, "route_IfDelete (%d)\n", bundle->ifp.Index);
sa_none.s_addr = INADDR_ANY;
mib[0] = CTL_NET;
@@ -408,7 +407,7 @@ route_IfDelete(struct bundle *bundle, int all)
Index2Nam(rtm->rtm_index), rtm->rtm_flags,
inet_ntoa(((struct sockaddr_in *) sa)->sin_addr));
if (rtm->rtm_addrs & RTA_DST && rtm->rtm_addrs & RTA_GATEWAY &&
- rtm->rtm_index == bundle->iface->index &&
+ rtm->rtm_index == bundle->ifp.Index &&
(all || (rtm->rtm_flags & RTF_GATEWAY))) {
sa_dst.s_addr = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
sa = (struct sockaddr *)((char *)sa + sa->sa_len);
diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c
index f786b1bc5776..e5583f661dd4 100644
--- a/usr.sbin/ppp/systems.c
+++ b/usr.sbin/ppp/systems.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.c,v 1.39 1998/10/17 12:28:03 brian Exp $
+ * $Id: systems.c,v 1.37 1998/06/15 19:05:47 brian Exp $
*
* TODO:
*/
@@ -156,10 +156,7 @@ DecodeCtrlCommand(char *line, char *arg)
return CTRL_UNKNOWN;
}
-/*
- * Initialised in system_IsValid(), set in ReadSystem(),
- * used by system_IsValid()
- */
+/* Initialised in system_IsValid(), set in ReadSystem(), used by system_IsValid() */
static int modeok;
static int userok;
static int modereq;
@@ -318,13 +315,8 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
if (*cp == '\0') /* empty / comment */
continue;
- if (!indent) { /* start of next section */
- wp = strchr(cp, ':');
- if (doexec && (wp == NULL || wp[1] != '\0'))
- log_Printf(LogWARN, "Unindented command (%s line %d) - ignored\n",
- filename, linenum);
+ if (!indent) /* start of next section */
break;
- }
len = strlen(cp);
argc = command_Interpret(cp, len, argv);
@@ -344,38 +336,22 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
return -1;
}
-const char *
+int
system_IsValid(const char *name, struct prompt *prompt, int mode)
{
/*
* Note: The ReadSystem() calls only result in calls to the Allow*
* functions. arg->bundle will be set to NULL for these commands !
*/
- int def;
-
- if (ID0realuid() == 0) {
- userok = modeok = 1;
- return NULL;
- }
-
- def = !strcmp(name, "default");
+ if (ID0realuid() == 0)
+ return userok = modeok = 1;
userok = 0;
modeok = 1;
modereq = mode;
-
- if (ReadSystem(NULL, "default", CONFFILE, 0, prompt, NULL) != 0 && def)
- return "System not found";
-
- if (!def && ReadSystem(NULL, name, CONFFILE, 0, prompt, NULL) != 0)
- return "System not found";
-
- if (!userok)
- return "Invalid user id";
-
- if (!modeok)
- return "Invalid mode";
-
- return NULL;
+ ReadSystem(NULL, "default", CONFFILE, 0, prompt, NULL);
+ if (name != NULL)
+ ReadSystem(NULL, name, CONFFILE, 0, prompt, NULL);
+ return userok && modeok;
}
int
diff --git a/usr.sbin/ppp/systems.h b/usr.sbin/ppp/systems.h
index e85b865bdbe5..5d3c311a9537 100644
--- a/usr.sbin/ppp/systems.h
+++ b/usr.sbin/ppp/systems.h
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.h,v 1.12 1998/06/15 19:05:51 brian Exp $
+ * $Id: systems.h,v 1.11 1998/05/21 21:48:36 brian Exp $
*
*/
@@ -28,7 +28,7 @@ struct cmdargs;
extern int system_Select(struct bundle *bundle, const char *, const char *,
struct prompt *, struct datalink *);
-extern const char *system_IsValid(const char *, struct prompt *, int);
+extern int system_IsValid(const char *, struct prompt *, int);
extern FILE *OpenSecret(const char *);
extern void CloseSecret(FILE *);
extern int AllowUsers(struct cmdargs const *);
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c
index 0bf2258e8a08..9accce3bfab6 100644
--- a/usr.sbin/ppp/timer.c
+++ b/usr.sbin/ppp/timer.c
@@ -17,12 +17,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: timer.c,v 1.31 1998/06/27 14:18:11 brian Exp $
+ * $Id: timer.c,v 1.30 1998/06/20 01:36:38 brian Exp $
*
* TODO:
*/
-#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <sys/time.h>
@@ -97,8 +96,8 @@ timer_Start(struct pppTimer * tp)
if (pt) {
pt->next = tp;
} else {
+ timer_InitService();
TimerList = tp;
- timer_InitService(0); /* Start the Timer Service */
}
if (t)
t->rest -= tp->rest;
@@ -144,7 +143,7 @@ StopTimerNoBlock(struct pppTimer * tp)
static void
TimerService(void)
{
- struct pppTimer *tp, *exp, *next;
+ struct pppTimer *tp, *exp, *wt;
if (log_IsKept(LogTIMER)) {
static time_t t; /* Only show timers globally every second */
@@ -154,34 +153,43 @@ TimerService(void)
timer_Show(LogTIMER, NULL);
t = n;
}
-
tp = TimerList;
if (tp) {
- tp->rest = 0;
+ tp->rest--;
+ if (tp->rest == 0) {
- /* Multiple timers might expire at once. Create a list of expired timers */
- exp = NULL;
- do {
- tp->state = TIMER_EXPIRED;
- next = tp->next;
- tp->enext = exp;
- exp = tp;
- tp = next;
- } while (tp && tp->rest == 0);
-
- TimerList = tp;
- if (TimerList != NULL) /* Any timers remaining ? */
- timer_InitService(1); /* Restart the Timer Service */
- else
- timer_TermService(); /* Stop the Timer Service */
-
- /* Process all expired timers */
- while (exp) {
- next = exp->enext;
- exp->enext = NULL;
- if (exp->func)
- (*exp->func)(exp->arg);
- exp = next;
+ /*
+ * Multiple timers may expires at once. Create list of expired timers.
+ */
+ exp = NULL;
+ do {
+ tp->state = TIMER_EXPIRED;
+ wt = tp->next;
+ tp->enext = exp;
+ exp = tp;
+ tp = wt;
+ } while (tp && (tp->rest == 0));
+
+ TimerList = tp;
+ if (TimerList == NULL) /* No timers ? */
+ timer_TermService(); /* Terminate Timer Service */
+
+ /*
+ * Process all expired timers.
+ */
+ while (exp) {
+#ifdef notdef
+ timer_Stop(exp);
+#endif
+ if (exp->func)
+ (*exp->func) (exp->arg);
+
+ /*
+ * Just Removing each item from expired list And exp->enext will be
+ * intialized at next expire in this funtion.
+ */
+ exp = exp->enext;
+ }
}
}
}
@@ -215,20 +223,15 @@ timer_Show(int LogLevel, struct prompt *prompt)
}
void
-timer_InitService(int restart)
+timer_InitService()
{
struct itimerval itimer;
- if (TimerList) {
- if (!restart)
- sig_signal(SIGALRM, (void (*)(int))TimerService);
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = TimerList->rest / SECTICKS;
- itimer.it_value.tv_usec = (TimerList->rest % SECTICKS) * TICKUNIT;
- if (setitimer(ITIMER_REAL, &itimer, NULL) == -1)
- log_Printf(LogERROR, "Unable to set itimer (%s)\n", sys_errlist[errno]);
- }
+ sig_signal(SIGALRM, (void (*) (int)) TimerService);
+ itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0;
+ itimer.it_interval.tv_usec = itimer.it_value.tv_usec = TICKUNIT;
+ if (setitimer(ITIMER_REAL, &itimer, NULL) == -1)
+ log_Printf(LogERROR, "Unable to set itimer.\n");
}
void
@@ -239,6 +242,6 @@ timer_TermService(void)
itimer.it_interval.tv_usec = itimer.it_interval.tv_sec = 0;
itimer.it_value.tv_usec = itimer.it_value.tv_sec = 0;
if (setitimer(ITIMER_REAL, &itimer, NULL) == -1)
- log_Printf(LogERROR, "Unable to set itimer (%s)\n", sys_errlist[errno]);
+ log_Printf(LogERROR, "Unable to set itimer.\n");
sig_signal(SIGALRM, SIG_IGN);
}
diff --git a/usr.sbin/ppp/timer.h b/usr.sbin/ppp/timer.h
index ae1f521abfd2..5e6b6be5a7f1 100644
--- a/usr.sbin/ppp/timer.h
+++ b/usr.sbin/ppp/timer.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: timer.h,v 1.7 1998/06/20 01:36:38 brian Exp $
+ * $Id: timer.h,v 1.6 1998/05/21 21:48:49 brian Exp $
*
* TODO:
*/
@@ -42,6 +42,6 @@ struct prompt;
extern void timer_Start(struct pppTimer *);
extern void timer_Stop(struct pppTimer *);
-extern void timer_InitService(int);
+extern void timer_InitService(void);
extern void timer_TermService(void);
extern void timer_Show(int LogLevel, struct prompt *);
diff --git a/usr.sbin/ppp/tun.c b/usr.sbin/ppp/tun.c
index 6d97e38c4b75..c1d021f58a6d 100644
--- a/usr.sbin/ppp/tun.c
+++ b/usr.sbin/ppp/tun.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tun.c,v 1.9 1998/08/09 16:41:01 brian Exp $
+ * $Id: tun.c,v 1.8 1998/06/27 14:18:15 brian Exp $
*/
#include <sys/types.h>
@@ -65,10 +65,9 @@ tun_configure(struct bundle *bundle, int mtu)
{
struct tuninfo info;
- memset(&info, '\0', sizeof info);
info.type = IFT_PPP;
info.mtu = mtu;
- info.baudrate = bundle->ifSpeed;
+ info.baudrate = bundle->ifp.Speed;
#ifdef __OpenBSD__
info.flags = IFF_UP|IFF_POINTOPOINT;
#endif
diff --git a/usr.sbin/pw/README b/usr.sbin/pw/README
index 38881271227e..9302f6b5fec8 100644
--- a/usr.sbin/pw/README
+++ b/usr.sbin/pw/README
@@ -13,10 +13,10 @@ the command "pw useradd <loginid>". Creation of a unique primary
group for each user and automatic memberhip in secondary groups
is fully supported.
-This program may be FreeBSD specific, but should be trivial to port to
+This program may be FreBSD specific, but should be trivial to port to
other bsd4.4 variants.
Author and maintainer: David L. Nugent, <davidn@blaze.net.au>
-$Id: README,v 1.3 1997/02/22 16:12:18 peter Exp $
+$Id$
diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c
index f862cbe12346..3dc9276d518d 100644
--- a/usr.sbin/pw/pw.c
+++ b/usr.sbin/pw/pw.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: pw.c,v 1.10 1998/08/04 22:31:26 nate Exp $";
+ "$Id: pw.c,v 1.8 1998/07/16 17:18:25 nate Exp $";
#endif /* not lint */
#include "pw.h"
@@ -50,6 +50,7 @@ static struct cargs arglist;
static int getindex(const char *words[], const char *word);
static void cmdhelp(int mode, int which);
+static void filelock(const char *filename);
int
@@ -149,6 +150,12 @@ main(int argc, char *argv[])
*/
cnf = read_userconfig(getarg(&arglist, 'C') ? getarg(&arglist, 'C')->val : NULL);
+ /*
+ * Try to lock the master passowrd and group files right away (we
+ * don't care if it works, since this is just advisory locking.
+ */
+ filelock(_PATH_GROUP);
+ filelock(_PATH_MASTERPASSWD);
ch = funcs[which] (cnf, mode, &arglist);
/*
@@ -179,6 +186,11 @@ main(int argc, char *argv[])
return ch;
}
+static void
+filelock(const char *filename)
+{
+ open(filename, O_RDONLY | O_EXLOCK, 0);
+}
static int
getindex(const char *words[], const char *word)
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 87ec76c7716c..d10c5283f5f8 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: pw_user.c,v 1.24 1999/01/02 04:37:46 billf Exp $";
+ "$Id$";
#endif /* not lint */
#include <ctype.h>
@@ -925,7 +925,7 @@ pw_password(struct userconf * cnf, struct cargs * args, char const * user)
l = (random() % 8 + 8); /* 8 - 16 chars */
pw_getrand(rndbuf, l);
for (i = 0; i < l; i++)
- pwbuf[i] = chars[rndbuf[i] % (sizeof(chars)-1)];
+ pwbuf[i] = chars[rndbuf[i] % sizeof(chars)];
pwbuf[i] = '\0';
/*
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.8 b/usr.sbin/pwd_mkdb/pwd_mkdb.8
index 7beecd779e9f..54abc76a3989 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.8
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.8
@@ -40,7 +40,6 @@
.Sh SYNOPSIS
.Nm pwd_mkdb
.Op Fl C
-.Op Fl N
.Op Fl p
.Op Fl d Ar directory
.Op Fl s Ar cachesize
@@ -68,12 +67,6 @@ The options are as follows:
.It Fl C
Check if the password file is in the correct format. Do not
change, add, or remove any files.
-.It Fl N
-Tell
-.Nm Pwd_mkdb
-to exit with an error if it cannot obtain a lock on the file. By default,
-we block waiting for a lock on the source file. The lock is held through
-the rebuilding of the database.
.It Fl p
Create a Version 7 style password file and install it into
.Pa /etc/passwd .
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index bb0398e46a04..3b73d8a4fdf2 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94";
#endif
static const char rcsid[] =
- "$Id: pwd_mkdb.c,v 1.29 1998/12/13 01:53:50 dillon Exp $";
+ "$Id: pwd_mkdb.c,v 1.26 1998/06/09 20:19:59 ache Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -109,13 +109,12 @@ main(argc, argv)
char *username;
u_int method, methoduid;
int Cflag;
- int nblock = 0;
Cflag = 0;
strcpy(prefix, _PATH_PWD);
makeold = 0;
username = NULL;
- while ((ch = getopt(argc, argv, "Cd:ps:u:vN")) != -1)
+ while ((ch = getopt(argc, argv, "Cd:ps:u:v")) != -1)
switch(ch) {
case 'C': /* verify only */
Cflag = 1;
@@ -134,9 +133,6 @@ main(argc, argv)
break;
case 'v': /* backward compatible */
break;
- case 'N': /* do not wait for lock */
- nblock = LOCK_NB;
- break;
default:
usage();
}
@@ -162,30 +158,9 @@ main(argc, argv)
(void)umask(0);
pname = *argv;
-
- /*
- * Open and lock the original password file. We have to check
- * the hardlink count after we get the lock to handle any potential
- * unlink/rename race.
- *
- * This lock is necessary when someone runs pwd_mkdb manually, directly
- * on master.passwd, to handle the case where a user might try to
- * change his password while pwd_mkdb is running.
- */
- for (;;) {
- struct stat st;
-
- if (!(fp = fopen(pname, "r")))
- error(pname);
- if (flock(fileno(fp), LOCK_EX|nblock) < 0)
- error("flock");
- if (fstat(fileno(fp), &st) < 0)
- error(pname);
- if (st.st_nlink != 0)
- break;
- fclose(fp);
- fp = NULL;
- }
+ /* Open the original password file */
+ if (!(fp = fopen(pname, "r")))
+ error(pname);
/* check only if password database is valid */
if (Cflag) {
@@ -312,10 +287,6 @@ main(argc, argv)
(pwd.pw_name[0] == '+' || pwd.pw_name[0] == '-'))
yp_enabled = 1;
#define COMPACT(e) t = e; while ((*p++ = *t++));
-#ifdef PASSWD_IGNORE_COMMENTS
- if(is_comment)
- --cnt;
-#endif
if (!is_comment &&
(!username || (strcmp(username, pwd.pw_name) == 0))) {
/* Create insecure data. */
@@ -456,6 +427,8 @@ main(argc, argv)
/* Set master.passwd permissions, in case caller forgot. */
(void)fchmod(fileno(fp), S_IRUSR|S_IWUSR);
+ if (fclose(fp) == EOF)
+ error("close fp");
/* Install as the real password files. */
(void)snprintf(buf, sizeof(buf), "%s/%s.tmp", prefix, _MP_DB);
@@ -477,13 +450,6 @@ main(argc, argv)
*/
(void)snprintf(buf, sizeof(buf), "%s/%s", prefix, _MASTERPASSWD);
mv(pname, buf);
-
- /*
- * Close locked password file after rename()
- */
- if (fclose(fp) == EOF)
- error("close fp");
-
exit(0);
}
@@ -614,6 +580,6 @@ usage()
{
(void)fprintf(stderr,
-"usage: pwd_mkdb [-C] [-N] [-p] [-d <dest dir>] [-s <cachesize>] [-u <local username>] file\n");
+"usage: pwd_mkdb [-C] [-p] [-d <dest dir>] [-s <cachesize>] [-u <local username>] file\n");
exit(1);
}
diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c
index 547fd8fd8637..7be0641814da 100644
--- a/usr.sbin/quot/quot.c
+++ b/usr.sbin/quot/quot.c
@@ -31,7 +31,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: quot.c,v 1.8 1998/01/17 16:45:03 bde Exp $";
+ "$Id: quot.c,v 1.7 1997/10/10 06:31:07 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -66,14 +66,11 @@ static int headerlen;
* The new code always counts the number of 512 byte blocks
* instead of the number of kilobytes and converts them to
* kByte when done (on request).
- *
- * Due to the size of modern disks, we must cast intermediate
- * values to 64 bits to prevent potential overflows.
*/
#ifdef COMPAT
#define SIZE(n) (n)
#else
-#define SIZE(n) ((int)(((quad_t)(n) * 512 + blocksize - 1)/blocksize))
+#define SIZE(n) (((n) * 512 + blocksize - 1)/blocksize)
#endif
#define INOCNT(fs) ((fs)->fs_ipg)
diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c
index ccc7eb1721d3..f09c1d668121 100644
--- a/usr.sbin/rarpd/rarpd.c
+++ b/usr.sbin/rarpd/rarpd.c
@@ -27,7 +27,7 @@ The Regents of the University of California. All rights reserved.\n";
#ifndef lint
static const char rcsid[] =
- "$Id: rarpd.c,v 1.19 1998/04/02 13:20:15 roberto Exp $";
+ "$Id: rarpd.c,v 1.18 1998/01/16 17:38:54 bde Exp $";
#endif /* not lint */
/*
@@ -400,7 +400,7 @@ init(target)
static void
usage()
{
- (void)fprintf(stderr, "usage: rarpd [-afsv] [interface]\n");
+ (void)fprintf(stderr, "usage: rarpd [-afnv] [interface]\n");
exit(1);
}
diff --git a/usr.sbin/rwhod/rwhod.8 b/usr.sbin/rwhod/rwhod.8
index 8050ca97f425..a7243e4040d9 100644
--- a/usr.sbin/rwhod/rwhod.8
+++ b/usr.sbin/rwhod/rwhod.8
@@ -39,8 +39,6 @@
.Nd system status server
.Sh SYNOPSIS
.Nm rwhod
-.Op Fl i
-.Op Fl l
.Op Fl m Op Ar ttl
.Sh DESCRIPTION
.Nm Rwhod
@@ -55,11 +53,7 @@ or
messages on a network.
.Pp
.Nm Rwhod
-operates as both a producer and consumer of status information,
-unless the
-.Fl l
-(listen mode) option is specified, in which case
-it acts as a consumer only.
+operates as both a producer and consumer of status information.
As a producer of information it periodically
queries the state of the system and constructs
status messages which are broadcasted or multicasted on a network.
@@ -70,21 +64,6 @@ them in a collection of files located in the directory
.Pa /var/rwho .
.Pp
The
-.Fl i
-option enables insecure mode, which causes
-.Nm
-to ignore the source port on incoming packets.
-.Pp
-The
-.Fl l
-option enables listen mode, which causes
-.Nm
-to not broadcast any information.
-This allows you to monitor other machines'
-.Nm
-information, without broadcasting your own.
-.Pp
-The
.Fl m
option causes
.Nm
@@ -184,9 +163,7 @@ Messages received by the
.Nm rwho
server are discarded unless they originated at an
.Nm rwho
-server's port or the
-.Fl i
-option was specified. In addition, if the host's name, as specified
+server's port. In addition, if the host's name, as specified
in the message, contains any unprintable
.Tn ASCII
characters, the
diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c
index 6b6899f6b274..229d1f17919b 100644
--- a/usr.sbin/rwhod/rwhod.c
+++ b/usr.sbin/rwhod/rwhod.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)rwhod.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: rwhod.c,v 1.8 1998/12/17 11:05:57 des Exp $";
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -115,8 +115,6 @@ static const char rcsid[] =
#define INADDR_WHOD_GROUP (u_long)0xe0000103 /* 224.0.1.3 */
/* (belongs in protocols/rwhod.h) */
-int insecure_mode;
-int quiet_mode;
int multicast_mode = NO_MULTICAST;
int multicast_scope;
struct sockaddr_in multicast_addr = { sizeof multicast_addr, AF_INET };
@@ -196,10 +194,6 @@ main(argc, argv)
}
else multicast_mode = PER_INTERFACE_MULTICAST;
}
- else if (strcmp(*argv, "-i") == 0)
- insecure_mode = 1;
- else if (strcmp(*argv, "-l") == 0)
- quiet_mode = 1;
else
usage();
argv++, argc--;
@@ -258,10 +252,8 @@ main(argc, argv)
setuid(unpriv_uid);
if (!configure(s))
exit(1);
- if (!quiet_mode) {
- signal(SIGALRM, onalrm);
- onalrm(0);
- }
+ signal(SIGALRM, onalrm);
+ onalrm(0);
for (;;) {
struct whod wd;
int cc, whod, len = sizeof(from);
@@ -273,7 +265,7 @@ main(argc, argv)
syslog(LOG_WARNING, "recv: %m");
continue;
}
- if (from.sin_port != sp->s_port && !insecure_mode) {
+ if (from.sin_port != sp->s_port) {
syslog(LOG_WARNING, "%d: bad from port",
ntohs(from.sin_port));
continue;
@@ -327,7 +319,7 @@ main(argc, argv)
static void
usage()
{
- fprintf(stderr, "usage: rwhod [-i] [-m [ttl]]\n");
+ fprintf(stderr, "usage: rwhod [-m [ttl]]\n");
exit(1);
}
diff --git a/usr.sbin/sendmail/Makefile b/usr.sbin/sendmail/Makefile
index 74675e29d599..cc883920c0c1 100644
--- a/usr.sbin/sendmail/Makefile
+++ b/usr.sbin/sendmail/Makefile
@@ -19,11 +19,10 @@ MAPS= -DMAP_REGEX
#TCPWRAPPERS= -DTCPWRAPPERS -I${TCPWRAPPERSBASEDIR}/include
CFLAGS+=-I${SMDIR} ${DBMDEF} ${NIS} ${TCPWRAPPERS} ${MAPS}
-CFLAGS+=-D_FFR_MAX_MIME_HEADER_LENGTH
-SRCS= alias.c arpadate.c clock.c collect.c conf.c control.c convtime.c \
- daemon.c deliver.c domain.c envelope.c err.c headers.c macro.c \
- main.c map.c mci.c mime.c parseaddr.c queue.c readcf.c recipient.c \
+SRCS= alias.c arpadate.c clock.c collect.c conf.c convtime.c daemon.c \
+ deliver.c domain.c envelope.c err.c headers.c macro.c main.c \
+ map.c mci.c mime.c parseaddr.c queue.c readcf.c recipient.c \
safefile.c savemail.c snprintf.c srvrsmtp.c stab.c stats.c \
sysexits.c trace.c udb.c usersmtp.c util.c version.c
DPADD= ${LIBUTIL}
diff --git a/usr.sbin/slstat/slstat.8 b/usr.sbin/slstat/slstat.8
index 201add7dd1b4..5b45a662f19d 100644
--- a/usr.sbin/slstat/slstat.8
+++ b/usr.sbin/slstat/slstat.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)slstat.8 6.8 (Berkeley) 6/20/91
-.\" $Id: slstat.8,v 1.11 1997/10/20 12:41:40 charnier Exp $
+.\" $Id: slstat.8,v 1.10 1997/02/22 16:13:33 peter Exp $
.\"
.Dd October 11, 1996
.Dt SLSTAT 8
@@ -62,7 +62,7 @@ is specified, the default is 5 seconds.
.It Fl v
Verbose display of extra fields of information.
.It Fl r
-Display all values in rate per second rather than amount per interval.
+Display all values in rate per second that amount per interval.
.It Ar unit
Is number specifying the
.Tn SLIP
diff --git a/usr.sbin/stallion/bootcode/stl.4 b/usr.sbin/stallion/bootcode/stl.4
index 81177eced24a..871744997e6b 100644
--- a/usr.sbin/stallion/bootcode/stl.4
+++ b/usr.sbin/stallion/bootcode/stl.4
@@ -36,7 +36,7 @@
.Nm stli
.Nd "drivers for Stallion Technologies multiport serial controllers"
.Sh SYNOPSIS
-.Cd "stl0 at isa? port <addr> tty irq <irq>"
+.Cd "stl0 at isa? port <addr> tty irq <irq> vector stlintr"
.Cd "stli0 at isa? port <io-addr> tty iomem <mem-addr> iosiz <size> flags <type> "
.Cd "stli0 at eisa? port <io-addr> tty iomem <mem-addr> iosiz <size> flags <type> "
.Sh DESCRIPTION
@@ -78,7 +78,7 @@ ISA board configuration entries for the
.Nm stl
driver take the general form of:
.Pp
-.Cd "stlX at isa? port <io-addr> tty irq <irq>"
+.Cd "stlX at isa? port <io-addr> tty irq <irq> vector stlintr"
.Pp
.Ar X
is the unit number assigned to the board.
@@ -119,7 +119,7 @@ board types.
Each EasyIO board requires 8 bytes of I/O address space and 1 IRQ line.
A configuration entry for an EasyIO board would look like:
.Pp
-.Cd "stl0 at isa? port 0x2a8 tty irq 15"
+.Cd "stl0 at isa? port 0x2a8 tty irq 15 vector stlintr"
.Pp
This entry specifies an EasyIO board at I/O address 0x2a8 using IRQ 15.
The I/O and IRQ values can be modified as required.
@@ -133,7 +133,7 @@ by multiple EasyConnection 8/32-AT boards.
This secondary I/O address is set at 0x280 in the driver code.
A configuration entry would look like:
.Pp
-.Cd "stl0 at isa? port 0x2a0 irq 10 tty"
+.Cd "stl0 at isa? port 0x2a0 irq 10 tty vector stlintr"
.Pp
This specifies an EasyConnection 8/32-AT with primary I/O address 0x2a0,
secondary I/O address of 0x280 and IRQ 10.
diff --git a/usr.sbin/sysctl/sysctl.8 b/usr.sbin/sysctl/sysctl.8
index e959ecd77aff..455dcaca85a4 100644
--- a/usr.sbin/sysctl/sysctl.8
+++ b/usr.sbin/sysctl/sysctl.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93
-.\" $Id: sysctl.8,v 1.17 1998/09/29 02:01:06 jkoshy Exp $
+.\" $Id: sysctl.8,v 1.16 1998/07/29 08:30:37 joerg Exp $
.\"
.Dd September 23, 1994
.Dt SYSCTL 8
@@ -40,14 +40,14 @@
.Nd get or set kernel state
.Sh SYNOPSIS
.Nm sysctl
-.Op Fl bdn
+.Op Fl bn
.Ar name ...
.Nm sysctl
.Op Fl bn
.Fl w
.Ar name=value ...
.Nm sysctl
-.Op Fl bdn
+.Op Fl bn
.Fl aAX
.Sh DESCRIPTION
The
@@ -85,9 +85,6 @@ set psize=`sysctl -n hw.pagesize`
Force the value of the variable(s) to be output in raw, binary
format. No names are printed and no terminating newlines are output.
This is mostly useful with a single variable.
-.It Fl d
-Display the description rather than the value of the requested
-variable(s).
.It Fl w Ar name=value ...
Set the MIB
.Ar name
diff --git a/usr.sbin/sysctl/sysctl.c b/usr.sbin/sysctl/sysctl.c
index f264409d6b3d..14247a08c225 100644
--- a/usr.sbin/sysctl/sysctl.c
+++ b/usr.sbin/sysctl/sysctl.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)from: sysctl.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: sysctl.c,v 1.19 1998/11/08 19:27:43 phk Exp $";
+ "$Id: sysctl.c,v 1.17 1998/06/29 17:54:29 bde Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -58,7 +58,7 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
-static int Aflag, aflag, bflag, dflag, nflag, wflag, Xflag;
+static int Aflag, aflag, nflag, wflag, Xflag, bflag;
static int oidfmt(int *, int, char *, u_int *);
static void parse(char *);
@@ -70,12 +70,11 @@ static void
usage(void)
{
- (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
- "usage: sysctl [-bdn] variable ...",
- " sysctl [-bn] -w variable=value ...",
- " sysctl [-bdn] -a",
- " sysctl [-bdn] -A",
- " sysctl [-bdn] -X");
+ (void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
+ "usage: sysctl [-bnX] variable ...",
+ " sysctl [-bnX] -w variable=value ...",
+ " sysctl [-bnX] -a",
+ " sysctl [-bnX] -A");
exit(1);
}
@@ -86,12 +85,11 @@ main(int argc, char **argv)
setbuf(stdout,0);
setbuf(stderr,0);
- while ((ch = getopt(argc, argv, "AabdnwX")) != -1) {
+ while ((ch = getopt(argc, argv, "AabnwX")) != -1) {
switch (ch) {
case 'A': Aflag = 1; break;
case 'a': aflag = 1; break;
case 'b': bflag = 1; break;
- case 'd': dflag = 1; break;
case 'n': nflag = 1; break;
case 'w': wflag = 1; break;
case 'X': Xflag = Aflag = 1; break;
@@ -101,8 +99,6 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (wflag && (Aflag || aflag || dflag))
- usage();
if (Aflag || aflag)
exit (sysctl_all(0, 0));
if (argc == 0)
@@ -340,34 +336,13 @@ static int
show_var(int *oid, int nlen)
{
u_char buf[BUFSIZ], *val, *p;
- char name[BUFSIZ], descr[BUFSIZ], *fmt;
+ char name[BUFSIZ], *fmt;
int qoid[CTL_MAXNAME+2];
int i;
size_t j, len;
u_int kind;
int (*func)(int, void *) = 0;
- qoid[0] = 0;
- memcpy(qoid + 2, oid, nlen * sizeof(int));
-
- qoid[1] = 1;
- j = sizeof name;
- i = sysctl(qoid, nlen + 2, name, &j, 0, 0);
- if (i || !j)
- err(1, "sysctl name %d %d %d", i, j, errno);
-
- if (dflag) {
- qoid[1] = 5;
- j = sizeof descr;
- i = sysctl(qoid, nlen + 2, descr, &j, 0, 0);
- if (i || !j)
- err(1, "sysctl name %d %d %d", i, j, errno);
- if (!nflag)
- printf("%s: ", name);
- printf("%s", descr[0] ? descr : "[no description]");
- return (0);
- }
-
/* find an estimate of how much we need for this var */
j = 0;
i = sysctl(oid, nlen, 0, &j, 0, 0);
@@ -384,7 +359,10 @@ show_var(int *oid, int nlen)
return (0);
}
+ qoid[0] = 0;
qoid[1] = 4;
+ memcpy(qoid + 2, oid, nlen * sizeof(int));
+
j = sizeof buf;
i = sysctl(qoid, nlen + 2, buf, &j, 0, 0);
if (i || !j)
@@ -394,6 +372,12 @@ show_var(int *oid, int nlen)
fmt = (char *)(buf + sizeof(u_int));
+ qoid[1] = 1;
+ j = sizeof name;
+ i = sysctl(qoid, nlen + 2, name, &j, 0, 0);
+ if (i || !j)
+ err(1, "sysctl name %d %d %d", i, j, errno);
+
p = val;
switch (*fmt) {
case 'A':
@@ -405,13 +389,7 @@ show_var(int *oid, int nlen)
case 'I':
if (!nflag)
printf("%s: ", name);
- val = "";
- while (len >= sizeof(int)) {
- printf("%s%d", val, *(int *)p);
- val = " ";
- len -= sizeof (int);
- p += sizeof (int);
- }
+ printf("%d", *(int *)p);
return (0);
case 'L':
diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5
index a2ddf5fe85b2..4b07d75e7c9f 100644
--- a/usr.sbin/syslogd/syslog.conf.5
+++ b/usr.sbin/syslogd/syslog.conf.5
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93
-.\" $Id: syslog.conf.5,v 1.11 1998/07/22 06:15:16 phk Exp $
+.\" $Id: syslog.conf.5,v 1.10 1998/06/10 04:34:54 julian Exp $
.\"
.Dd June 9, 1993
.Dt SYSLOG.CONF 5
@@ -62,19 +62,7 @@ The
.Em selector
field is separated from the
.Em action
-field by one or more tab characters or spaces.
-.Pp
-Note that if you use spaces as separators, your
-.Em syslog.conf
-might be incompatible with other Unices or Unix-like systems.
-This functionality was added for the ease of configuration
-(e.g. it is possible to cut-and-paste into
-.Em syslog.conf
-),
-and to avoid possible mistakes. This change however preserves
-backwards compatibility with the old style of the
-.Em syslog.conf
-(i.e. tab characters only).
+field by one or more tab characters.
.Pp
The
.Em Selectors
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 523de1af5a67..5c0ffd524e32 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
#endif
static const char rcsid[] =
- "$Id: syslogd.c,v 1.45 1998/12/29 20:36:22 cwt Exp $";
+ "$Id: syslogd.c,v 1.40 1998/07/27 13:04:14 phk Exp $";
#endif /* not lint */
/*
@@ -491,8 +491,7 @@ main(argc, argv)
Vogons++;
if (!(Vogons & (Vogons - 1))) {
(void)snprintf(line, sizeof line,
-"syslogd: discarded %d unwanted packets in secure mode, last from %s", Vogons,
- inet_ntoa(frominet.sin_addr));
+"syslogd: discarded %d unwanted packets in secure mode", Vogons);
logmsg(LOG_SYSLOG|LOG_AUTH, line,
LocalHostName, ADDDATE);
}
@@ -741,8 +740,7 @@ logmsg(pri, msg, from, flags)
f->f_prevpri = pri;
(void)strncpy(f->f_lasttime, timestamp, 15);
(void)strncpy(f->f_prevhost, from,
- sizeof(f->f_prevhost)-1);
- f->f_prevhost[sizeof(f->f_prevhost)-1] = '\0';
+ sizeof(f->f_prevhost));
if (msglen < MAXSVLINE) {
f->f_prevlen = msglen;
(void)strcpy(f->f_prevline, msg);
@@ -1067,7 +1065,6 @@ cvthname(f)
struct sockaddr_in *f;
{
struct hostent *hp;
- sigset_t omask, nmask;
char *p;
dprintf("cvthname(%s)\n", inet_ntoa(f->sin_addr));
@@ -1076,12 +1073,8 @@ cvthname(f)
dprintf("Malformed from address\n");
return ("???");
}
- sigemptyset(&nmask);
- sigaddset(&nmask, SIGHUP);
- sigprocmask(SIG_BLOCK, &nmask, &omask);
hp = gethostbyaddr((char *)&f->sin_addr,
sizeof(struct in_addr), f->sin_family);
- sigprocmask(SIG_SETMASK, &omask, NULL);
if (hp == 0) {
dprintf("Host name for your address (%s) unknown\n",
inet_ntoa(f->sin_addr));
@@ -1271,7 +1264,7 @@ init(signo)
if(*p=='!') {
p++;
while(isspace(*p)) p++;
- if((!*p) || (*p == '*')) {
+ if(!*p) {
strcpy(prog, "*");
continue;
}
@@ -1372,12 +1365,12 @@ cfline(line, f, prog)
}
/* scan through the list of selectors */
- for (p = line; *p && *p != '\t' && *p != ' ';) {
+ for (p = line; *p && *p != '\t';) {
int pri_done;
int pri_cmp;
/* find the end of this facility name list */
- for (q = p; *q && *q != '\t' && *q != ' ' && *q++ != '.'; )
+ for (q = p; *q && *q != '\t' && *q++ != '.'; )
continue;
/* get the priority comparison */
@@ -1409,12 +1402,12 @@ cfline(line, f, prog)
;
/* collect priority name */
- for (bp = buf; *q && !strchr("\t,; ", *q); )
+ for (bp = buf; *q && !strchr("\t,;", *q); )
*bp++ = *q++;
*bp = '\0';
/* skip cruft */
- while (strchr(",;", *q))
+ while (strchr(", ;", *q))
q++;
/* decode priority name */
@@ -1431,8 +1424,8 @@ cfline(line, f, prog)
}
/* scan facilities */
- while (*p && !strchr("\t.; ", *p)) {
- for (bp = buf; *p && !strchr("\t,;. ", *p); )
+ while (*p && !strchr("\t.;", *p)) {
+ for (bp = buf; *p && !strchr("\t,;.", *p); )
*bp++ = *p++;
*bp = '\0';
@@ -1461,16 +1454,14 @@ cfline(line, f, prog)
}
/* skip to action part */
- while (*p == '\t' || *p == ' ')
+ while (*p == '\t')
p++;
switch (*p)
{
case '@':
- (void)strncpy(f->f_un.f_forw.f_hname, ++p,
- sizeof(f->f_un.f_forw.f_hname)-1);
- f->f_un.f_forw.f_hname[sizeof(f->f_un.f_forw.f_hname)-1] = '\0';
- hp = gethostbyname(f->f_un.f_forw.f_hname);
+ (void)strcpy(f->f_un.f_forw.f_hname, ++p);
+ hp = gethostbyname(p);
if (hp == NULL) {
extern int h_errno;
diff --git a/usr.sbin/tcpdump/tcpslice/tcpslice.c b/usr.sbin/tcpdump/tcpslice/tcpslice.c
index a1ff54e36949..904d9b7f2ded 100644
--- a/usr.sbin/tcpdump/tcpslice/tcpslice.c
+++ b/usr.sbin/tcpdump/tcpslice/tcpslice.c
@@ -27,7 +27,7 @@ static const char copyright[] =
#ifndef lint
static const char rcsid[] =
- "$Id: tcpslice.c,v 1.7 1999/01/15 07:37:00 imp Exp $";
+ "$Id$";
#endif /* not lint */
/*
@@ -356,12 +356,8 @@ fill_tm(char *time_string, int is_delta, struct tm *t, time_t *usecs_addr)
switch (format_ch) {
case 'y':
- if ( val >= 1900 )
+ if ( val > 1900 )
val -= 1900;
- else if (val < 100 && !is_delta) {
- if (val < 69) /* Same hack as date */
- val += 100;
- }
SET_VAL(t->tm_year, val);
break;
@@ -567,7 +563,7 @@ timestamp_to_string(struct timeval *timestamp)
switch ( timestamp_style )
{
case TIMESTAMP_RAW:
- sprintf(buf, "%lu.%06lu", timestamp->tv_sec, timestamp->tv_usec);
+ sprintf(buf, "%ld.%ld", timestamp->tv_sec, timestamp->tv_usec);
break;
case TIMESTAMP_READABLE:
@@ -578,8 +574,6 @@ timestamp_to_string(struct timeval *timestamp)
case TIMESTAMP_PARSEABLE:
t = localtime((time_t *) &timestamp->tv_sec);
- if (t->tm_year >= 100)
- t->tm_year += 1900;
sprintf( buf, "%02dy%02dm%02dd%02dh%02dm%02ds%06ldu",
t->tm_year, t->tm_mon + 1, t->tm_mday, t->tm_hour,
t->tm_min, t->tm_sec, timestamp->tv_usec );
diff --git a/usr.sbin/traceroute/Makefile b/usr.sbin/traceroute/Makefile
index e0d97249119e..3c799d892224 100644
--- a/usr.sbin/traceroute/Makefile
+++ b/usr.sbin/traceroute/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.9 1998/09/19 22:42:13 obrien Exp $
+# $Id: Makefile,v 1.8 1998/06/09 05:36:48 imp Exp $
PROG= traceroute
MAN8= traceroute.8
@@ -14,12 +14,6 @@ SRCS= version.c traceroute.c
CLEANFILES+= version.c
TRACEROUTE_DISTDIR?= ${.CURDIR}/../../contrib/traceroute
-
-.if ${MACHINE_ARCH} == "alpha"
-# gcc builtin memcpy causes unaligned access
-CFLAGS+= -fno-builtin
-.endif
-
CFLAGS+= -I${TRACEROUTE_DISTDIR}/lbl
.PATH: ${TRACEROUTE_DISTDIR}
diff --git a/usr.sbin/tzsetup/paths.h b/usr.sbin/tzsetup/paths.h
index 4754e9ad9e98..10a6812ad034 100644
--- a/usr.sbin/tzsetup/paths.h
+++ b/usr.sbin/tzsetup/paths.h
@@ -2,4 +2,3 @@
#define _PATH_ISO3166 "/usr/share/misc/iso3166"
#define _PATH_ZONEINFO "/usr/share/zoneinfo"
#define _PATH_LOCALTIME "/etc/localtime"
-#define _PATH_WALL_CMOS_CLOCK "/etc/wall_cmos_clock"
diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c
index 42522b6dde8c..8f3f34c2cd08 100644
--- a/usr.sbin/tzsetup/tzsetup.c
+++ b/usr.sbin/tzsetup/tzsetup.c
@@ -34,7 +34,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: tzsetup.c,v 1.10 1998/01/10 15:55:11 steve Exp $";
+ "$Id: tzsetup.c,v 1.9 1997/11/07 00:07:27 joerg Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -631,7 +631,7 @@ usage()
int
main(int argc, char **argv)
{
- int c, fd;
+ int c;
while ((c = getopt(argc, argv, "n")) != -1) {
switch(c) {
@@ -657,15 +657,10 @@ main(int argc, char **argv)
"Is this machine's CMOS clock set to UTC? If it is set to local time,\n"
"please choose NO here!", 7, 72)) {
if (reallydoit)
- unlink(_PATH_WALL_CMOS_CLOCK);
+ system("rm -f /etc/wall_cmos_clock");
} else {
- if (reallydoit) {
- fd = open(_PATH_WALL_CMOS_CLOCK,
- O_WRONLY|O_CREAT|O_TRUNC, 0666);
- if (fd < 0)
- err(1, "create %s", _PATH_WALL_CMOS_CLOCK);
- close(fd);
- }
+ if (reallydoit)
+ system("touch /etc/wall_cmos_clock");
}
dialog_clear_norefresh();
dialog_menu("Time Zone Selector", "Select a region", -1, -1,
diff --git a/usr.sbin/usbd/Makefile b/usr.sbin/usbd/Makefile
deleted file mode 100644
index 526ab61deb3e..000000000000
--- a/usr.sbin/usbd/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $Id$
-
-PROG= usbd
-MAN8= usbd.8
-CFLAGS+=-I${.CURDIR}/../../sys
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/usbd/usbd.8 b/usr.sbin/usbd/usbd.8
deleted file mode 100644
index 41e96aee3f4d..000000000000
--- a/usr.sbin/usbd/usbd.8
+++ /dev/null
@@ -1,81 +0,0 @@
-.\" $NetBSD: usbd.8,v 1.2 1998/07/13 11:01:50 augustss Exp $
-.\" FreeBSD $Id$
-.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
-.\" All rights reserved.
-.\"
-.\" Author: Lennart Augustsson
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the NetBSD
-.\" Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
-.\" contributors may be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-.\" POSSIBILITY OF SUCH DAMAGE.
-.\"
-.Dd July 12, 1998
-.Dt USBD 8
-.Os
-.Sh NAME
-.Nm usbd
-.Nd supervise USB attach/detach
-.Sh SYNOPSIS
-.Nm
-.Op Fl d
-.Op Fl f Ar device
-.Op Fl t Ar timeout
-.Op Fl v
-.Sh DESCRIPTION
-.Nm
-handles the USB device attachment and detachment.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl d
-Enable debugging to the standard output,
-and do not disassociate from the controlling terminal.
-.It Fl e
-Do one device tree exploration and then exit.
-.It Fl f Ar device
-Specify the pathname of a USB controller device file.
-The flag may be repeated to watch more than one USB controller.
-The default is
-.Pa /dev/usb0 ,
-.Pa /dev/usb1 ,
-.Pa /dev/usb2 ,
-and
-.Pa /dev/usb3 .
-.It Fl t Ar timeout
-Set the timeout interval (in seconds) before an exploration happens
-without being triggered by a connect or disconnect.
-A timeout of 0 means that there is no timeout. The default is 30.
-.It Fl v
-Be verbose.
-.El
-.Sh SEE ALSO
-.Xr usb 4
-.Sh HISTORY
-The
-.Nm
-command appeared in
-.Nx 1.4 .
diff --git a/usr.sbin/usbd/usbd.c b/usr.sbin/usbd/usbd.c
deleted file mode 100644
index bde1cc6281f3..000000000000
--- a/usr.sbin/usbd/usbd.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* $NetBSD: usbd.c,v 1.2 1998/07/23 18:39:53 augustss Exp $ */
-/* FreeBSD $Id$ */
-
-/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * Author: Lennart Augustsson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/time.h>
-#if defined(__FreeBSD__)
-#include <sys/ioctl.h>
-#include <sys/malloc.h>
-#endif
-#include <dev/usb/usb.h>
-
-#define USBDEV "/dev/usb"
-#define MAXUSBDEV 4
-
-extern char *__progname;
-
-void usage(void);
-
-void
-usage(void)
-{
- fprintf(stderr, "Usage: %s [-d] [-e] [-f dev] [-t timeout] [-v]\n",
- __progname);
- exit(1);
-}
-
-#define NDEVS 20 /* maximum number of usb controllers */
-
-/*
- * Sometimes a device does not respond in time for interrupt
- * driven explore to find it. Therefore we run an exploration
- * at regular intervals to catch those.
- */
-#define TIMEOUT 30
-
-int
-main(int argc, char **argv)
-{
- int r, i;
- char *devs[NDEVS];
- int ndevs = 0;
- int fds[NDEVS];
- fd_set fdset;
- int ch, verbose = 0;
- int debug = 0;
- int explore = 0;
- int itimo = TIMEOUT;
- int maxfd;
- char buf[50];
- struct timeval timo;
- extern char *optarg;
- extern int optind;
-
- while ((ch = getopt(argc, argv, "def:t:v")) != -1) {
- switch(ch) {
- case 'd':
- debug++;
- break;
- case 'e':
- explore++;
- break;
- case 'f':
- if (ndevs < NDEVS)
- devs[ndevs++] = optarg;
- break;
- case 't':
- itimo = atoi(optarg);
- break;
- case 'v':
- verbose++;
- break;
- case '?':
- default:
- usage();
- }
- }
- argc -= optind;
- argv += optind;
-
- maxfd = 0;
- if (ndevs == 0) {
- for (i = 0; i < MAXUSBDEV; i++) {
- sprintf(buf, "%s%d", USBDEV, i);
- fds[ndevs] = open(buf, O_RDWR);
- if (fds[ndevs] >= 0) {
- devs[ndevs] = strdup(buf);
- if (verbose)
- printf("%s: opening %s\n",
- __progname, devs[ndevs]);
- if (fds[ndevs] > maxfd)
- maxfd = fds[ndevs];
- ndevs++;
- }
- }
- } else {
- for (i = 0; i < ndevs; i++) {
- fds[i] = open(devs[i], O_RDWR);
- if (fds[i] < 0)
- err(1, "%s", devs[i]);
- else if (fds[i] > maxfd)
- maxfd = fds[i];
- }
- }
- if (ndevs == 0) {
- if (verbose)
- printf("%s: no USB controllers found\n", __progname);
- exit(0);
- }
-
- if (explore) {
- for (i = 0; i < ndevs; i++) {
- r = ioctl(fds[i], USB_DISCOVER);
- if (r < 0)
- err(1, "USB_DISCOVER");
- }
- exit(0);
- }
-
- if (!debug)
- daemon(0, 0);
-
-
-
- FD_ZERO(&fdset);
- for (;;) {
- for (i = 0; i < ndevs; i++)
- FD_SET(fds[i], &fdset);
- timo.tv_usec = 0;
- timo.tv_sec = itimo;
- r = select(maxfd+1, &fdset, &fdset, 0, itimo ? &timo : 0);
- if (r < 0)
- warn("select failed\n");
- for (i = 0; i < ndevs; i++)
- if (r == 0 || FD_ISSET(fds[i], &fdset)) {
- if (verbose)
- printf("%s: doing %sdiscovery on %s\n",
- __progname, r ? "" : "timeout ",
- devs[i]);
- if (ioctl(fds[i], USB_DISCOVER) < 0)
- err(1, "USB_DISCOVER");
- }
- }
-}
diff --git a/usr.sbin/usbdevs/Makefile b/usr.sbin/usbdevs/Makefile
deleted file mode 100644
index 0393156cf9fb..000000000000
--- a/usr.sbin/usbdevs/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $NetBSD: Makefile,v 1.2 1998/07/12 20:40:45 augustss Exp $
-# FreeBSD $Id: Makefile,v 1.2 1998/12/13 15:52:26 bde Exp $
-
-PROG= usbdevs
-MAN8= usbdevs.8
-CFLAGS+=-I${.CURDIR}/../../sys
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/usbdevs/usbdevs.8 b/usr.sbin/usbdevs/usbdevs.8
deleted file mode 100644
index 46ed36e21117..000000000000
--- a/usr.sbin/usbdevs/usbdevs.8
+++ /dev/null
@@ -1,68 +0,0 @@
-.\" $NetBSD: usbdevs.8,v 1.3 1998/07/23 13:57:51 augustss Exp $
-.\" FreeBSD $Id$
-.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
-.\" All rights reserved.
-.\"
-.\" Author: Lennart Augustsson
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the NetBSD
-.\" Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
-.\" contributors may be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-.\" POSSIBILITY OF SUCH DAMAGE.
-.\"
-.Dd July 12, 1998
-.Dt USBDEVS 8
-.Os
-.Sh NAME
-.Nm usbdevs
-.Nd show USB devices connected to the system
-.Sh SYNOPSIS
-.Nm
-.Op Fl a Ar addr
-.Op Fl f Ar dev
-.Op Fl v
-.Sh DESCRIPTION
-.Nm
-prints a listing of all USB devices connected to the system
-with some information about each device.
-The indentation of each line indicates its distance from the root.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl a Ar addr
-only print information about the device at the given address.
-.It Fl f Ar dev
-only print information for the given USB controller.
-.It Fl v
-Be verbose.
-.El
-.Sh SEE ALSO
-.Xr usb 4
-.Sh HISTORY
-The
-.Nm
-command appeared in
-.Nx 1.4 .
diff --git a/usr.sbin/usbdevs/usbdevs.c b/usr.sbin/usbdevs/usbdevs.c
deleted file mode 100644
index 171c908d4a1c..000000000000
--- a/usr.sbin/usbdevs/usbdevs.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* $NetBSD: usbdevs.c,v 1.4 1998/07/23 13:57:51 augustss Exp $ */
-/* FreeBSD $Id$ */
-
-/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * Author: Lennart Augustsson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <err.h>
-#include <errno.h>
-#include <dev/usb/usb.h>
-#if defined(__FreeBSD__)
-#include <sys/ioctl.h>
-#endif
-
-#define USBDEV "/dev/usb"
-
-int verbose;
-
-void usage __P((void));
-void usbdev __P((int f, int a, int rec));
-void usbdump __P((int f));
-void dumpone __P((char *name, int f, int addr));
-int main __P((int, char **));
-
-extern char *__progname;
-
-void
-usage()
-{
- fprintf(stderr, "Usage: %s [-a addr] [-f dev] [-v]\n", __progname);
- exit(1);
-}
-
-char done[USB_MAX_DEVICES];
-int indent;
-
-void
-usbdev(f, a, rec)
- int f;
- int a;
- int rec;
-{
- struct usb_device_info di;
- int e, p;
-
- di.addr = a;
- e = ioctl(f, USB_DEVICEINFO, &di);
- if (e)
- return;
- done[a] = 1;
- printf("addr %d: ", di.addr);
- if (verbose) {
- if (di.lowspeed)
- printf("low speed, ");
- if (di.power)
- printf("power %d mA, ", di.power);
- else
- printf("self powered, ");
- if (di.config)
- printf("config %d, ", di.config);
- else
- printf("unconfigured, ");
- }
- printf("%s, %s", di.product, di.vendor);
- if (verbose)
- printf(", rev %s", di.revision);
- printf("\n");
- if (!rec)
- return;
- for (p = 0; p < di.nports; p++) {
- int s = di.ports[p];
- if (s >= USB_MAX_DEVICES) {
- if (verbose) {
- printf("%*sport %d %s\n", indent+1, "", p+1,
- s == USB_PORT_ENABLED ? "enabled" :
- s == USB_PORT_SUSPENDED ? "suspended" :
- s == USB_PORT_POWERED ? "powered" :
- s == USB_PORT_DISABLED ? "disabled" :
- "???");
-
- }
- continue;
- }
- indent++;
- printf("%*s", indent, "");
- if (verbose)
- printf("port %d ", p+1);
- usbdev(f, di.ports[p], 1);
- indent--;
- }
-}
-
-void
-usbdump(f)
- int f;
-{
- int a;
-
- for (a = 1; a < USB_MAX_DEVICES; a++) {
- if (!done[a])
- usbdev(f, a, 1);
- }
-}
-
-void
-dumpone(name, f, addr)
- char *name;
- int f;
- int addr;
-{
- if (verbose)
- printf("Controller %s:\n", name);
- indent = 0;
- memset(done, 0, sizeof done);
- if (addr)
- usbdev(f, addr, 0);
- else
- usbdump(f);
-}
-
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- int ch, i, f;
- char buf[50];
- extern int optind;
- extern char *optarg;
- char *dev = 0;
- int addr = 0;
- int ncont;
-
- while ((ch = getopt(argc, argv, "a:f:v")) != -1) {
- switch(ch) {
- case 'a':
- addr = atoi(optarg);
- break;
- case 'f':
- dev = optarg;
- break;
- case 'v':
- verbose = 1;
- break;
- case '?':
- default:
- usage();
- }
- }
- argc -= optind;
- argv += optind;
-
- if (dev == 0) {
- for (ncont = 0, i = 0; i < 10; i++) {
- sprintf(buf, "%s%d", USBDEV, i);
- f = open(buf, O_RDONLY);
- if (f >= 0) {
- ncont++;
- dumpone(buf, f, addr);
- close(f);
- } else {
- if (errno == EACCES)
- warn("%s", buf);
- }
- }
- if (verbose && ncont == 0)
- printf("%s: no USB controllers found\n", __progname);
- } else {
- f = open(dev, O_RDONLY);
- if (f >= 0)
- dumpone(dev, f, addr);
- else
- err(1, "%s", dev);
- }
- exit(0);
-}
diff --git a/usr.sbin/vidcontrol/vidcontrol.c b/usr.sbin/vidcontrol/vidcontrol.c
index 6583d9f305ea..d6a7df8e9a96 100644
--- a/usr.sbin/vidcontrol/vidcontrol.c
+++ b/usr.sbin/vidcontrol/vidcontrol.c
@@ -28,7 +28,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: vidcontrol.c,v 1.25 1999/01/11 03:20:32 yokota Exp $";
+ "$Id: vidcontrol.c,v 1.23 1998/09/24 01:36:36 gpalmer Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -289,7 +289,7 @@ video_mode(int argc, char **argv, int *index)
{ "VESA_800x600", SW_VESA_800x600 },
{ NULL },
};
- unsigned long mode = 0;
+ unsigned long mode;
int size[3];
int i;
@@ -373,7 +373,7 @@ set_console(char *arg)
n = atoi(arg);
if (n < 1 || n > 12) {
warnx("console number out of range");
- } else if (ioctl(0, VT_ACTIVATE, (caddr_t) (long) n) == -1)
+ } else if (ioctl(0,VT_ACTIVATE,(char *)n) == -1)
warn("ioctl(VT_ACTIVATE)");
}
@@ -431,11 +431,7 @@ static char
void
show_adapter_info(void)
{
-#ifdef __i386__
- struct video_adapter_info ad;
-#else
struct video_adapter ad;
-#endif
ad.va_index = 0;
if (ioctl(0, CONS_ADPINFO, &ad)) {
@@ -443,15 +439,11 @@ show_adapter_info(void)
return;
}
- printf("fb%d:\n", ad.va_index);
-#ifdef __i386__
- printf(" %.*s%d, type:%s%s (%d), flags:0x%x\n",
- (int)sizeof(ad.va_name), ad.va_name, ad.va_unit,
-#else
- printf(" type:%s%s (%d), flags:0x%x\n",
-#endif
+ printf("adapter %d:\n", ad.va_index);
+ printf(" type:%s%s (%d), flags:0x%08x, CRTC:0x%x\n",
(ad.va_flags & V_ADP_VESA) ? "VESA " : "",
- adapter_name(ad.va_type), ad.va_type, ad.va_flags);
+ adapter_name(ad.va_type), ad.va_type,
+ ad.va_flags, ad.va_crtc_addr);
printf(" initial mode:%d, current mode:%d, BIOS mode:%d\n",
ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
}
diff --git a/usr.sbin/vipw/pw_util.c b/usr.sbin/vipw/pw_util.c
index 2003cd6ed1ff..d005d1610696 100644
--- a/usr.sbin/vipw/pw_util.c
+++ b/usr.sbin/vipw/pw_util.c
@@ -36,7 +36,7 @@
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
- "$Id: pw_util.c,v 1.12 1998/12/13 01:36:45 dillon Exp $";
+ "$Id: pw_util.c,v 1.9 1997/10/27 07:53:19 charnier Exp $";
#endif /* not lint */
/*
@@ -45,7 +45,6 @@ static const char rcsid[] =
*/
#include <sys/param.h>
-#include <sys/errno.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/stat.h>
@@ -115,27 +114,11 @@ pw_lock()
* that users can't get at the encrypted passwords while editing.
* Open should allow flock'ing the file; see 4.4BSD. XXX
*/
- for (;;) {
- struct stat st;
-
- lockfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0);
- if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1)
- err(1, "%s", _PATH_MASTERPASSWD);
- if (flock(lockfd, LOCK_EX|LOCK_NB))
- errx(1, "the password db file is busy");
-
- /*
- * If the password file was replaced while we were trying to
- * get the lock, our hardlink count will be 0 and we have to
- * close and retry.
- */
- if (fstat(lockfd, &st) < 0)
- errx(1, "fstat() failed");
- if (st.st_nlink != 0)
- break;
- close(lockfd);
- lockfd = -1;
- }
+ lockfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0);
+ if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1)
+ err(1, "%s", _PATH_MASTERPASSWD);
+ if (flock(lockfd, LOCK_EX|LOCK_NB))
+ errx(1, "the password db file is busy");
return (lockfd);
}
@@ -202,18 +185,16 @@ pw_edit(notsetuid)
(void)setgid(getgid());
(void)setuid(getuid());
}
- errno = 0;
execlp(editor, p, tempname, NULL);
- _exit(errno);
+ _exit(1);
}
for (;;) {
editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
- errno = WEXITSTATUS(pstat);
if (editpid == -1)
pw_error(editor, 1, 1);
else if (WIFSTOPPED(pstat))
raise(WSTOPSIG(pstat));
- else if (WIFEXITED(pstat) && errno == 0)
+ else if (WIFEXITED(pstat) && WEXITSTATUS(pstat) == 0)
break;
else
pw_error(editor, 1, 1);
diff --git a/usr.sbin/wlconfig/wlconfig.8 b/usr.sbin/wlconfig/wlconfig.8
index 76c595e40236..21b68a086e23 100644
--- a/usr.sbin/wlconfig/wlconfig.8
+++ b/usr.sbin/wlconfig/wlconfig.8
@@ -57,7 +57,7 @@ In the hardware, NWIDs are stored long-term in non-volative memory
(called the PSA or programmable storage area), and are loaded by
software into the radio modem when the driver is
initialized. This sets the default NWID loaded at startup.
-.It currnwid
+.It curnwid
This sets the current operating NWID (but does not save it to the
PSA).
.It cache
diff --git a/usr.sbin/xntpd/include/ntp_machine.h b/usr.sbin/xntpd/include/ntp_machine.h
index 0d4267c452a6..25de0213b931 100644
--- a/usr.sbin/xntpd/include/ntp_machine.h
+++ b/usr.sbin/xntpd/include/ntp_machine.h
@@ -373,7 +373,6 @@ in this file.
#if defined(SYS_44BSD)
#define HAVE_SIGNALED_IO
#define HAVE_LIBKVM
-#define HAVE_SYSCTL
#define NTP_POSIX_SOURCE
#define HAVE_BSD_NICE
#define USE_PROTOTYPES
diff --git a/usr.sbin/xntpd/parse/util/dcfd.c b/usr.sbin/xntpd/parse/util/dcfd.c
index 0acfa72a1b9d..38980714eb2b 100644
--- a/usr.sbin/xntpd/parse/util/dcfd.c
+++ b/usr.sbin/xntpd/parse/util/dcfd.c
@@ -68,7 +68,7 @@ MUST DEFINE ONE OF "HAVE_TERMIOS" or "HAVE_TERMIO"
#endif
#ifndef dysize
-#define dysize(_x_) (((_x_) % 4) ? 365 : (((_x_) % 100) ? 366 : ((_x_) % 400 ? 365 : 366 )))
+#define dysize(_x_) (((_x_) % 4) ? 365 : (((_x_) % 400) ? 365 : 366))
#endif
#define timernormalize(_a_) \
@@ -761,8 +761,7 @@ dcf_to_unixtime(clock, cvtrtc)
*/
t = (clock->year - 1970) * 365;
t += (clock->year >> 2) - (1970 >> 2);
- t -= clock->year / 100 - 1970 / 100;
- t += clock->year / 400 - 1970 / 400;
+ t -= clock->year / 400 - 1970 / 400;
/* month */
if (clock->month <= 0 || clock->month > 12)
@@ -1588,10 +1587,9 @@ main(argc, argv)
-tt.tv_usec;
/*
- * output interpreted DCF77 data. DCF77 gives us a YY year
- * but dcf_to_unixtime() adds the century, so print YYYY.
+ * output interpreted DCF77 data
*/
- PRINTF(offsets ? "%s, %2d:%02d:%02d, %d.%02d.%4d, <%s%s%s%s> (%c%d.%06ds)" :
+ PRINTF(offsets ? "%s, %2d:%02d:%02d, %d.%02d.%02d, <%s%s%s%s> (%c%d.%06ds)" :
"%s, %2d:%02d:%02d, %d.%02d.%02d, <%s%s%s%s>",
wday[clock.wday],
clock.hour, clock.minute, i, clock.day, clock.month,
diff --git a/usr.sbin/xntpd/parse/util/testdcf.c b/usr.sbin/xntpd/parse/util/testdcf.c
index bd5ea88506d0..219b7c3975b9 100644
--- a/usr.sbin/xntpd/parse/util/testdcf.c
+++ b/usr.sbin/xntpd/parse/util/testdcf.c
@@ -451,9 +451,6 @@ main(argc, argv)
if (rtc == CVT_OK)
{
- /* We are only supplied two digits of the year, by the
- * clock, so we'll just print two digits.
- */
printf("%s, %2d:%02d:%02d, %d.%02d.%02d, <%s%s%s%s>",
wday[clock.wday],
(int)clock.hour, (int)clock.minute, (int)i, (int)clock.day, (int)clock.month,
diff --git a/usr.sbin/xntpd/xntpd/ntp_unixclock.c b/usr.sbin/xntpd/xntpd/ntp_unixclock.c
index 557ce25eddcb..bc771b6b717f 100644
--- a/usr.sbin/xntpd/xntpd/ntp_unixclock.c
+++ b/usr.sbin/xntpd/xntpd/ntp_unixclock.c
@@ -40,12 +40,6 @@
#undef hz
#endif /* RS6000 */
-#ifdef HAVE_SYSCTL
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/time.h>
-#endif
-
extern int debug;
/*
* These routines (init_systime, get_systime, step_systime, adj_systime)
@@ -182,27 +176,6 @@ init_systime()
L_CLR(&sys_clock_offset);
}
-#if defined(HAVE_SYSCTL) && defined(KERN_CLOCKRATE)
-static void
-clock_parms(tickadj, tick)
- u_long *tickadj;
- u_long *tick;
-{
- int mib[2];
- size_t len;
- struct clockinfo x;
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_CLOCKRATE;
- len = sizeof(x);
- if (sysctl(mib, 2, &x, &len, NULL, 0) == -1) {
- syslog(LOG_NOTICE, "sysctl(KERN_CLOCKRATE) failed: %m");
- exit(3);
- }
- *tickadj = x.tickadj;
- *tick = x.tick;
-}
-#else
#ifdef HAVE_LIBKVM
/*
* clock_parms - return the local clock tickadj and tick parameters
@@ -631,4 +604,3 @@ clock_parms(tickadj, tick)
*tick = (u_long)txc.tick;
}
#endif /* SYS_LINUX */
-#endif
diff --git a/usr.sbin/xntpd/xntpd/refclock_acts.c b/usr.sbin/xntpd/xntpd/refclock_acts.c
index ad3c33a881a6..39ff433719ae 100644
--- a/usr.sbin/xntpd/xntpd/refclock_acts.c
+++ b/usr.sbin/xntpd/xntpd/refclock_acts.c
@@ -291,7 +291,7 @@ extern u_char sys_poll; /* log2 of system poll interval */
extern struct peer *sys_peer; /* system peer structure pointer */
/*
- * Tables to compute the ddd of year from icky dd/mm timecode. Viva la
+ * Tables to compute the ddd of year form icky dd/mm timecode. Viva la
* leap.
*/
static day1tab[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
@@ -581,7 +581,7 @@ acts_receive(rbufp)
(void)write(pp->io.fd, &flag, 1);
/*
- * Yes, I know this code incorrectly thinks that 2100 is a leap
+ * Yes, I know this code incorrectly thinks that 2000 is a leap
* year. The ACTS timecode format croaks then anyway. Life is
* short. Would only the timecode mavens resist the urge to
* express months of the year and days of the month in favor of
diff --git a/usr.sbin/xntpd/xntpd/refclock_heath.c b/usr.sbin/xntpd/xntpd/refclock_heath.c
index 6f2899d153c0..a1b602cf96f5 100644
--- a/usr.sbin/xntpd/xntpd/refclock_heath.c
+++ b/usr.sbin/xntpd/xntpd/refclock_heath.c
@@ -297,7 +297,7 @@ heath_receive(rbufp)
* be avoided if the engineers had been required to write a
* device driver before finalizing the timecode format.
*
- * Yes, I know this code incorrectly thinks that 2100 is a leap
+ * Yes, I know this code incorrectly thinks that 2000 is a leap
* year; but, the latest year that can be set by the DIPswitches
* is 1997 anyay. Life is short.
*/
diff --git a/usr.sbin/xten/README b/usr.sbin/xten/README
index 1ea5ddd34bfa..7ff07faefcd7 100644
--- a/usr.sbin/xten/README
+++ b/usr.sbin/xten/README
@@ -89,7 +89,7 @@ connect to your parallel port.
Add a line like the following
- device tw0 at isa? port 0x278 tty irq 5
+ device tw0 at isa? port 0x278 tty irq 5 vector twintr
to /sys/i386/conf/YOURSYSTEM, but make sure to change the I/O port and
interrupt to match your hardware configuration.
@@ -274,8 +274,8 @@ x-10 devices fail to work when plugged in NEXT to a surge protector!
I placed the tw option before the lpt entries in my config file:
-device tw0 at isa? port 0x378 tty irq 7
-device lpt0 at isa? port? tty irq 7
+device tw0 at isa? port 0x378 tty irq 7 vector twintr
+device lpt0 at isa? port? tty irq 7 vector lptintr
from dmesg I get: