Compare commits

...
Author SHA1 Message Date
cvs2svn e5eb97b547 This commit was manufactured by cvs2svn to create tag
'RELENG_3_3_0_RELEASE'.
1999-09-16 08:26:13 +00:00
63 changed files with 3 additions and 21276 deletions

No files matched your search

-106
View File
@@ -1,106 +0,0 @@
1999-07-03 Assar Westerlund <[email protected]>
* parse.y (statement): use asprintf
1999-06-13 Assar Westerlund <[email protected]>
* Makefile.in: make it solaris make vpath-safe
Thu Apr 1 11:13:53 1999 Johan Danielsson <[email protected]>
* compile_et.c: use getargs
Sat Mar 20 00:16:30 1999 Assar Westerlund <[email protected]>
* compile_et.c: static-ize
Thu Mar 18 11:22:13 1999 Johan Danielsson <[email protected]>
* Makefile.am: include Makefile.am.common
Tue Mar 16 22:30:05 1999 Assar Westerlund <[email protected]>
* parse.y: use YYACCEPT instead of return
Sat Mar 13 22:22:56 1999 Assar Westerlund <[email protected]>
* compile_et.c (generate_h): cast when calling is* to get rid of a
warning
Thu Mar 11 15:00:51 1999 Johan Danielsson <[email protected]>
* parse.y: prototype for error_message
Sun Nov 22 10:39:02 1998 Assar Westerlund <[email protected]>
* compile_et.h: include ctype and roken
* compile_et.c: include err.h
(generate_h): remove unused variable
* Makefile.in (WFLAGS): set
Fri Nov 20 06:58:59 1998 Assar Westerlund <[email protected]>
* lex.l: undef ECHO to work around AIX lex bug
Sun Sep 27 02:23:59 1998 Johan Danielsson <[email protected]>
* com_err.c (error_message): try to pass code to strerror, to see
if it might be an errno code (this if broken, but some MIT code
seems to expect this behaviour)
Sat Sep 26 17:42:39 1998 Johan Danielsson <[email protected]>
* compile_et.c: <foo_err.h> -> "foo_err.h"
Tue Jun 30 17:17:36 1998 Assar Westerlund <[email protected]>
* Makefile.in: add str{cpy,cat}_truncate
Mon May 25 05:24:39 1998 Assar Westerlund <[email protected]>
* Makefile.in (clean): try to remove shared library debris
Sun Apr 19 09:50:17 1998 Assar Westerlund <[email protected]>
* Makefile.in: add symlink magic for linux
Sun Apr 5 09:22:11 1998 Assar Westerlund <[email protected]>
* parse.y: define alloca to malloc in case we're using bison but
don't have alloca
Tue Mar 24 05:13:01 1998 Assar Westerlund <[email protected]>
* Makefile.in: link with snprintf (From Derrick J Brashear
<[email protected]>)
Fri Feb 27 05:01:42 1998 Assar Westerlund <[email protected]>
* parse.y: initialize ec->next
Thu Feb 26 02:22:25 1998 Assar Westerlund <[email protected]>
* Makefile.am: @LEXLIB@
Sat Feb 21 15:18:54 1998 assar westerlund <[email protected]>
* Makefile.in: set YACC and LEX
Tue Feb 17 22:20:27 1998 Bjoern Groenvall <[email protected]>
* com_right.h: Change typedefs so that one may mix MIT compile_et
generated code with krb4 dito.
Tue Feb 17 16:30:55 1998 Johan Danielsson <[email protected]>
* compile_et.c (generate): Always return a value.
* parse.y: Files don't have to end with `end'.
Mon Feb 16 16:09:20 1998 Johan Danielsson <[email protected]>
* lex.l (getstring): Replace getc() with input().
* Makefile.am: Fixes for new compile_et.
-24
View File
@@ -1,24 +0,0 @@
# $Id: Makefile.am,v 1.23 1999/04/09 18:26:55 assar Exp $
include $(top_srcdir)/Makefile.am.common
YFLAGS = -d
lib_LTLIBRARIES = libcom_err.la
libcom_err_la_LDFLAGS = -version-info 1:0:0
bin_PROGRAMS = compile_et
include_HEADERS = com_err.h com_right.h
compile_et_SOURCES = compile_et.c compile_et.h parse.y lex.l
libcom_err_la_SOURCES = error.c com_err.c roken_rename.h
CLEANFILES = lex.c parse.c parse.h
$(compile_et_OBJECTS): parse.h
compile_et_LDADD = \
$(LIB_roken) \
$(LEXLIB)
-710
View File
@@ -1,710 +0,0 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# $Id: Makefile.am,v 1.23 1999/04/09 18:26:55 assar Exp $
# $Id: Makefile.am.common,v 1.3 1999/04/01 14:58:43 joda Exp $
# $Id: Makefile.am.common,v 1.12 1999/07/28 00:54:29 assar Exp $
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AFS_EXTRA_LD = @AFS_EXTRA_LD@
AIX_EXTRA_KAFS = @AIX_EXTRA_KAFS@
AWK = @AWK@
CANONICAL_HOST = @CANONICAL_HOST@
CATMAN = @CATMAN@
CATMANEXT = @CATMANEXT@
CC = @CC@
DBLIB = @DBLIB@
EXEEXT = @EXEEXT@
EXTRA_LIB45 = @EXTRA_LIB45@
GROFF = @GROFF@
INCLUDE_ = @INCLUDE_@
LD = @LD@
LEX = @LEX@
LIBOBJS = @LIBOBJS@
LIBTOOL = @LIBTOOL@
LIB_ = @LIB_@
LIB_AUTH_SUBDIRS = @LIB_AUTH_SUBDIRS@
LIB_kdb = @LIB_kdb@
LIB_otp = @LIB_otp@
LIB_roken = @LIB_roken@
LIB_security = @LIB_security@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MAKE_X_PROGS_BIN_PROGS = @MAKE_X_PROGS_BIN_PROGS@
MAKE_X_PROGS_BIN_SCRPTS = @MAKE_X_PROGS_BIN_SCRPTS@
MAKE_X_PROGS_LIBEXEC_PROGS = @MAKE_X_PROGS_LIBEXEC_PROGS@
NEED_WRITEAUTH_FALSE = @NEED_WRITEAUTH_FALSE@
NEED_WRITEAUTH_TRUE = @NEED_WRITEAUTH_TRUE@
NM = @NM@
NROFF = @NROFF@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
VOID_RETSIGTYPE = @VOID_RETSIGTYPE@
WFLAGS = @WFLAGS@
WFLAGS_NOIMPLICITINT = @WFLAGS_NOIMPLICITINT@
WFLAGS_NOUNUSED = @WFLAGS_NOUNUSED@
YACC = @YACC@
AUTOMAKE_OPTIONS = foreign no-dependencies
SUFFIXES = .et .h .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .x
INCLUDES = -I$(top_builddir)/include
AM_CFLAGS = $(WFLAGS)
COMPILE_ET = $(top_builddir)/lib/com_err/compile_et
buildinclude = $(top_builddir)/include
LIB_XauReadAuth = @LIB_XauReadAuth@
LIB_crypt = @LIB_crypt@
LIB_dbm_firstkey = @LIB_dbm_firstkey@
LIB_dbopen = @LIB_dbopen@
LIB_dlopen = @LIB_dlopen@
LIB_dn_expand = @LIB_dn_expand@
LIB_el_init = @LIB_el_init@
LIB_getattr = @LIB_getattr@
LIB_gethostbyname = @LIB_gethostbyname@
LIB_getpwent_r = @LIB_getpwent_r@
LIB_getpwnam_r = @LIB_getpwnam_r@
LIB_getsockopt = @LIB_getsockopt@
LIB_logout = @LIB_logout@
LIB_logwtmp = @LIB_logwtmp@
LIB_odm_initialize = @LIB_odm_initialize@
LIB_readline = @LIB_readline@
LIB_res_search = @LIB_res_search@
LIB_setpcred = @LIB_setpcred@
LIB_setsockopt = @LIB_setsockopt@
LIB_socket = @LIB_socket@
LIB_syslog = @LIB_syslog@
LIB_tgetent = @LIB_tgetent@
HESIODLIB = @HESIODLIB@
HESIODINCLUDE = @HESIODINCLUDE@
INCLUDE_hesiod = @INCLUDE_hesiod@
LIB_hesiod = @LIB_hesiod@
INCLUDE_krb4 = @INCLUDE_krb4@
LIB_krb4 = @LIB_krb4@
INCLUDE_readline = @INCLUDE_readline@
LEXLIB = @LEXLIB@
cat1dir = $(mandir)/cat1
cat3dir = $(mandir)/cat3
cat5dir = $(mandir)/cat5
cat8dir = $(mandir)/cat8
MANRX = \(.*\)\.\([0-9]\)
CATSUFFIX = @CATSUFFIX@
NROFF_MAN = groff -mandoc -Tascii
@KRB4_TRUE@LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS)
@KRB5_TRUE@LIB_krb5 = $(top_builddir)/lib/krb5/libkrb5.la $(top_builddir)/lib/asn1/libasn1.la
@KRB5_TRUE@LIB_gssapi = $(top_builddir)/lib/gssapi/libgssapi.la
CHECK_LOCAL = $(PROGRAMS)
YFLAGS = -d
lib_LTLIBRARIES = libcom_err.la
libcom_err_la_LDFLAGS = -version-info 1:0:0
bin_PROGRAMS = compile_et
include_HEADERS = com_err.h com_right.h
compile_et_SOURCES = compile_et.c compile_et.h parse.y lex.l
libcom_err_la_SOURCES = error.c com_err.c roken_rename.h
CLEANFILES = lex.c parse.c parse.h
compile_et_LDADD = $(LIB_roken) $(LEXLIB)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../include/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I../../include
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libcom_err_la_LIBADD =
libcom_err_la_OBJECTS = error.lo com_err.lo
bin_PROGRAMS = compile_et$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS)
compile_et_OBJECTS = compile_et.$(OBJEXT) parse.$(OBJEXT) lex.$(OBJEXT)
compile_et_DEPENDENCIES =
compile_et_LDFLAGS =
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(include_HEADERS)
DIST_COMMON = ChangeLog Makefile.am Makefile.in lex.c parse.c
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
SOURCES = $(libcom_err_la_SOURCES) $(compile_et_SOURCES)
OBJECTS = $(libcom_err_la_OBJECTS) $(compile_et_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .1 .3 .5 .8 .S .c .cat1 .cat3 .cat5 .cat8 .et .h .l .lo .o .obj .s .x .y
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common
cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/com_err/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
done
.c.o:
$(COMPILE) -c $<
# FIXME: We should only use cygpath when building on Windows,
# and only if it is available.
.c.obj:
$(COMPILE) -c `cygpath -w $<`
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
-rm -f *.$(OBJEXT)
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
libcom_err.la: $(libcom_err_la_OBJECTS) $(libcom_err_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libcom_err_la_LDFLAGS) $(libcom_err_la_OBJECTS) $(libcom_err_la_LIBADD) $(LIBS)
mostlyclean-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
distclean-binPROGRAMS:
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
compile_et$(EXEEXT): $(compile_et_OBJECTS) $(compile_et_DEPENDENCIES)
@rm -f compile_et$(EXEEXT)
$(LINK) $(compile_et_LDFLAGS) $(compile_et_OBJECTS) $(compile_et_LDADD) $(LIBS)
.l.c:
$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
else :; fi
parse.h: parse.c
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
list='$(include_HEADERS)'; for p in $$list; do \
rm -f $(DESTDIR)$(includedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = lib/com_err
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-local
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES install-binPROGRAMS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
install-exec: install-exec-am
install-data-am: install-includeHEADERS install-data-local
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES uninstall-binPROGRAMS \
uninstall-includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) all-local
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) \
$(DESTDIR)$(includedir)
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
-test -z "lexlparsehparsec" || rm -f lexl parseh parsec
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-binPROGRAMS \
mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool \
clean-binPROGRAMS clean-tags clean-generic \
mostlyclean-am
clean: clean-am
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-binPROGRAMS distclean-tags \
distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-binPROGRAMS maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
mostlyclean-libtool distclean-libtool clean-libtool \
maintainer-clean-libtool mostlyclean-binPROGRAMS distclean-binPROGRAMS \
clean-binPROGRAMS maintainer-clean-binPROGRAMS uninstall-binPROGRAMS \
install-binPROGRAMS uninstall-includeHEADERS install-includeHEADERS \
tags mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
distdir info-am info dvi-am dvi check-local check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-local install-data-am install-data install-am install \
uninstall-am uninstall all-local all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
install-suid-programs:
@foo='$(bin_SUIDS)'; \
for file in $$foo; do \
x=$(DESTDIR)$(bindir)/$$file; \
if chown 0:0 $$x && chmod u+s $$x; then :; else \
chmod 0 $$x; fi; done
install-exec-hook: install-suid-programs
install-build-headers:: $(include_HEADERS) $(build_HEADERZ)
@foo='$(include_HEADERS) $(build_HEADERZ)'; \
for f in $$foo; do \
f=`basename $$f`; \
if test -f "$(srcdir)/$$f"; then file="$(srcdir)/$$f"; \
else file="$$f"; fi; \
if cmp -s $$file $(buildinclude)/$$f 2> /dev/null ; then \
: ; else \
echo " $(INSTALL_DATA) $$file $(buildinclude)/$$f"; \
$(INSTALL_DATA) $$file $(buildinclude)/$$f; \
fi ; \
done
all-local: install-build-headers
#NROFF_MAN = nroff -man
.1.cat1:
$(NROFF_MAN) $< > $@
.3.cat3:
$(NROFF_MAN) $< > $@
.5.cat5:
$(NROFF_MAN) $< > $@
.8.cat8:
$(NROFF_MAN) $< > $@
dist-cat1-mans:
@foo='$(man1_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.1) foo="$$foo $$i";; \
esac; done ;\
for i in $$foo; do \
x=`echo $$i | sed 's/\.[^.]*$$/.cat1/'`; \
echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \
$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \
done
dist-cat3-mans:
@foo='$(man3_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.3) foo="$$foo $$i";; \
esac; done ;\
for i in $$foo; do \
x=`echo $$i | sed 's/\.[^.]*$$/.cat3/'`; \
echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \
$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \
done
dist-cat5-mans:
@foo='$(man5_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.5) foo="$$foo $$i";; \
esac; done ;\
for i in $$foo; do \
x=`echo $$i | sed 's/\.[^.]*$$/.cat5/'`; \
echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \
$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \
done
dist-cat8-mans:
@foo='$(man8_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.8) foo="$$foo $$i";; \
esac; done ;\
for i in $$foo; do \
x=`echo $$i | sed 's/\.[^.]*$$/.cat8/'`; \
echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \
$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \
done
dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat8-mans
install-cat1-mans:
@ext=1;\
foo='$(man1_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.1) foo="$$foo $$i";; \
esac; done; \
if test "$$foo"; then \
$(mkinstalldirs) $(DESTDIR)$(cat1dir); \
for x in $$foo; do \
f=`echo $$x | sed 's/\.[^.]*$$/.cat1/'`; \
if test -f "$(srcdir)/$$f"; then \
b=`echo $$x | sed 's!$(MANRX)!\1!'`; \
echo "$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(cat1dir)/$$b.$(CATSUFFIX)";\
$(INSTALL_DATA) $(srcdir)/$$g $(DESTDIR)$(cat1dir)/$$b.$(CATSUFFIX);\
fi; \
done ;\
fi
install-cat3-mans:
@ext=3;\
foo='$(man3_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.3) foo="$$foo $$i";; \
esac; done; \
if test "$$foo"; then \
$(mkinstalldirs) $(DESTDIR)$(cat3dir); \
for x in $$foo; do \
f=`echo $$x | sed 's/\.[^.]*$$/.cat3/'`; \
if test -f "$(srcdir)/$$f"; then \
b=`echo $$x | sed 's!$(MANRX)!\1!'`; \
echo "$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(cat3dir)/$$b.$(CATSUFFIX)";\
$(INSTALL_DATA) $(srcdir)/$$g $(DESTDIR)$(cat3dir)/$$b.$(CATSUFFIX);\
fi; \
done ;\
fi
install-cat5-mans:
@ext=5;\
foo='$(man5_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.5) foo="$$foo $$i";; \
esac; done; \
if test "$$foo"; then \
$(mkinstalldirs) $(DESTDIR)$(cat5dir); \
for x in $$foo; do \
f=`echo $$x | sed 's/\.[^.]*$$/.cat5/'`; \
if test -f "$(srcdir)/$$f"; then \
b=`echo $$x | sed 's!$(MANRX)!\1!'`; \
echo "$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(cat5dir)/$$b.$(CATSUFFIX)";\
$(INSTALL_DATA) $(srcdir)/$$g $(DESTDIR)$(cat5dir)/$$b.$(CATSUFFIX);\
fi; \
done ;\
fi
install-cat8-mans:
@ext=8;\
foo='$(man8_MANS)'; \
bar='$(man_MANS)'; \
for i in $$bar; do \
case $$i in \
*.8) foo="$$foo $$i";; \
esac; done; \
if test "$$foo"; then \
$(mkinstalldirs) $(DESTDIR)$(cat8dir); \
for x in $$foo; do \
f=`echo $$x | sed 's/\.[^.]*$$/.cat8/'`; \
if test -f "$(srcdir)/$$f"; then \
b=`echo $$x | sed 's!$(MANRX)!\1!'`; \
echo "$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(cat8dir)/$$b.$(CATSUFFIX)";\
$(INSTALL_DATA) $(srcdir)/$$g $(DESTDIR)$(cat8dir)/$$b.$(CATSUFFIX);\
fi; \
done ;\
fi
install-cat-mans: install-cat1-mans install-cat3-mans install-cat5-mans install-cat8-mans
install-data-local: install-cat-mans
.et.h:
$(COMPILE_ET) $<
.et.c:
$(COMPILE_ET) $<
.x.c:
@cmp -s $< $@ 2> /dev/null || cp $< $@
check-local::
@foo='$(CHECK_LOCAL)'; \
if test "$$foo"; then \
failed=0; all=0; \
for i in $$foo; do \
all=`expr $$all + 1`; \
if ./$$i --version > /dev/null 2>&1; then \
echo "PASS: $$i"; \
else \
echo "FAIL: $$i"; \
failed=`expr $$failed + 1`; \
fi; \
done; \
if test "$$failed" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="$$failed of $$all tests failed"; \
fi; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"; \
test "$$failed" -eq 0; \
fi
$(compile_et_OBJECTS): parse.h
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
-96
View File
@@ -1,96 +0,0 @@
.\" Copyright (c) 1988 Massachusetts Institute of Technology,
.\" Student Information Processing Board. All rights reserved.
.\"
.\" $FreeBSD$
.\"
.TH COM_ERR 3 "22 Nov 1988" SIPB
.SH NAME
com_err \- common error display routine
.SH SYNOPSIS
.nf
#include <com_err.h>
.PP
void com_err (whoami, code, format, ...);
const char *whoami;
long code;
const char *format;
.PP
proc = set_com_err_hook (proc);
.fi
void (*
.I proc
) (const char *, long, const char *, va_list);
.nf
.PP
proc = reset_com_err_hook ();
.PP
void initialize_XXXX_error_table ();
.fi
.SH DESCRIPTION
.I Com_err
displays an error message on the standard error stream
.I stderr
(see
.IR stdio (3S))
composed of the
.I whoami
string, which should specify the program name or some subportion of
a program, followed by an error message generated from the
.I code
value (derived from
.IR compile_et (1)),
and a string produced using the
.I format
string and any following arguments, in the same style as
.IR fprintf (3).
The behavior of
.I com_err
can be modified using
.I set_com_err_hook;
this defines a procedure which is called with the arguments passed to
.I com_err,
instead of the default internal procedure which sends the formatted
text to error output. Thus the error messages from a program can all
easily be diverted to another form of diagnostic logging, such as
.IR syslog (3).
.I Reset_com_err_hook
may be used to restore the behavior of
.I com_err
to its default form. Both procedures return the previous ``hook''
value. These ``hook'' procedures must have the declaration given for
.I proc
above in the synopsis.
The
.I initialize_XXXX_error_table
routine is generated mechanically by
.IR compile_et (1)
from a source file containing names and associated strings. Each
table has a name of up to four characters, which is used in place of
the
.B XXXX
in the name of the routine. These routines should be called before
any of the corresponding error codes are used, so that the
.I com_err
library will recognize error codes from these tables when they are
used.
The
.B com_err.h
header file should be included in any source file that uses routines
from the
.I com_err
library; executable files must be linked using
.I ``-lcom_err''
in order to cause the
.I com_err
library to be included.
.\" .IR for manual entries
.\" .PP for paragraph breaks
.SH "SEE ALSO"
compile_et (1), syslog (3).
Ken Raeburn, "A Common Error Description Library for UNIX".
-155
View File
@@ -1,155 +0,0 @@
/*
* Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
RCSID("$Id: com_err.c,v 1.13 1999/03/12 15:17:08 bg Exp $");
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "com_err.h"
struct et_list *_et_list;
const char *
error_message (long code)
{
static char msg[128];
const char *p = com_right(_et_list, code);
if (p == NULL)
p = strerror(code);
if (p != NULL && *p != '\0') {
strncpy(msg, p, sizeof(msg) - 1);
msg[sizeof(msg) - 1] = 0;
} else
sprintf(msg, "Unknown error %ld", code);
return msg;
}
int
init_error_table(const char **msgs, long base, int count)
{
initialize_error_table_r(&_et_list, msgs, count, base);
return 0;
}
static void
default_proc (const char *whoami, long code, const char *fmt, va_list args)
{
if (whoami)
fprintf(stderr, "%s: ", whoami);
if (code)
fprintf(stderr, "%s ", error_message(code));
if (fmt)
vfprintf(stderr, fmt, args);
fprintf(stderr, "\r\n"); /* ??? */
}
static errf com_err_hook = default_proc;
void
com_err_va (const char *whoami,
long code,
const char *fmt,
va_list args)
{
(*com_err_hook) (whoami, code, fmt, args);
}
void
com_err (const char *whoami,
long code,
const char *fmt,
...)
{
va_list ap;
va_start(ap, fmt);
com_err_va (whoami, code, fmt, ap);
va_end(ap);
}
errf
set_com_err_hook (errf new)
{
errf old = com_err_hook;
if (new)
com_err_hook = new;
else
com_err_hook = default_proc;
return old;
}
errf
reset_com_err_hook (void)
{
return set_com_err_hook(NULL);
}
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
static const char char_set[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
static char buf[6];
const char *
error_table_name(int num)
{
int ch;
int i;
char *p;
/* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
p = buf;
num >>= ERRCODE_RANGE;
/* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
num &= 077777777;
/* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
for (i = 4; i >= 0; i--) {
ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
if (ch != 0)
*p++ = char_set[ch-1];
}
*p = '\0';
return(buf);
}
-78
View File
@@ -1,78 +0,0 @@
.\" Copyright (c) 1988 Massachusetts Institute of Technology,
.\" Student Information Processing Board. All rights reserved.
.\"
.\" $FreeBSD$
.\"
.Dd November 22, 1988
.Os
.Dt COMPILE_ET 1
.Sh NAME
.Nm compile_et
.Nd error table compiler
.Sh SYNOPSIS
.Nm compile_et
.Ar file
.Sh DESCRIPTION
.Nm Compile_et
converts a table listing error-code names and associated messages into
a C source file suitable for use with the
.Xr com_err 3
library.
.Pp
The source file name must end with a suffix of ``.et''; the file
consists of a declaration supplying the name (up to four characters
long) of the error-code table:
.Em error_table name
followed by up to 256 entries of the form:
.Em error_code name ,
"
.Em string
"
and a final
.Em end
to indicate the end of the table.
.Pp
The name of the table is used to construct the name of a subroutine
.Em initialize_XXXX_error_table
which must be called in order for the
.Xr com_err 3
library to recognize the error table.
.Pp
The various error codes defined are assigned sequentially increasing
numbers (starting with a large number computed as a hash function of
the name of the table); thus for compatibility it is suggested that
new codes be added only to the end of an existing table, and that no
codes be removed from tables.
.Pp
The names defined in the table are placed into a C header file with
preprocessor directives defining them as integer constants of up to
32 bits in magnitude.
.Pp
A C source file is also generated which should be compiled and linked
with the object files which reference these error codes; it contains
the text of the messages and the initialization subroutine. Both C
files have names derived from that of the original source file, with
the ``.et'' suffix replaced by ``.c'' and ``.h''.
.Pp
A ``#'' in the source file is treated as a comment character, and all
remaining text to the end of the source line will be ignored.
.Sh BUGS
Since
.Nm compile_et
uses a very simple parser based on
.Xr yacc 1 ,
its error recovery leaves much to be desired.
.Sh "SEE ALSO"
.Xr yacc 1 ,
.Xr com_err 3
.Pp
.Rs
.%A Ken Raeburn
.%T "A Common Error Description Library for UNIX"
.Re
-234
View File
@@ -1,234 +0,0 @@
/*
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*/
#undef ROKEN_RENAME
#include "compile_et.h"
#include <getarg.h>
#if 0
RCSID("$Id: compile_et.c,v 1.12 1999/04/01 09:13:52 joda Exp $");
#endif
#include <err.h>
#include "parse.h"
int numerror;
extern FILE *yyin;
extern void yyparse(void);
long base;
int number;
char *prefix;
char *id_str;
char name[128];
char Basename[128];
#ifdef YYDEBUG
extern int yydebug = 1;
#endif
char *filename;
char hfn[128];
char cfn[128];
struct error_code *codes = NULL;
static int
generate_c(void)
{
int n;
struct error_code *ec;
FILE *c_file = fopen(cfn, "w");
if(c_file == NULL)
return 1;
fprintf(c_file, "/* Generated from %s */\n", filename);
if(id_str)
fprintf(c_file, "/* %s */\n", id_str);
fprintf(c_file, "\n");
fprintf(c_file, "#include <stddef.h>\n");
fprintf(c_file, "#include <com_err.h>\n");
fprintf(c_file, "#include \"%s\"\n", hfn);
fprintf(c_file, "\n");
fprintf(c_file, "static const char *text[] = {\n");
for(ec = codes, n = 0; ec; ec = ec->next, n++) {
while(n < ec->number) {
fprintf(c_file, "\t/* %03d */ \"Reserved %s error (%d)\",\n",
n, name, n);
n++;
}
fprintf(c_file, "\t/* %03d */ \"%s\",\n", ec->number, ec->string);
}
fprintf(c_file, "\tNULL\n");
fprintf(c_file, "};\n");
fprintf(c_file, "\n");
fprintf(c_file,
"void initialize_%s_error_table_r(struct et_list **list)\n",
name);
fprintf(c_file, "{\n");
fprintf(c_file,
" initialize_error_table_r(list, text, "
"%s_num_errors, ERROR_TABLE_BASE_%s);\n", name, name);
fprintf(c_file, "}\n");
fprintf(c_file, "\n");
fprintf(c_file, "void initialize_%s_error_table(void)\n", name);
fprintf(c_file, "{\n");
fprintf(c_file,
" init_error_table(text, ERROR_TABLE_BASE_%s, "
"%s_num_errors);\n", name, name);
fprintf(c_file, "}\n");
fclose(c_file);
return 0;
}
static int
generate_h(void)
{
struct error_code *ec;
char fn[128];
FILE *h_file = fopen(hfn, "w");
char *p;
if(h_file == NULL)
return 1;
snprintf(fn, sizeof(fn), "__%s__", hfn);
for(p = fn; *p; p++)
if(!isalnum((unsigned char)*p))
*p = '_';
fprintf(h_file, "/* Generated from %s */\n", filename);
if(id_str)
fprintf(h_file, "/* %s */\n", id_str);
fprintf(h_file, "\n");
fprintf(h_file, "#ifndef %s\n", fn);
fprintf(h_file, "#define %s\n", fn);
fprintf(h_file, "\n");
fprintf(h_file, "#include <com_right.h>\n");
fprintf(h_file, "\n");
fprintf(h_file,
"void initialize_%s_error_table_r(struct et_list **);\n",
name);
fprintf(h_file, "\n");
fprintf(h_file, "void initialize_%s_error_table(void);\n", name);
fprintf(h_file, "#define init_%s_err_tbl initialize_%s_error_table\n",
name, name);
fprintf(h_file, "\n");
fprintf(h_file, "typedef enum %s_error_number{\n", name);
fprintf(h_file, "\tERROR_TABLE_BASE_%s = %ld,\n", name, base);
fprintf(h_file, "\t%s_err_base = %ld,\n", name, base);
for(ec = codes; ec; ec = ec->next) {
fprintf(h_file, "\t%s = %ld,\n", ec->name, base + ec->number);
}
fprintf(h_file, "\t%s_num_errors = %d\n", name, number);
fprintf(h_file, "} %s_error_number;\n", name);
fprintf(h_file, "\n");
fprintf(h_file, "#endif /* %s */\n", fn);
fclose(h_file);
return 0;
}
static int
generate(void)
{
return generate_c() || generate_h();
}
int help_flag;
struct getargs args[] = {
{ "help", 0, arg_flag, &help_flag }
};
int num_args = sizeof(args) / sizeof(args[0]);
static void
usage(int code)
{
arg_printusage(args, num_args, NULL, "error-table");
exit(code);
}
int
main(int argc, char **argv)
{
char *p;
int optind = 0;
if(getarg(args, num_args, argc, argv, &optind))
usage(1);
if(help_flag)
usage(0);
if(optind == argc)
usage(1);
filename = argv[optind];
yyin = fopen(filename, "r");
if(yyin == NULL)
err(1, "%s", filename);
p = strrchr(filename, '/');
if(p)
p++;
else
p = filename;
strncpy(Basename, p, sizeof(Basename));
Basename[sizeof(Basename) - 1] = '\0';
Basename[strcspn(Basename, ".")] = '\0';
snprintf(hfn, sizeof(hfn), "%s.h", Basename);
snprintf(cfn, sizeof(cfn), "%s.c", Basename);
yyparse();
if(numerror)
return 1;
return generate();
}
-83
View File
@@ -1,83 +0,0 @@
/*
* Copyright (c) 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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: compile_et.h,v 1.3 1998/11/22 09:39:46 assar Exp $ */
#ifndef __COMPILE_ET_H__
#define __COMPILE_ET_H__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
extern long base;
extern int number;
extern char *prefix;
extern char name[128];
extern char *id_str;
extern char *filename;
extern int numerror;
struct error_code {
unsigned number;
char *name;
char *string;
struct error_code *next, **tail;
};
extern struct error_code *codes;
#define APPEND(L, V) \
do { \
if((L) == NULL) { \
(L) = (V); \
(L)->tail = &(V)->next; \
(L)->next = NULL; \
}else{ \
*(L)->tail = (V); \
(L)->tail = &(V)->next; \
} \
}while(0)
#endif /* __COMPILE_ET_H__ */
-96
View File
@@ -1,96 +0,0 @@
/*
* Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
RCSID("$Id: error.c,v 1.13 1998/02/17 21:19:44 bg Exp $");
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <com_right.h>
const char *
com_right(struct et_list *list, long code)
{
struct et_list *p;
for (p = list; p; p = p->next) {
if (code >= p->table->base && code < p->table->base + p->table->n_msgs)
return p->table->msgs[code - p->table->base];
}
return NULL;
}
struct foobar {
struct et_list etl;
struct error_table et;
};
void
initialize_error_table_r(struct et_list **list,
const char **messages,
int num_errors,
long base)
{
struct et_list *et;
struct foobar *f;
for (et = *list; et; et = et->next)
if (et->table->msgs == messages)
return;
f = malloc(sizeof(*f));
if (f == NULL)
return;
et = &f->etl;
et->table = &f->et;
et->table->msgs = messages;
et->table->n_msgs = num_errors;
et->table->base = base;
et->next = *list;
*list = et;
}
void
free_error_table(struct et_list *et)
{
while(et){
struct et_list *p = et;
et = et->next;
free(p);
}
}
-376
View File
@@ -1,376 +0,0 @@
/*
* Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*/
#if 0
RCSID("$Id: getarg.c,v 1.25 1998/11/22 09:45:05 assar Exp $");
#endif
#include <sys/ttycom.h>
#include <time.h>
#include <stdio.h>
#include "getarg.h"
#define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
static size_t
print_arg (char *string, size_t len, int mdoc, int longp, struct getargs *arg)
{
const char *s;
*string = '\0';
if (ISFLAG(*arg))
return 0;
if(mdoc){
if(longp)
strncat(string, "= Ns", len);
strncat(string, " Ar ", len);
}else
if (longp)
strncat (string, "=", len);
else
strncat (string, " ", len);
if (arg->arg_help)
s = arg->arg_help;
else if (arg->type == arg_integer)
s = "number";
else if (arg->type == arg_string)
s = "string";
else
s = "<undefined>";
strncat(string, s, len);
return 1 + strlen(s);
}
static int
check_column(FILE *f, int col, int len, int columns)
{
if(col + len > columns) {
fprintf(f, "\n");
col = fprintf(f, " ");
}
return col;
}
void
arg_printusage (struct getargs *args,
size_t num_args,
const char *progname,
const char *extra_string)
{
int i;
size_t max_len = 0;
char buf[128];
int col = 0, columns;
struct winsize ws;
columns = 80;
col = 0;
col += fprintf (stderr, "Usage: %s", progname);
for (i = 0; i < num_args; ++i) {
size_t len = 0;
if (args[i].long_name) {
buf[0] = '\0';
strncat(buf, "[--", sizeof(buf));
len += 2;
if(args[i].type == arg_negative_flag) {
strncat(buf, "no-", sizeof(buf));
len += 3;
}
strncat(buf, args[i].long_name, sizeof(buf));
len += strlen(args[i].long_name);
len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf),
0, 1, &args[i]);
strncat(buf, "]", sizeof(buf));
if(args[i].type == arg_strings)
strncat(buf, "...", sizeof(buf));
col = check_column(stderr, col, strlen(buf) + 1, columns);
col += fprintf(stderr, " %s", buf);
}
if (args[i].short_name) {
snprintf(buf, sizeof(buf), "[-%c", args[i].short_name);
len += 2;
len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf),
0, 0, &args[i]);
strncat(buf, "]", sizeof(buf));
if(args[i].type == arg_strings)
strncat(buf, "...", sizeof(buf));
col = check_column(stderr, col, strlen(buf) + 1, columns);
col += fprintf(stderr, " %s", buf);
}
if (args[i].long_name && args[i].short_name)
len += 2; /* ", " */
max_len = max(max_len, len);
}
if (extra_string) {
col = check_column(stderr, col, strlen(extra_string) + 1, columns);
fprintf (stderr, " %s\n", extra_string);
} else
fprintf (stderr, "\n");
for (i = 0; i < num_args; ++i) {
if (args[i].help) {
size_t count = 0;
if (args[i].short_name) {
count += fprintf (stderr, "-%c", args[i].short_name);
print_arg (buf, sizeof(buf), 0, 0, &args[i]);
count += fprintf(stderr, "%s", buf);
}
if (args[i].short_name && args[i].long_name)
count += fprintf (stderr, ", ");
if (args[i].long_name) {
count += fprintf (stderr, "--");
if (args[i].type == arg_negative_flag)
count += fprintf (stderr, "no-");
count += fprintf (stderr, "%s", args[i].long_name);
print_arg (buf, sizeof(buf), 0, 1, &args[i]);
count += fprintf(stderr, "%s", buf);
}
while(count++ <= max_len)
putc (' ', stderr);
fprintf (stderr, "%s\n", args[i].help);
}
}
}
static void
add_string(getarg_strings *s, char *value)
{
s->strings = realloc(s->strings, (s->num_strings + 1) * sizeof(*s->strings));
s->strings[s->num_strings] = value;
s->num_strings++;
}
static int
arg_match_long(struct getargs *args, size_t num_args,
char *argv)
{
int i;
char *optarg = NULL;
int negate = 0;
int partial_match = 0;
struct getargs *partial = NULL;
struct getargs *current = NULL;
int argv_len;
char *p;
argv_len = strlen(argv);
p = strchr (argv, '=');
if (p != NULL)
argv_len = p - argv;
for (i = 0; i < num_args; ++i) {
if(args[i].long_name) {
int len = strlen(args[i].long_name);
char *p = argv;
int p_len = argv_len;
negate = 0;
for (;;) {
if (strncmp (args[i].long_name, p, p_len) == 0) {
if(p_len == len)
current = &args[i];
else {
++partial_match;
partial = &args[i];
}
optarg = p + p_len;
} else if (ISFLAG(args[i]) && strncmp (p, "no-", 3) == 0) {
negate = !negate;
p += 3;
p_len -= 3;
continue;
}
break;
}
if (current)
break;
}
}
if (current == NULL) {
if (partial_match == 1)
current = partial;
else
return ARG_ERR_NO_MATCH;
}
if(*optarg == '\0' && !ISFLAG(*current))
return ARG_ERR_NO_MATCH;
switch(current->type){
case arg_integer:
{
int tmp;
if(sscanf(optarg + 1, "%d", &tmp) != 1)
return ARG_ERR_BAD_ARG;
*(int*)current->value = tmp;
return 0;
}
case arg_string:
{
*(char**)current->value = optarg + 1;
return 0;
}
case arg_strings:
{
add_string((getarg_strings*)current->value, optarg + 1);
return 0;
}
case arg_flag:
case arg_negative_flag:
{
int *flag = current->value;
if(*optarg == '\0' ||
strcmp(optarg + 1, "yes") == 0 ||
strcmp(optarg + 1, "true") == 0){
*flag = !negate;
return 0;
} else if (*optarg && strcmp(optarg + 1, "maybe") == 0) {
*flag = rand() & 1;
} else {
*flag = negate;
return 0;
}
return ARG_ERR_BAD_ARG;
}
default:
abort ();
}
}
int
getarg(struct getargs *args, size_t num_args,
int argc, char **argv, int *optind)
{
int i, j, k;
int ret = 0;
srand (time(NULL));
(*optind)++;
for(i = *optind; i < argc; i++) {
if(argv[i][0] != '-')
break;
if(argv[i][1] == '-'){
if(argv[i][2] == 0){
i++;
break;
}
ret = arg_match_long (args, num_args, argv[i] + 2);
if(ret)
return ret;
}else{
for(j = 1; argv[i][j]; j++) {
for(k = 0; k < num_args; k++) {
char *optarg;
if(args[k].short_name == 0)
continue;
if(argv[i][j] == args[k].short_name){
if(args[k].type == arg_flag){
*(int*)args[k].value = 1;
break;
}
if(args[k].type == arg_negative_flag){
*(int*)args[k].value = 0;
break;
}
if(argv[i][j + 1])
optarg = &argv[i][j + 1];
else{
i++;
optarg = argv[i];
}
if(optarg == NULL)
return ARG_ERR_NO_ARG;
if(args[k].type == arg_integer){
int tmp;
if(sscanf(optarg, "%d", &tmp) != 1)
return ARG_ERR_BAD_ARG;
*(int*)args[k].value = tmp;
goto out;
}else if(args[k].type == arg_string){
*(char**)args[k].value = optarg;
goto out;
}else if(args[k].type == arg_strings){
add_string((getarg_strings*)args[k].value, optarg);
goto out;
}
return ARG_ERR_BAD_ARG;
}
}
if (k == num_args)
return ARG_ERR_NO_MATCH;
}
out:;
}
}
*optind = i;
return 0;
}
#if TEST
int foo_flag = 2;
int flag1 = 0;
int flag2 = 0;
int bar_int;
char *baz_string;
struct getargs args[] = {
{ NULL, '1', arg_flag, &flag1, "one", NULL },
{ NULL, '2', arg_flag, &flag2, "two", NULL },
{ "foo", 'f', arg_negative_flag, &foo_flag, "foo", NULL },
{ "bar", 'b', arg_integer, &bar_int, "bar", "seconds"},
{ "baz", 'x', arg_string, &baz_string, "baz", "name" },
};
int main(int argc, char **argv)
{
int optind = 0;
while(getarg(args, 5, argc, argv, &optind))
printf("Bad arg: %s\n", argv[optind]);
printf("flag1 = %d\n", flag1);
printf("flag2 = %d\n", flag2);
printf("foo_flag = %d\n", foo_flag);
printf("bar_int = %d\n", bar_int);
printf("baz_flag = %s\n", baz_string);
arg_printusage (args, 5, argv[0], "nothing here");
}
#endif
-76
View File
@@ -1,76 +0,0 @@
/*
* Copyright (c) 1997 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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: getarg.h,v 1.5 1998/08/18 20:26:11 assar Exp $ */
#ifndef __GETARG_H__
#define __GETARG_H__
#include <stddef.h>
#define max(a,b) (((a)>(b))?(a):(b))
struct getargs{
const char *long_name;
char short_name;
enum { arg_integer, arg_string, arg_flag, arg_negative_flag, arg_strings } type;
void *value;
const char *help;
const char *arg_help;
};
enum {
ARG_ERR_NO_MATCH = 1,
ARG_ERR_BAD_ARG,
ARG_ERR_NO_ARG
};
typedef struct getarg_strings {
int num_strings;
char **strings;
} getarg_strings;
int getarg(struct getargs *args, size_t num_args,
int argc, char **argv, int *optind);
void arg_printusage (struct getargs *args,
size_t num_args,
const char *progname,
const char *extra_string);
#endif /* __GETARG_H__ */
-129
View File
@@ -1,129 +0,0 @@
%{
/*
* Copyright (c) 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*/
/*
* This is to handle the definition of this symbol in some AIX
* headers, which will conflict with the definition that lex will
* generate for it. It's only a problem for AIX lex.
*/
#undef ECHO
#include "compile_et.h"
#include "parse.h"
#if 0
RCSID("$Id: lex.l,v 1.4 1998/11/20 05:58:52 assar Exp $");
#endif
static unsigned lineno = 1;
void error_message(char *, ...);
int getstring(void);
%}
%%
et { return ET; }
error_table { return ET; }
ec { return EC; }
error_code { return EC; }
prefix { return PREFIX; }
index { return INDEX; }
id { return ID; }
end { return END; }
[0-9]+ { yylval.number = atoi(yytext); return NUMBER; }
#[^\n]* ;
[ \t] ;
\n { lineno++; }
\" { return getstring(); }
[a-zA-Z0-9_]+ { yylval.string = strdup(yytext); return STRING; }
. { return *yytext; }
%%
#ifndef yywrap /* XXX */
int
yywrap ()
{
return 1;
}
#endif
int
getstring(void)
{
char x[128];
int i = 0;
int c;
int quote = 0;
while((c = input()) != EOF){
if(quote) {
x[i++] = c;
quote = 0;
continue;
}
if(c == '\n'){
error_message("unterminated string");
lineno++;
break;
}
if(c == '\\'){
quote++;
continue;
}
if(c == '\"')
break;
x[i++] = c;
}
x[i] = '\0';
yylval.string = strdup(x);
return STRING;
}
void
error_message (char *format, ...)
{
va_list args;
va_start (args, format);
fprintf (stderr, "%s:%d:", filename, lineno);
vfprintf (stderr, format, args);
va_end (args);
numerror++;
}
-173
View File
@@ -1,173 +0,0 @@
%{
/*
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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 "compile_et.h"
#if 0
RCSID("$Id: parse.y,v 1.9 1999/07/04 14:54:58 assar Exp $");
#endif
void yyerror (char *s);
long name2number(const char *str);
void error_message(char *, ...);
extern char *yytext;
/* This is for bison */
#if !defined(alloca) && !defined(HAVE_ALLOCA)
#define alloca(x) malloc(x)
#endif
%}
%union {
char *string;
int number;
}
%token ET INDEX PREFIX EC ID END
%token <string> STRING
%token <number> NUMBER
%%
file : /* */
| header statements
;
header : id et
| et
;
id : ID STRING
{
id_str = $2;
}
;
et : ET STRING
{
base = name2number($2);
strncpy(name, $2, sizeof(name));
name[sizeof(name) - 1] = '\0';
free($2);
}
| ET STRING STRING
{
base = name2number($2);
strncpy(name, $3, sizeof(name));
name[sizeof(name) - 1] = '\0';
free($2);
free($3);
}
;
statements : statement
| statements statement
;
statement : INDEX NUMBER
{
number = $2;
}
| PREFIX STRING
{
prefix = realloc(prefix, strlen($2) + 2);
strcpy(prefix, $2);
strcat(prefix, "_");
free($2);
}
| PREFIX
{
prefix = realloc(prefix, 1);
*prefix = '\0';
}
| EC STRING ',' STRING
{
struct error_code *ec = malloc(sizeof(*ec));
ec->next = NULL;
ec->number = number;
if(prefix && *prefix != '\0') {
asprintf (&ec->name, "%s%s", prefix, $2);
free($2);
} else
ec->name = $2;
ec->string = $4;
APPEND(codes, ec);
number++;
}
| END
{
YYACCEPT;
}
;
%%
long
name2number(const char *str)
{
const char *p;
long base = 0;
const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz0123456789_";
if(strlen(str) > 4) {
yyerror("table name too long");
return 0;
}
for(p = str; *p; p++){
char *q = strchr(x, *p);
if(q == NULL) {
yyerror("invalid character in table name");
return 0;
}
base = (base << 6) + (q - x) + 1;
}
base <<= 8;
if(base > 0x7fffffff)
base = -(0xffffffff - base + 1);
return base;
}
void
yyerror (char *s)
{
error_message ("%s\n", s);
}
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright (c) 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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: roken_rename.h,v 1.2 1999/03/11 18:14:53 bg Exp $ */
#ifndef __roken_rename_h__
#define __roken_rename_h__
#endif /* __roken_rename_h__ */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-156
View File
@@ -1,156 +0,0 @@
/*
* Copyright (c) 1999
* Bill Paul <[email protected]>. 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. 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 Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
* 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.
*
* $FreeBSD$
*/
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <stdlib.h>
#include <unistd.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_vlan_var.h>
#include <net/route.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <err.h>
#include <errno.h>
#include "ifconfig.h"
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif
static int __tag = 0;
static int __have_tag = 0;
void vlan_status(s, info)
int s;
struct rt_addrinfo *info __unused;
{
struct vlanreq vreq;
bzero((char *)&vreq, sizeof(struct vlanreq));
ifr.ifr_data = (caddr_t)&vreq;
if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
return;
printf("\tvlan: %d parent interface: %s\n",
vreq.vlr_tag, vreq.vlr_parent[0] == '\0' ?
"<none>" : vreq.vlr_parent);
return;
}
void setvlantag(val, d, s, afp)
const char *val;
int d, s;
const struct afswtch *afp;
{
u_int16_t tag;
struct vlanreq vreq;
__tag = tag = atoi(val);
__have_tag = 1;
bzero((char *)&vreq, sizeof(struct vlanreq));
ifr.ifr_data = (caddr_t)&vreq;
if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
err(1, "SIOCGETVLAN");
vreq.vlr_tag = tag;
if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
err(1, "SIOCSETVLAN");
return;
}
void setvlandev(val, d, s, afp)
const char *val;
int d, s;
const struct afswtch *afp;
{
struct vlanreq vreq;
if (!__have_tag)
errx(1, "must specify both vlan tag and device");
bzero((char *)&vreq, sizeof(struct vlanreq));
ifr.ifr_data = (caddr_t)&vreq;
if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
err(1, "SIOCGETVLAN");
strncpy(vreq.vlr_parent, val, sizeof(vreq.vlr_parent));
vreq.vlr_tag = __tag;
if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
err(1, "SIOCSETVLAN");
return;
}
void unsetvlandev(val, d, s, afp)
const char *val;
int d, s;
const struct afswtch *afp;
{
struct vlanreq vreq;
bzero((char *)&vreq, sizeof(struct vlanreq));
ifr.ifr_data = (caddr_t)&vreq;
if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
err(1, "SIOCGETVLAN");
bzero((char *)&vreq.vlr_parent, sizeof(vreq.vlr_parent));
vreq.vlr_tag = 0;
if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
err(1, "SIOCSETVLAN");
return;
}
@@ -1,27 +0,0 @@
kernel, rc.local, and xdm-config are typically softlinks. Plus other
files, of course, depending on how you setup your system.
rc.local and xdm-config might be softlinks into HT.DISKLESS, allowing
you to ease system administration when managing many diskless
workstations. You can also play other tricks, such as I play in
rc.conf.local by having it source ../HT.DISKLESS/rc.conf.local to get
class-based defaults.
Note: the ttys file below contains an example of how to have X startup
on boot.
apollo:/conf/209.157.86.12# ls -la
total 7
drwxr-xr-x 2 root wheel 512 Feb 9 00:27 .
drwxr-xr-x 8 root wheel 512 Feb 8 22:48 ..
lrwxr-xr-x 1 root wheel 20 Feb 8 22:04 fstab -> ../HT.DISKLESS/fstab
lrwxr-xr-x 1 root wheel 17 Jan 24 23:33 kernel -> /kernel.diskless2
-rw-r--r-- 1 root wheel 133 Feb 8 22:04 rc.conf.local
lrwxr-xr-x 1 root wheel 23 Jan 25 00:41 rc.local -> ../HT.DISKLESS/rc.local
-rw------- 1 root wheel 539 Jan 17 15:29 ssh_host_key
-rw-r--r-- 1 root wheel 343 Jan 17 15:29 ssh_host_key.pub
lrwxr-xr-x 1 root wheel 26 Feb 9 00:27 syslog.conf -> ../HT.DISKLESS/syslog.conf
-rw-r--r-- 1 root wheel 1408 Feb 8 19:54 ttys
lrwxr-xr-x 1 root wheel 25 Jan 25 00:38 xdm-config -> ../HT.DISKLESS/xdm-config
@@ -1,9 +0,0 @@
# DISKLESS RC.CONF.LOCAL
#
# Override system standard /etc/rc.conf
. /conf/HT.DISKLESS/rc.conf.local
hostname=test2.backplane.com
start_xdm=NO
Binary file not shown.
@@ -1 +0,0 @@
1024 33 131532587310298436102876167134780549224884868848048954510241288010381123823834489593599651234236801895942903979896941799980786675282403650831462626987993609590967535749256449810953893747928248417183421903403076895749793372279190481189373438759742396152779236777836204647146078686957945395785442097357022574693 [email protected]
@@ -1,5 +0,0 @@
# fstab for diskless machine. Root is already mounted, as is swap.
#
209.157.86.2:/usr /usr nfs ro 0 0
209.157.86.2:/var /var nfs ro 0 0
proc /proc procfs rw 0 0
@@ -1,34 +0,0 @@
# DISKLESS RC.CONF.LOCAL
#
# Override system standard /etc/rc.conf
ldconfig_paths="$ldconfig_paths /usr/krb5/lib"
ldconfig_paths_aout="$ldconfig_paths_aout /usr/krb5/lib/aout"
# Must do NFS mounts early
# Must not attempt to mount root rw
#
early_nfs_mounts="YES"
root_rw_mount="NO"
inetd_enable="NO"
portmap_enable="NO"
router_enable="NO"
cron_enable="NO"
sendmail_enable="NO"
# Enable additional services
#
nfs_client_enable="YES"
lpd_enable="YES"
ntpdate_enable="YES"
ntpdate_flags="apollo.backplane.com"
xntpd_enable="YES"
if [ -f /etc/ipfw.conf ]; then
firewall_enable="YES"
firewall_type="/etc/ipfw.conf"
firewall_quiet="NO"
fi
@@ -1,77 +0,0 @@
#!/bin/sh
if [ -f /etc/rc.conf ]; then
. /etc/rc.conf
fi
# Firewall helper - if we configure the firewall to let through
# ports > 4000, we need to configure the machines as such.
#
sysctl -w net.inet.ip.portrange.first=4000
# Setup spool
#
cat >> /var/spool/lpd/ljet4.ps << EOF
#!/bin/sh
#
gs -q -dSAFER -dNOPAUSE -sDEVICE=ljet4 -r600x600 -dBitsPerPixel=1 \
-sOutputFile=- -
EOF
chmod 755 /var/spool/lpd/ljet4.ps
mkdir /var/spool/ljet4
chown daemon /var/spool/ljet4
# Setup remote source
#
mount_mfs -s 600000 -T qp120at dummy /src
mount apollo:/FreeBSD /FreeBSD
mkdir /src/u3
mkdir /src/u3/usr.obj
# Copy of ssh_host_key* files to where sshd
# expects them, assuming you add to /usr/local/etc/sshd_config:
#
# HostKey /var/db/ssh_host_key
#
# Then restart sshd ( the /usr/local/etc/rc.d script installed by
# the port probably failed due to the lack of host keys )
if [ -f /conf/ME/ssh_host_key ]; then
cp /conf/ME/ssh_host_key* /var/db
else
(cd /var/db; ssh-keygen -f ssh_host_key -P "")
fi
chmod 400 /var/db/ssh_host_key
chmod 644 /var/db/ssh_host_key.pub
/usr/local/sbin/sshd
# Copy home directory so you can login
#
#
mount_mfs -s 65536 -T qp120at dummy /home
if [ -d /home.diskless ]; then
cd /home.diskless
for i in *; do
if [ -f $i/home.tgz ]; then
mkdir /home/$i
chown $i /home/$i
chmod 700 /home/$i
(cd /home/$i; tar xzpf /home.diskless/$i/home.tgz)
homeok=1
fi
done
fi
if [ "${homeok:=0}" = "0" ]; then
echo "ERROR, NO /home.diskless DIRECTORY TO COPY TO /HOME"
sleep 10
fi
@@ -1,3 +0,0 @@
*.err;kern.debug;auth.notice;mail.crit;lpr.info /dev/console
*.err;kern.debug;auth.notice;mail.crit root
*.emerg *
-52
View File
@@ -1,52 +0,0 @@
#
# @(#)ttys 5.1 (Berkeley) 4/17/89
#
# name getty type status comments
#
# This entry needed for asking password when init goes to single-user mode
# If you want to be asked for password, change "secure" to "insecure" here
console none unknown off secure
#
ttyv0 "/usr/X11R6/bin/xdm -nodaemon -config /conf/209.157.86.6/xdm-config" cons25 on secure
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" cons25 on secure
ttyv2 "/usr/libexec/getty Pc" cons25 on secure
ttyv3 "/usr/libexec/getty Pc" cons25 on secure
# Serial terminals
ttyd0 "/usr/libexec/getty std.9600" unknown off secure
ttyd1 "/usr/libexec/getty std.9600" unknown off secure
ttyd2 "/usr/libexec/getty std.9600" unknown off secure
ttyd3 "/usr/libexec/getty std.9600" unknown off secure
# Pseudo terminals
ttyp0 none network
ttyp1 none network
ttyp2 none network
ttyp3 none network
ttyp4 none network
ttyp5 none network
ttyp6 none network
ttyp7 none network
ttyp8 none network
ttyp9 none network
ttypa none network
ttypb none network
ttypc none network
ttypd none network
ttype none network
ttypf none network
ttypg none network
ttyph none network
ttypi none network
ttypj none network
ttypk none network
ttypl none network
ttypm none network
ttypn none network
ttypo none network
ttypp none network
ttypq none network
ttypr none network
ttyps none network
ttypt none network
ttypu none network
ttypv none network
@@ -1,15 +0,0 @@
! $XConsortium: xdm-conf.cpp,v 1.2 93/09/28 14:30:32 gildea Exp $
DisplayManager.errorLogFile: /var/run/xdm-errors
DisplayManager.pidFile: /var/run/xdm-pid
DisplayManager.servers: /usr/X11R6/lib/X11/xdm/Xservers-1
DisplayManager.keyFile: /usr/X11R6/lib/X11/xdm/xdm-keys
DisplayManager.servers: /usr/X11R6/lib/X11/xdm/Xservers
DisplayManager.accessFile: /usr/X11R6/lib/X11/xdm/Xaccess
DisplayManager._0.authorize: true
DisplayManager._0.setup: /usr/X11R6/lib/X11/xdm/Xsetup_0
DisplayManager._0.startup: /usr/X11R6/lib/X11/xdm/GiveConsole
DisplayManager._0.reset: /usr/X11R6/lib/X11/xdm/TakeConsole
DisplayManager*resources: /usr/X11R6/lib/X11/xdm/Xresources
DisplayManager*session: /usr/X11R6/lib/X11/xdm/Xsession
DisplayManager*authComplain: false
-30
View File
@@ -1,30 +0,0 @@
#
# @(#)aliases 5.3 (Berkeley) 5/24/90
#
# Aliases in this file will NOT be expanded in the header from
# Mail, but WILL be visible over networks or from /bin/mail.
#
# >>>>>>>>>> The program "newaliases" must be run after
# >> NOTE >> this file is updated for any changes to
# >>>>>>>>>> show through to sendmail.
#
# Basic system aliases -- these MUST be present
MAILER-DAEMON: postmaster
postmaster: root
# General redirections for pseudo accounts
bin: root
daemon: root
games: root
ingres: root
nobody: root
system: root
toor: root
uucp: root
usenet: root
root: [email protected]
diablo: dillon
diablo-bugs: dillon
@@ -1,6 +0,0 @@
# @(#)forward.map 1.1 1/17/95
#
# Put addresses to be forwarded here. Example:
#
# [email protected] [email protected]
#
@@ -1,11 +0,0 @@
#
# example:
# fofs.com [email protected]
#
# NOTE: FORWARD.MAP can be used to override NDOMAIN.MAP for specific
# users. NDOMAIN.MAP would then act as a catch-all
#
# NOTE: NDOMAIN.MAP only works to two levels. I.E. if you have an
# entry for fubar.com, then [email protected] will work and
# [email protected] will work, but NOT [email protected]
#
@@ -1,11 +0,0 @@
*.err;kern.debug;auth.notice;mail.crit /dev/console
# *.notice;kern.debug;lpr,auth.info;mail.crit /var/log/messages
*.debug;kern.debug;lpr,auth.info;mail.crit;news.crit /var/log/messages
mail.info /var/log/maillog
news.info /var/log/news
lpr.info /var/log/lpd-errs
cron.* /var/log/cron
#*.err root
#*.notice;auth.debug root
#*.alert root
*.emerg *
-52
View File
@@ -1,52 +0,0 @@
#
# @(#)ttys 5.1 (Berkeley) 4/17/89
#
# name getty type status comments
#
# This entry needed for asking password when init goes to single-user mode
# If you want to be asked for password, change "secure" to "insecure" here
console none unknown off secure
#
ttyv0 "/usr/libexec/getty Pc" cons25 on secure
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" cons25 on secure
ttyv2 "/usr/libexec/getty Pc" cons25 on secure
ttyv3 "/usr/libexec/getty Pc" cons25 on secure
# Serial terminals
ttyd0 "/usr/libexec/getty std.9600" unknown off secure
ttyd1 "/usr/libexec/getty std.9600" unknown off secure
ttyd2 "/usr/libexec/getty std.9600" unknown off secure
ttyd3 "/usr/libexec/getty std.9600" unknown off secure
# Pseudo terminals
ttyp0 none network
ttyp1 none network
ttyp2 none network
ttyp3 none network
ttyp4 none network
ttyp5 none network
ttyp6 none network
ttyp7 none network
ttyp8 none network
ttyp9 none network
ttypa none network
ttypb none network
ttypc none network
ttypd none network
ttype none network
ttypf none network
ttypg none network
ttyph none network
ttypi none network
ttypj none network
ttypk none network
ttypl none network
ttypm none network
ttypn none network
ttypo none network
ttypp none network
ttypq none network
ttypr none network
ttyps none network
ttypt none network
ttypu none network
ttypv none network
-37
View File
@@ -1,37 +0,0 @@
When templating, /conf/ME is typically a softlink to
/conf/<appropriate-machine>. When doing a diskless boot, /conf/ME is
retargeted by /etc/rc.diskless1 from pointing to the server to pointing
to the client's directory, /conf/<ip-address-of-client>. The retargeting
is accomplished through an MFS -o union mount.
When templating, this softlink should be different for each machine.
When doing a diskless boot, this softlink is typically part of the / NFS
mount from the server and points to the server's conf directory, but gets
retargeted during the /etc/rc.diskless1 phase.
System-wide configuration files must generally be targeted through /conf/ME.
For example, your /etc/rc.conf.local should become a softlink to
/conf/ME/rc.conf.local and your real rc.conf.local should go into the
appropriate /conf/<appropriate-machine> directory. This is also true of
/etc/rc.local, /etc/fstab, /etc/syslog.conf, /etc/ccd.conf, /etc/ipfw.conf,
/etc/motd, /etc/resolv.conf, and possibly even /etc/ttys ( if you want
to start an X session up on boot on certain of your machines ).
When templating, you duplicate your / and /usr partitions on each machine's
local disk from a single master ( assuming /var and /home reside elsewhere ),
EXCEPT for the /conf/ME softlink. The /conf/ME softlink is the only thing
on / that should be different for each machine.
There are often categories of configuration files. For example, all of your
shell machines may use one resolv.conf while all of your mail proxies may
use another. Configuration files can be categorized fairly easily through
/conf/HT.<category> directories. You put the actual configuration file in
/conf/HT.<category> and make a softlink from
/conf/ME/<appropriate-machines>/config-file to "../HT.<category/config-file".
This means that access to these files tends to run through more then one
softlink. The advantage is that for all the complexity of your /conf
directory hierarchy, most of your common config files exist in only one place
in reality.
-157
View File
@@ -1,157 +0,0 @@
BOOTP configuration mechanism
Matthew Dillon
[email protected]
BOOTP kernels automatically configure the machine's IP address, netmask,
optional NFS based swap, and NFS based root mount. The NFS server will
typically export a shared read-only /, /usr, and /var to any number of
workstations. The shared read-only root is typically either the server's
own root or, if you are more security concious, a contrived root.
The key issue with starting up a BOOTP kernel is that you typically want
to export read-only NFS partitions from the server, yet still be able to
customize each workstation ( or not ).
/etc/rc.diskless1 is responsible for doing core mounts and for retargeting
/conf/ME ( part of the read-only root NFS mount ) to /conf/$IP_OF_CLIENT.
/etc/rc.conf.local and /etc/rc.local, along with other machine-specific
configuration files, are typically softlinks to /conf/ME/<filename>.
In the BOOTP workstation /conf/$IP/rc.conf.local, you must typically
turn *OFF* most of the system option defaults in /etc/rc.conf as well
as do additional custom configuration of your environment
The /usr/src/share/examples/diskless directory contains a typical
X session / sshd based workstation configuration. The directories
involved are HT.DISKLESS/ and 192.157.86.12/.
Essentially, the $IP/ directory ( which rc.diskless looks for in
/conf/$IP/ ) contains all the junk. The HT.DISKLESS directory exists
to hold common elements of your custom configuration so you do not have
to repeat those elements for each workstation. The example /conf
structure included here shows how to create a working sshd setup ( so
you can sshd into the diskless workstation ), retarget xdm's pid and error
files to R+W directories if /usr is mounted read-only, and retarget
syslogd and other programs. This example is not designed to run out of
the box and some modifications are required.
>> NOTE << HT.DISKLESS/ttys contains the typical configuration required
to bring X up at boot time. Essentially, it runs xdm in the foreground
with the appropriate arguments rather then a getty on ttyv0. You must
run xdm on ttyv0 in order to prevent xdm racing with getty on a virtual
terminal. Such a race can cause your keyboard to be directed away from
the X session, essentially making the session unusable.
Typically you should start with a clean slate by tar-copying this example
directory to /conf and then hack on it in /conf rather then in
/usr/share/examples/diskless.
BOOTP CLIENT SETUP
Here is a typical kernel configuration. If you have only one ethernet
interface you do not need to wire BOOTP to a specific interface name.
BOOTP requires NFS and NFS_ROOT, and our boot scripts require MFS. If
your /tmp is *not* a softlink to /var/tmp, the scripts also require NULLFS
# BootP
#
options BOOTP # Use BOOTP to obtain IP address/hostname
options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info
options "BOOTP_NFSV3" # Use NFS v3 to NFS mount rootoptions
options BOOTP_COMPAT # Workaround for broken bootp daemons.
#options "BOOTP_WIRED_TO=de0"
options MFS # Memory File System
options NFS # Network Filesystem
options NFS_ROOT # Nfs can be root
options NULLFS # nullfs to map /var/tmp to /tmp
BOOTP SERVER SETUP
The BOOTP server must be running on the same logical LAN as the the
BOOTP client(s). You need to setup two things:
(1) You need to NFS-export /, /usr, and /var.
(2) You need to run a BOOTP server. DHCPD can do this.
NFS Export:
Here is an example "/etc/exports" file.
/ -ro -maproot=root: -network 192.157.86.0 -mask 255.255.255.192
/usr -ro -maproot=root: -network 192.157.86.0 -mask 255.255.255.192
/var -ro -maproot=root: -network 192.157.86.0 -mask 255.255.255.192
In order to be an NFS server, the server must run portmap, mountd,
nfsd, and rpc.statd. The standard NFS server options in /etc/rc.conf
will work ( you should put your overrides in /etc/rc.conf.local on the
server and not edit the distribution /etc/rc.conf, though ).
BOOTP Server:
This configuration file "/etc/dhcpd.conf" example is for
the '/usr/ports/net/isc-dhcp' dhcpd port.
subnet 192.157.86.0 netmask 255.255.255.192 {
# range if you want to run the core dhcpd service of
# dynamic IP assignment, but it is not used with BOOTP
# workstations
range 192.157.86.32 192.157.86.62;
# misc configuration.
#
option routers 192.157.86.2;
option domain-name-servers 192.157.86.2;
server-name "apollo.fubar.com";
option subnet-mask 255.255.255.192;
option domain-name-servers 192.157.86.2;
option domain-name "fubar.com";
option broadcast-address 192.157.86.63;
option routers 192.157.86.2;
}
host test1 {
hardware ethernet 00:a0:c9:d3:38:25;
fixed-address 192.157.86.11;
option root-path "192.157.86.2:/";
option option-128 "192.157.86.2:/images/swap";
}
host test2 {
# hardware ethernet 00:e0:29:1d:16:09;
hardware ethernet 00:10:5a:a8:94:0e;
fixed-address 192.157.86.12;
option root-path "192.157.86.2:/";
option option-128 "192.157.86.2:/images/swap";
}
SWAP. This example includes options to automatically BOOTP configure
NFS swap on each workstation. In order to use this capabilities you
need to NFS-export a swap directory READ+WRITE to the workstations.
You must then create a swap directory for each workstation you wish to
assign swap to. In this example I created a dummy user 'lander' and
did an NFS export of /images/swap enforcing a UID of 'lander' for
all accesses.
apollo:/usr/ports/net# ls -la /images/swap
total 491786
drwxr-xr-x 2 root wheel 512 Dec 28 07:00 .
drwxr-xr-x 8 root wheel 512 Jan 20 10:54 ..
-rw-r--r-- 1 lander wheel 33554432 Dec 23 14:35 swap.192.157.86.11
-rw-r--r-- 1 lander wheel 335544320 Jan 24 16:55 swap.192.157.86.12
-rw-r--r-- 1 lander wheel 134217728 Jan 21 17:19 swap.192.157.86.6
A swap file is best created with dd:
# create a 32MB swap file for a BOOTP workstation
dd if=/dev/zero of=swap.IPADDRESS bs=1m count=32
It is generally a good idea to give your workstations some swap space,
but not a requirement if they have a lot of memory.
-286
View File
@@ -1,286 +0,0 @@
TEMPLATING machine configurations
Matthew Dillon
[email protected]
This document describes a general mechanism by which you can template
/ and /usr. That is, to keep a 'master template' of / and /usr on a
separate machine which is then used to update the rest of your machines.
Generally speaking, you can't simply mirror /. You might be able to
get away with mirroring /usr. There are two main problems involved with
templating:
(1) Avoiding overwriting run-time generated files
By default, the system maintains a number of files in the root
partition. For example, sendmail will dbm /etc/aliases into
/etc/aliases.db. vipw or chpass or other password related routines
will regenerate the password dbm's /etc/spwd.db, /etc/pwd.db, and
passwd. /etc/namedb/s might contain generated secondaries. And
so forth.
The templating mechanism must avoid copying over such files.
(2) Customizing machines.
Customizing machines is actually considerably simpler. You create
a configuration hierarchy and convert the configuration files that
have to be customized into softlinks that run through a special
softlink in the configuration directory. This will work for every
configuration file except possibly /etc/master.passwd
For example, /etc/resolv.conf would be turned into a softlink to
/conf/ME/resolv.conf, and /conf/ME itself would be a softlink to
/conf/<HOSTNAME>. The actual resolv.conf configuration file
would reside in /conf/<HOSTNAME>.
If you have a lot of hosts, some configuration files may be commonly
classified. For example, all your shell machines might have the
same /etc/resolv.conf. The solution is to make
/conf/<HOSTNAME>/resolv.conf a softlink to a common directory, say
/conf/HT.SHELL/resolv.conf. It may sound a little messy, but this
sort of categorization actually makes the sysadmins job much, much
easier.
The /conf/ directory hierarchy is stored on the template and
distributed to all the machines along with the rest of the root
partition.
This type of customization is taken from my direct experience
instituting such a system at BEST. At the time, BEST had over 45
machines managed from a single template.
RUN-TIME GENERATED OR MODIFIED FILES IN / or /USR
/etc/aliases.db
/etc/master.passwd
/etc/spwd.db
/etc/pwd.db
/etc/passwd
/etc/namedb/s
/root/.history
/root/.ssh/identity
/root/.ssh/identity.pub
/root/.ssh/random_seed
/root/.ssh/known_hosts
/conf/ME
/kernel* ( note 2 )
/dev ( note 3 )
/var ( note 4 )
/home ( note 4 )
/lost+found
/usr/lost+found
/usr/home ( note 4 )
/usr/crash ( note 5 )
/usr/obj ( note 5 )
/usr/ports ( note 5 )
/usr/src ( note 5 )
/usr/local/crack ( note 5 )
/usr/X11R6/lib/X11/xdm/xdm-errors ( note 6 )
/usr/X11R6/lib/X11/xdm/xdm-pid ( note 6 )
/usr/local/etc/ssh_host_key ( note 6 )
/usr/local/etc/ssh_host_key.pub ( note 6 )
/usr/local/etc/ssh_random_seed ( note 6 )
/conf/ME ( note 7 )
note 2: You typically want to update kernels manually and *NOT*
template them as a safety measure. This also allows you to run
different kernels on different machines or.
note 3: /dev must be updated manually. Some devices, such as tty's and
pty's, use the access and/or modify time and/or user/group
operationally and regenerating the devices on the fly would be
bad.
note 4: /var and /home are usually separately mounted partitions and
thus would not fall under the template, but as a safety measure
the template copier refuse to copy directories named 'home'.
note 5: These are directories that are as often created directly on
/usr as they are separately-mounted partitions. You typically
do not want to template such directories.
note 6: Note that you can solve the problem of xdm and sshd creating
files in /usr. With xdm, edit /usr/X11R6/lib/xdm/xdm-config
and change the errorLogFile and pidFile config lines.
With sshd, add 'HostKey' and 'RandomSeed' directives to specify
/var/db for the location of the host key and run-time sshd
random seed:
HostKey /var/db/ssh_host_key
RandomSeed /var/db/ssh_random_seed
note 7: In this example, /conf/ME is the machine customizer and must
be pointed to the /conf/<full-host-name>/ directory, which is
different for each machine. Thus, the /conf/ME softlink
should never be overwritten by the templating copy.
TYPICAL CUSTOMIZED CONFIGRATION SOFTLINKS
The following files typically need to be turned into softlinks
to /conf/ME/<filename>:
/etc/ccd.conf -> /conf/ME/ccd.conf
/etc/ipfw.conf ...
/etc/fstab
/etc/motd
/etc/resolv.conf
/etc/aliases
/etc/sendmail.cw
/etc/organization
/etc/named.conf
/etc/rc.conf.local
/etc/printcap
/etc/inetd.conf
/etc/login.conf
/etc/gettytab
/etc/ntp.conf
/etc/exports
/root/.k5login -> /conf/ME/root/.k5login
And, of course, /conf/ME is usually a softlink to the appropriate
/conf/<full-host-name>/. Depending on your system configuration,
there may be other files not listed above that you have to worry about.
In many cases, /conf/ME/filename is itself a softlink to
"../HT.xxxx/filename", where HT.xxxx is something like HT.STD ... this
added complexity actually makes it easier to manage multiple
classifications of machines.
DELETION OF FILES
Any file found on the template destination that does not exist in the
source and is not listed as an exception by the source should be deleted.
However, deletion can be dangerous and cpdup will ask for confirmation
by default. Once you know you aren't going to blow things up, you can
turn this feature off and update your systems automatically from cron.
By formalizing the delete operation, you can be 100% sure that it is
possible to recreate / and /usr on any machine with only the original
template and a backup of the ( relatively few ) explicitly-excepted
files. The most common mistake a sysop makes is to make a change to a
file in / or /usr on a target machine instead of the template machine.
If the target machine is updated once a night from cron, the sysop
quickly learns not to do this ( because his changes get overwritten
overnight ). With a manual update, these sorts of mistakes can propogate
for weeks or months before they are caught.
TEMPLATE COPYING AND SAFETY
THE CPDUP PROGRAM
The 'cpdup' program is a program which efficiently duplicates a directory
tree. The program copies source to destination, duplicating devices,
softlinks, hardlinks, files, modification times, uid, gid, flags, perms,
and so forth. The program incorporates several major features:
* The program refuses, absolutely, to cross partition boundries.
i.e. if you were copying the template /usr from an NFS mount to
your /usr, and you had a mount point called /usr/home, the
template copying program would *NOT* descend into /usr/home on
the destination.
This is a safety.
* The program accesses a file called .cpignore in each directory
it descending into on the source to obtain a list of exceptions
for that directory -- that is, files not to copy or mess with.
This is a templating function.
* The program refuses to delete a directory on the destination
being replaced by a softlink or file on the source.
This is a safety mechanism
* The program is capable of maintaing MD5 check cache files and
doing an MD5 check between source and destination during the
scan.
* The program is capable of deleting files/directories on the
destination that do not exist on the source, but asks for
confirmation by default.
This is a templating and a safety mechanism.
* The program uses a copy-to-tmp-and-rename methodology allowing
it to be used to update live filesystems.
This is a templating mechanism.
* The program, by default, tries to determine if a copy is required
by checking modify times, file size, perms, and other stat
elements. If the elements match, it does not bother to copy
( unless an MD5 check is being made, in which case it must read
the destination file ).
You typically run cpdup on the target machine. The target machine
temporarily mounts the template machine's / and /usr via NFS, read-only,
and runs cpdup to update / and /usr. If you use this methodology note
that THERE ARE SECURITY CONSIDERATIONS! See 'SECURITY CONSIDERATIONS WITH
NFS' below.
Whatever script you use that does the NFS mounts should ensure that the
mount succeeded before continuing with the cpdup.
You should create .cpignore files in the appropriate directories on the
template machine's / and /usr partitions so as not to overwrite active
files on the target. The most critical .cpignore files should be
protected with 'chflags schg .cpignore'. Specifically, the ones in /
and /etc, but possibly others as well. For example, the .cpignore
hierarchy for protect /root is:
# /root/.cpignore contains
.history
# /root/.ssh/.cpignore contains
random_seed
known_hosts
authorized_keys
identity
identity.pub
WHEN INITIALLY CONVERTING A TARGET MACHINE TO USE TEMPLATING, ALWAYS
MAKE A FULL BACKUP OF THE TARGET MACHINE FIRST! You may accidently delete
files on the target during the conversion due to forgetting to enter
items into appropriate .cpignore files on the source.
SECURITY CONSIDERATIONS WITH NFS ROOT EXPORT FROM TEMPLATE MACHINE
SECURITY CONSIDERATIONS WITH NFS USR EXPORT FROM TEMPLATE MACHINE
There are some serious security considerations that must be taken into
account when exporting / and /usr on the template machine.
* only export read-only
* the password file ( aka vipw ) may not contain any crypted passwords
at all. You MUST use ssh or kerberos to access the template machine.
You can get away with giving only root a crypted password, but only
if you disallow network root logins and only allow direct root
logins on the console.
* The machine's private ssh_host_key usually resides in /usr/local/etc.
You must move this key to /var/db. You can softlink link so no
modification of sshd_config is required.
* The machine's private ~root/.ssh/identity file is also exposed by
the NFS export, you should move this file to /var/db as well and
put a softlink in ~root/.ssh.
* DON'T EXPORT /var ! Either that, or don't put the private keys
in /var/db ... put them somewhere else.
* You may want to redirect the location of the random_seed file, which
can be done by editing ~root/.ssh/sshd_config and
/usr/local/etc/sshd_config so it is not exposed either.
-Matt
Matthew Dillon
[email protected]
-64
View File
@@ -1,64 +0,0 @@
.\" Copyright (c) 1999 Takanori Watanabe
.\" 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.
.\"
.\" $FreeBSD$
.\"
.\" Note: The date here should be updated whenever a non-trivial
.\" change is made to the manual page.
.Dd January 8, 1999
.Dt INTPM 4 i386
.\" Note: Only specify the operating system when the command
.\" is FreeBSD specific, otherwise use the .Os macro with no
.\" arguments.
.Os FreeBSD 3.0
.Sh NAME
.Nm intpm
.Nd Intel PIIX4 Power management controller driver.
.Sh SYNOPSIS
.Cd controller smbus0
.Cd controller intpm0
.Sh DESCRIPTION
This driver provides access to
.Tn Intel PIIX4 PCI Controller function 3 ,
Power management controller. Currently, only smbus controller
function is implemented. But it also have bus idle monitoring function. It
will display mapped I/O address for bus monitoring function when attaching.
.Sh SEE ALSO
.Xr smb 4 ,
.Xr smbus 4
.Sh HISTORY
The
.Nm
manual page example first appeared in
.Fx 3.0 .
.Sh AUTHORS
This
manual page was written by
.An Takanori Watanabe Aq [email protected] .
.Sh BUGS
This device requires IRQ 9 exclusively. To use this, you should enable
ACPI function in BIOS configuration, or PnP mechanism assigns conflicted
IRQ for PnP ISA card. And don't use IRQ 9 for Non-PnP ISA cards.
-149
View File
@@ -1,149 +0,0 @@
.\" Copyright (c) 1997, 1998, 1999
.\" Bill Paul <[email protected]>. 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by Bill Paul.
.\" 4. 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 Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
.\" 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.
.\"
.\" $FreeBSD$
.\"
.Dd September 4, 1999
.Dt SIS 4 i386
.Os FreeBSD
.Sh NAME
.Nm sis
.Nd
Silicon Integrated Systems fast ethernet device driver
.Sh SYNOPSIS
.Cd "controller miibus0"
.Cd "device sis0"
.Sh DESCRIPTION
The
.Nm
driver provides support for PCI ethernet adapters and embedded
controllers based on the Silicon Integrated Systems SiS 900
and SiS 7016 fast ethernet controller chips.
.Pp
The SiS 900 is a 100Mbps ethernet MAC and MII-compliant transceiver
in a single package. It uses a bus master DMA and a scatter/gather
descriptor scheme. The SiS 7016 is similar to the SiS 900 except
that it has no internal PHY, requiring instead an external transceiver
to be attached to its MII interface.
The SiS 900 and SiS 7016 both have a 128-bit multicast hash filter
and a single perfect filter entry for the station address.
.Pp
The
.Nm
driver supports the following media types:
.Pp
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
.It autoselect
Enable autoselection of the media type and options.
The user can manually override
the autoselected mode by adding media options to the
.Pa /etc/rc.conf
fine.
.It 10baseT/UTP
Set 10Mbps operation. The
.Ar mediaopt
option can also be used to select either
.Ar full-duplex
or
.Ar half-duplex modes.
.It 100baseTX
Set 100Mbps (fast ethernet) operation. The
.Ar mediaopt
option can also be used to select either
.Ar full-duplex
or
.Ar half-duplex
modes.
.El
.Pp
The
.Nm
driver supports the following media options:
.Pp
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
.It full-duplex
Force full duplex operation
.It half-duplex
Force half duplex operation.
.El
.Pp
For more information on configuring this device, see
.Xr ifconfig 8 .
.Sh DIAGNOSTICS
.Bl -diag
.It "sis%d: couldn't map ports/memory"
A fatal initialization error has occurred.
.It "sis%d: couldn't map interrupt"
A fatal initialization error has occurred.
.It "sis%d: watchdog timeout"
The device has stopped responding to the network, or there is a problem with
the network connection (cable).
.It "sis%d: no memory for rx list"
The driver failed to allocate an mbuf for the receiver ring.
.It "sis%d: no memory for tx list"
The driver failed to allocate an mbuf for the transmitter ring when
allocating a pad buffer or collapsing an mbuf chain into a clusisr.
.It "sis%d: chip is in D3 power state -- setting to D0"
This message applies only to adapters which support power
management. Some operating sysisms place the controller in low power
mode when shutting down, and some PCI BIOSes fail to bring the chip
out of this state before configuring it. The controller loses all of
its PCI configuration in the D3 state, so if the BIOS does not set
it back to full power mode in time, it won't be able to configure it
correctly. The driver tries to detect this condition and bring
the adapter back to the D0 (full power) state, but this may not be
enough to return the driver to a fully operational condition. If
you see this message at boot time and the driver fails to attach
the device as a network interface, you will have to perform second
warm boot to have the device properly configured.
.Pp
Note that this condition only occurs when warm booting from another
operating sysism. If you power down your sysism prior to booting
.Fx ,
the card should be configured correctly.
.El
.Sh SEE ALSO
.Xr arp 4 ,
.Xr netintro 4 ,
.Xr ifconfig 8
.Rs
.%T SiS 900 and SiS 7016 datasheets
.%O http://www.sis.com.tw
.Re
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 3.0 .
.Sh AUTHORS
The
.Nm
driver was written by
.An Bill Paul Aq [email protected] .
-149
View File
@@ -1,149 +0,0 @@
.\" Copyright (c) 1997, 1998, 1999
.\" Bill Paul <[email protected]>. 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by Bill Paul.
.\" 4. 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 Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
.\" 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.
.\"
.\" $FreeBSD$
.\"
.Dd August 21, 1999
.Dt STE 4 i386
.Os FreeBSD
.Sh NAME
.Nm ste
.Nd
Sundance Technologies ST201 fast ethernet device driver
.Sh SYNOPSIS
.Cd "controller miibus0"
.Cd "device ste0"
.Sh DESCRIPTION
The
.Nm
driver provides support for PCI ethernet adapters and embedded
controllers based on the Sundance Technologies ST201 PCI fast
ethernet controller chip. This includes the D-Link DFE-550TX.
.Pp
The Sundance ST201 uses bus master DMA and is designed to be a
3Com Etherlink XL workalike. It uses the same DMA descriptor
structure and is very similar in operation, however its register
layout is different. The ST201 has a 64-bit multicast hash filter
and a single perfect filter entry for the station address. IT
supports both 10 and 100Mbps speeds in either full or half duplex
using an MII transceiver.
.Pp
The
.Nm
driver supports the following media types:
.Pp
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
.It autoselect
Enable autoselection of the media type and options.
The user can manually override
the autoselected mode by adding media options to the
.Pa /etc/rc.conf
fine.
.It 10baseT/UTP
Set 10Mbps operation. The
.Ar mediaopt
option can also be used to select either
.Ar full-duplex
or
.Ar half-duplex modes.
.It 100baseTX
Set 100Mbps (fast ethernet) operation. The
.Ar mediaopt
option can also be used to select either
.Ar full-duplex
or
.Ar half-duplex
modes.
.El
.Pp
The
.Nm
driver supports the following media options:
.Pp
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
.It full-duplex
Force full duplex operation
.It half-duplex
Force half duplex operation.
.El
.Pp
For more information on configuring this device, see
.Xr ifconfig 8 .
.Sh DIAGNOSTICS
.Bl -diag
.It "ste%d: couldn't map ports/memory"
A fatal initialization error has occurred.
.It "ste%d: couldn't map interrupt"
A fatal initialization error has occurred.
.It "ste%d: watchdog timeout"
The device has stopped responding to the network, or there is a problem with
the network connection (cable).
.It "ste%d: no memory for rx list"
The driver failed to allocate an mbuf for the receiver ring.
.It "ste%d: no memory for tx list"
The driver failed to allocate an mbuf for the transmitter ring when
allocating a pad buffer or collapsing an mbuf chain into a cluster.
.It "ste%d: chip is in D3 power state -- setting to D0"
This message applies only to adapters which support power
management. Some operating systems place the controller in low power
mode when shutting down, and some PCI BIOSes fail to bring the chip
out of this state before configuring it. The controller loses all of
its PCI configuration in the D3 state, so if the BIOS does not set
it back to full power mode in time, it won't be able to configure it
correctly. The driver tries to detect this condition and bring
the adapter back to the D0 (full power) state, but this may not be
enough to return the driver to a fully operational condition. If
you see this message at boot time and the driver fails to attach
the device as a network interface, you will have to perform second
warm boot to have the device properly configured.
.Pp
Note that this condition only occurs when warm booting from another
operating system. If you power down your system prior to booting
.Fx ,
the card should be configured correctly.
.El
.Sh SEE ALSO
.Xr arp 4 ,
.Xr netintro 4 ,
.Xr ifconfig 8
.Rs
.%T Sundance ST201 data sheet
.%O http://www.sundanceti.com
.Re
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 3.0 .
.Sh AUTHORS
The
.Nm
driver was written by
.An Bill Paul Aq [email protected] .
-34
View File
@@ -1,34 +0,0 @@
/*-
* Copyright (c) 1998 Nicolas Souchu
* 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.
*
* $FreeBSD$
*
*/
#ifndef _BT848_I2C_H
#define _BT848_I2C_H
extern int bt848_i2c_attach(int, bt848_ptr_t, struct bktr_i2c_softc *);
#endif
-53
View File
@@ -1,53 +0,0 @@
/*
* Copyright (c) 1999 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*---------------------------------------------------------------------------
*
* i4b_rbch_ioctl.h raw B-channel driver interface ioctls
* ------------------------------------------------------
*
* $FreeBSD$
*
* last edit-date: [Fri Jul 9 08:35:07 1999]
*
*---------------------------------------------------------------------------*/
#ifndef _I4B_RBCH_IOCTL_H_
#define _I4B_RBCH_IOCTL_H_
/*---------------------------------------------------------------------------*
* instruct the rbch device to dial the given number
*---------------------------------------------------------------------------*/
typedef char telno_t[TELNO_MAX];
#define I4B_RBCH_DIALOUT _IOW('R', 1, telno_t)
/*---------------------------------------------------------------------------*
* request version and release info from kernel part
*---------------------------------------------------------------------------*/
#define I4B_RBCH_VR_REQ _IOR('R', 2, msg_vr_req_t)
#endif /* _I4B_RBCH_IOCTL_H_ */
+2
View File
@@ -1282,6 +1282,8 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
}
error = 0;
}
#else
wlinit(sc);
#endif
break;
#endif /* MULTICAST */
-1
View File
@@ -1 +0,0 @@
MAINTAINER = [email protected]
-559
View File
@@ -1,559 +0,0 @@
/*
* Copyright (c) 1998, 1999 Bert Driehuis. 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_bsdi_ibc.c - isdn4bsd kernel BSD/OS point to point driver
* -------------------------------------------------------------
*
* $FreeBSD$
*
* last edit-date: [Fri Apr 23 10:27:57 1999]
*
*---------------------------------------------------------------------------*/
#include "ibc.h"
#if NIBC > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/errno.h>
#include <sys/ioccom.h>
#include <sys/ttycom.h>
#include <sys/sockio.h>
#include <sys/kernel.h>
#include <sys/protosw.h>
#include <net/if.h>
#include <net/if_types.h>
#include <net/if_p2p.h>
#include <net/netisr.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
#include <i4b/i4b_ioctl.h>
#include <i4b/i4b_cause.h>
#include <i4b/include/i4b_global.h>
#include <i4b/include/i4b_mbuf.h>
#include <i4b/include/i4b_l3l4.h>
#include <i4b/layer4/i4b_l4.h>
#define IFP2UNIT(ifp) (ifp)->if_unit
#define IOCTL_CMD_T u_long
void ibcattach(void *);
#define IBCACCT 1 /* enable accounting messages */
#define IBCACCTINTVL 2 /* accounting msg interval in secs */
#define PPP_HDRLEN 4 /* 4 octets PPP header length */
struct ibc_softc {
struct p2pcom sc_p2pcom;
int sc_state; /* state of the interface */
call_desc_t *sc_cdp; /* ptr to call descriptor */
#ifdef IBCACCT
int sc_iinb; /* isdn driver # of inbytes */
int sc_ioutb; /* isdn driver # of outbytes */
int sc_inb; /* # of bytes rx'd */
int sc_outb; /* # of bytes tx'd */
int sc_linb; /* last # of bytes rx'd */
int sc_loutb; /* last # of bytes tx'd */
int sc_fn; /* flag, first null acct */
#endif
} ibc_softc[NIBC];
static void ibc_init_linktab(int unit);
static int ibc_start(struct ifnet *ifp);
static int ibc_watchdog(int unit);
static int ibc_mdmctl(struct p2pcom *pp, int flag);
static int ibc_getmdm(struct p2pcom *pp, caddr_t arg);
/* initialized by L4 */
static drvr_link_t ibc_drvr_linktab[NIBC];
static isdn_link_t *isdn_ibc_lt[NIBC];
enum ibc_states {
ST_IDLE, /* initialized, ready, idle */
ST_DIALING, /* dialling out to remote */
ST_CONNECTED, /* connected to remote */
};
int ibcdebug = 0; /* Use bpatch to set this for debug printf's */
#define DBG(x) if (ibcdebug) printf x
/*===========================================================================*
* DEVICE DRIVER ROUTINES
*===========================================================================*/
/*---------------------------------------------------------------------------*
* interface attach routine at kernel boot time
*---------------------------------------------------------------------------*/
void
ibcattach(void *dummy)
{
struct ibc_softc *sc = ibc_softc;
struct ifnet *ifp;
int i;
#ifndef HACK_NO_PSEUDO_ATTACH_MSG
printf("ibc: %d ISDN ibc device(s) attached\n",
NIBC);
#endif
for(i = 0; i < NIBC; sc++, i++) {
ibc_init_linktab(i);
sc->sc_p2pcom.p2p_mdmctl = ibc_mdmctl;
sc->sc_p2pcom.p2p_getmdm = ibc_getmdm;
sc->sc_state = ST_IDLE;
ifp = &sc->sc_p2pcom.p2p_if;
ifp->if_name = "ibc";
ifp->if_next = NULL;
ifp->if_unit = i;
ifp->if_mtu = 1500 /*XXX*/;
ifp->if_baudrate = 64000;
ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT;
ifp->if_type = IFT_ISDNBASIC;
ifp->if_start = ibc_start;
ifp->if_output = 0;
ifp->if_ioctl = p2p_ioctl;
ifp->if_hdrlen = 0;
ifp->if_addrlen = 0;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_ipackets = 0;
ifp->if_ierrors = 0;
ifp->if_opackets = 0;
ifp->if_oerrors = 0;
ifp->if_collisions = 0;
ifp->if_ibytes = 0;
ifp->if_obytes = 0;
ifp->if_imcasts = 0;
ifp->if_omcasts = 0;
ifp->if_iqdrops = 0;
ifp->if_noproto = 0;
#if IBCACCT
ifp->if_timer = 0;
ifp->if_watchdog = ibc_watchdog;
sc->sc_iinb = 0;
sc->sc_ioutb = 0;
sc->sc_inb = 0;
sc->sc_outb = 0;
sc->sc_linb = 0;
sc->sc_loutb = 0;
sc->sc_fn = 1;
#endif
if_attach(ifp);
p2p_attach(&sc->sc_p2pcom);
}
}
static struct mbuf *
p2p_dequeue(struct p2pcom *pp)
{
struct ifqueue *ifq;
struct mbuf *m;
ifq = &pp->p2p_isnd;
m = ifq->ifq_head;
if (m == 0) {
ifq = &pp->p2p_if.if_snd;
m = ifq->ifq_head;
}
if (m == 0)
return 0;
IF_DEQUEUE(ifq, m);
return m;
}
/*---------------------------------------------------------------------------*
* start output to ISDN B-channel
*---------------------------------------------------------------------------*/
static int
ibc_start(struct ifnet *ifp)
{
int unit = IFP2UNIT(ifp);
struct ibc_softc *sc = (struct ibc_softc *)&ibc_softc[unit];
struct p2pcom *pp = &sc->sc_p2pcom;
struct mbuf *m;
int s;
if(sc->sc_state != ST_CONNECTED) {
DBG(("ibc%d: ibc_start called with sc_state=%d\n",
unit, sc->sc_state));
return 0;
}
s = SPLI4B();
if (IF_QFULL(isdn_ibc_lt[unit]->tx_queue)) {
splx(s);
return 0;
}
m = p2p_dequeue(pp);
if (m == NULL) {
splx(s);
return 0;
}
do {
microtime(&ifp->if_lastchange);
IF_ENQUEUE(isdn_ibc_lt[unit]->tx_queue, m);
ifp->if_obytes += m->m_pkthdr.len;
sc->sc_outb += m->m_pkthdr.len;
ifp->if_opackets++;
} while (!IF_QFULL(isdn_ibc_lt[unit]->tx_queue) &&
(m = p2p_dequeue(pp)) != NULL);
isdn_ibc_lt[unit]->bch_tx_start(isdn_ibc_lt[unit]->unit,
isdn_ibc_lt[unit]->channel);
splx(s);
return 0;
}
#ifdef IBCACCT
/*---------------------------------------------------------------------------*
* watchdog routine
*---------------------------------------------------------------------------*/
static int
ibc_watchdog(int unit)
{
struct ibc_softc *sc = &ibc_softc[unit];
struct ifnet *ifp = &sc->sc_p2pcom.p2p_if;
bchan_statistics_t bs;
(*isdn_ibc_lt[unit]->bch_stat)
(isdn_ibc_lt[unit]->unit, isdn_ibc_lt[unit]->channel, &bs);
sc->sc_ioutb += bs.outbytes;
sc->sc_iinb += bs.inbytes;
if((sc->sc_iinb != sc->sc_linb) || (sc->sc_ioutb != sc->sc_loutb) || sc->sc_fn)
{
int ri = (sc->sc_iinb - sc->sc_linb)/IBCACCTINTVL;
int ro = (sc->sc_ioutb - sc->sc_loutb)/IBCACCTINTVL;
if((sc->sc_iinb == sc->sc_linb) && (sc->sc_ioutb == sc->sc_loutb))
sc->sc_fn = 0;
else
sc->sc_fn = 1;
sc->sc_linb = sc->sc_iinb;
sc->sc_loutb = sc->sc_ioutb;
i4b_l4_accounting(BDRV_IBC, unit, ACCT_DURING,
sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_outb, sc->sc_inb);
}
ifp->if_timer = IBCACCTINTVL;
return 0;
}
#endif /* IBCACCT */
/*
*===========================================================================*
* P2P layer interface routines
*===========================================================================*
*/
#if 0
/*---------------------------------------------------------------------------*
* PPP interface phase change
*---------------------------------------------------------------------------*
*/
static void
ibc_state_changed(struct sppp *sp, int new_state)
{
struct ibc_softc *sc = (struct ibc_softc *)sp;
i4b_l4_ifstate_changed(sc->sc_cdp, new_state);
}
/*---------------------------------------------------------------------------*
* PPP control protocol negotiation complete (run ip-up script now)
*---------------------------------------------------------------------------*
*/
static void
ibc_negotiation_complete(struct sppp *sp)
{
struct ibc_softc *sc = (struct ibc_softc *)sp;
i4b_l4_negcomplete(sc->sc_cdp);
}
#endif
/*===========================================================================*
* ISDN INTERFACE ROUTINES
*===========================================================================*/
/*---------------------------------------------------------------------------*
* this routine is called from L4 handler at connect time
*---------------------------------------------------------------------------*/
static void
ibc_connect(int unit, void *cdp)
{
struct ibc_softc *sc = &ibc_softc[unit];
struct ifnet *ifp = &sc->sc_p2pcom.p2p_if;
int s;
DBG(("ibc%d: ibc_connect\n", unit));
s = splimp();
sc->sc_cdp = (call_desc_t *)cdp;
sc->sc_state = ST_CONNECTED;
#if IBCACCT
sc->sc_iinb = 0;
sc->sc_ioutb = 0;
sc->sc_inb = 0;
sc->sc_outb = 0;
sc->sc_linb = 0;
sc->sc_loutb = 0;
ifp->if_timer = IBCACCTINTVL;
#endif
splx(s);
if (sc->sc_p2pcom.p2p_modem)
(*sc->sc_p2pcom.p2p_modem)(&sc->sc_p2pcom, 1);
/* This is a lie... PPP is just starting to negociate :-) */
i4b_l4_negcomplete(sc->sc_cdp);
}
/*---------------------------------------------------------------------------*
* this routine is called from L4 handler at disconnect time
*---------------------------------------------------------------------------*/
static void
ibc_disconnect(int unit, void *cdp)
{
call_desc_t *cd = (call_desc_t *)cdp;
struct ibc_softc *sc = &ibc_softc[unit];
struct ifnet *ifp = &sc->sc_p2pcom.p2p_if;
int s;
DBG(("ibc%d: ibc_disconnect\n", unit));
s = splimp();
/* new stuff to check that the active channel is being closed */
if (cd != sc->sc_cdp)
{
DBG(("ibc_disconnect: ibc%d channel%d not active\n",
cd->driver_unit, cd->channelid));
splx(s);
return;
}
#if IBCACCT
ifp->if_timer = 0;
#endif
i4b_l4_accounting(BDRV_IBC, unit, ACCT_FINAL,
sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_outb, sc->sc_inb);
if (sc->sc_state == ST_CONNECTED)
{
sc->sc_cdp = (call_desc_t *)0;
sc->sc_state = ST_IDLE;
if (sc->sc_p2pcom.p2p_modem)
(*sc->sc_p2pcom.p2p_modem)(&sc->sc_p2pcom, 0);
}
splx(s);
}
/*---------------------------------------------------------------------------*
* this routine is used to give a feedback from userland demon
* in case of dial problems
*---------------------------------------------------------------------------*/
static void
ibc_dialresponse(int unit, int status)
{
DBG(("ibc%d: ibc_dialresponse %d\n", unit, status));
/* struct ibc_softc *sc = &ibc_softc[unit]; */
}
/*---------------------------------------------------------------------------*
* interface up/down
*---------------------------------------------------------------------------*/
static void
ibc_updown(int unit, int updown)
{
DBG(("ibc%d: ibc_updown %d\n", unit, updown));
/* could probably do something useful here */
}
/*---------------------------------------------------------------------------*
* this routine is called from the HSCX interrupt handler
* when a new frame (mbuf) has been received and was put on
* the rx queue.
*---------------------------------------------------------------------------*/
static void
ibc_rx_data_rdy(int unit)
{
struct ibc_softc *sc = &ibc_softc[unit];
struct ifnet *ifp = &sc->sc_p2pcom.p2p_if;
struct mbuf *m, *m0;
char *buf;
int s;
if((m = *isdn_ibc_lt[unit]->rx_mbuf) == NULL)
return;
microtime(&ifp->if_lastchange);
ifp->if_ipackets++;
/* Walk the mbuf chain */
s = splimp();
for (m0 = m; m != 0; m = m->m_next) {
if (m->m_len == 0)
continue;
ifp->if_ibytes += m->m_len;
#if IBCACCT
sc->sc_inb += m->m_len;
#endif
buf = mtod(m, caddr_t);
if ((*sc->sc_p2pcom.p2p_hdrinput)(
&sc->sc_p2pcom, buf, m->m_len) >= 0)
(*sc->sc_p2pcom.p2p_input)(&sc->sc_p2pcom, 0);
}
splx(s);
m_freem(m0);
}
/*---------------------------------------------------------------------------*
* this routine is called from the HSCX interrupt handler
* when the last frame has been sent out and there is no
* further frame (mbuf) in the tx queue.
*---------------------------------------------------------------------------*/
static void
ibc_tx_queue_empty(int unit)
{
ibc_start(&ibc_softc[unit].sc_p2pcom.p2p_if);
}
/*---------------------------------------------------------------------------*
* this routine is called from the HSCX interrupt handler
* each time a packet is received or transmitted. It should
* be used to implement an activity timeout mechanism.
*---------------------------------------------------------------------------*/
static void
ibc_activity(int unit, int rxtx)
{
ibc_softc[unit].sc_cdp->last_active_time = SECOND;
}
/*---------------------------------------------------------------------------*
* return this drivers linktab address
*---------------------------------------------------------------------------*/
drvr_link_t *
ibc_ret_linktab(int unit)
{
return(&ibc_drvr_linktab[unit]);
}
/*---------------------------------------------------------------------------*
* setup the isdn_ibc_lt for this driver
*---------------------------------------------------------------------------*/
void
ibc_set_linktab(int unit, isdn_link_t *ilt)
{
isdn_ibc_lt[unit] = ilt;
}
/*---------------------------------------------------------------------------*
* initialize this drivers linktab
*---------------------------------------------------------------------------*/
static void
ibc_init_linktab(int unit)
{
ibc_drvr_linktab[unit].unit = unit;
ibc_drvr_linktab[unit].bch_rx_data_ready = ibc_rx_data_rdy;
ibc_drvr_linktab[unit].bch_tx_queue_empty = ibc_tx_queue_empty;
ibc_drvr_linktab[unit].bch_activity = ibc_activity;
ibc_drvr_linktab[unit].line_connected = ibc_connect;
ibc_drvr_linktab[unit].line_disconnected = ibc_disconnect;
ibc_drvr_linktab[unit].dial_response = ibc_dialresponse;
ibc_drvr_linktab[unit].updown_ind = ibc_updown;
}
/*===========================================================================*/
static int
ibc_mdmctl(pp, flag)
struct p2pcom *pp;
int flag;
{
register struct ifnet *ifp = &pp->p2p_if;
struct ibc_softc *sc = (struct ibc_softc *)&ibc_softc[ifp->if_unit];
DBG(("ibc%d: ibc_mdmctl called flags=%d\n", IFP2UNIT(ifp), flag));
if (flag == 1 && sc->sc_state == ST_IDLE) {
sc->sc_state = ST_DIALING;
i4b_l4_dialout(BDRV_IBC, IFP2UNIT(ifp));
} else if (flag == 0 && sc->sc_state != ST_IDLE) {
sc->sc_state = ST_IDLE;
i4b_l4_drvrdisc(BDRV_IBC, IFP2UNIT(ifp));
}
return 0;
}
static int
ibc_getmdm(pp, arg)
struct p2pcom *pp;
caddr_t arg;
{
register struct ifnet *ifp = &pp->p2p_if;
struct ibc_softc *sc = (struct ibc_softc *)&ibc_softc[ifp->if_unit];
if (sc->sc_state == ST_CONNECTED)
*(int *)arg = TIOCM_CAR;
else
*(int *)arg = 0;
return 0;
DBG(("ibc%d: ibc_getmdm called ret=%d\n", IFP2UNIT(ifp), *(int *)arg));
}
#endif
-510
View File
@@ -1,510 +0,0 @@
/*
* Copyright (c) 1999 Ari Suutari. All rights reserved.
* Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*---------------------------------------------------------------------------
*
* isic - I4B Siemens ISDN Chipset Driver for Asuscom ISDNlink 128K PnP
* =====================================================================
*
* This driver works with Asuscom ISDNlink 128K PnP ISA adapter,
* which is based on Siemens IPAC chip (my card probes as ASU1690).
* Older Asuscom ISA cards are based on different chipset
* (containing two chips) - for those cards, one might want
* to try the Dynalink driver.
*
* This driver is heavily based on ELSA Quickstep 1000pro PCI
* driver written by Hellmuth Michaelis. Card initialization
* code is modeled after Linux i4l driver written by Karsten
* Keil.
*
* $FreeBSD$
*
* last edit-date: [Mon May 31 20:53:17 EEST 1999]
*
*---------------------------------------------------------------------------*/
#if defined(__FreeBSD__)
#include "isic.h"
#include "opt_i4b.h"
#include "pnp.h"
#else
#define NISIC 1
#define NPNP 1
#endif
#if (NISIC > 0) && (NPNP > 0) && defined(ASUSCOM_IPAC)
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <net/if.h>
#ifdef __FreeBSD__
#if __FreeBSD__ >= 3
#include <sys/ioccom.h>
#else
#include <sys/ioctl.h>
#endif
#include <machine/clock.h>
#include <i386/isa/isa_device.h>
#include <i386/isa/pnp.h>
#else
#include <machine/bus.h>
#include <sys/device.h>
#endif
#ifdef __FreeBSD__
#include <machine/i4b_debug.h>
#include <machine/i4b_ioctl.h>
#else
#include <i4b/i4b_debug.h>
#include <i4b/i4b_ioctl.h>
#endif
#include <i4b/include/i4b_global.h>
#include <i4b/include/i4b_l1l2.h>
#include <i4b/include/i4b_mbuf.h>
#include <i4b/layer1/i4b_l1.h>
#include <i4b/layer1/i4b_isac.h>
#include <i4b/layer1/i4b_hscx.h>
#include <i4b/layer1/i4b_ipac.h>
#ifndef __FreeBSD__
#include <i4b/layer1/pci_isic.h>
#endif
/* masks for register encoded in base addr */
#define ASI_BASE_MASK 0x0ffff
#define ASI_OFF_MASK 0xf0000
/* register id's to be encoded in base addr */
#define ASI_IDISAC 0x00000
#define ASI_IDHSCXA 0x10000
#define ASI_IDHSCXB 0x20000
#define ASI_IDIPAC 0x40000
/* offsets from base address */
#define ASI_OFF_ALE 0x00
#define ASI_OFF_RW 0x01
/*---------------------------------------------------------------------------*
* Asuscom ISDNlink 128K PnP ISAC get fifo routine
*---------------------------------------------------------------------------*/
#ifdef __FreeBSD__
static void
asi_read_fifo(void *buf, const void *base, size_t len)
{
u_int asus_base;
asus_base = ((u_int) base) & ASI_BASE_MASK;
switch (((u_int) base) & ASI_OFF_MASK) {
case ASI_IDHSCXB:
outb(asus_base + ASI_OFF_ALE, IPAC_HSCXB_OFF);
insb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len);
break;
case ASI_IDHSCXA:
outb(asus_base + ASI_OFF_ALE, IPAC_HSCXA_OFF);
insb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len);
break;
case ASI_IDISAC:
outb(asus_base + ASI_OFF_ALE, IPAC_ISAC_OFF);
insb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len);
break;
}
}
#else
static void
asi_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size)
{
bus_space_tag_t t = sc->sc_maps[1].t;
bus_space_handle_t h = sc->sc_maps[1].h;
switch (what) {
case ISIC_WHAT_ISAC:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_ISAC_OFF);
bus_space_read_multi_1(t, h, ASI_OFF_RW, buf, size);
break;
case ISIC_WHAT_HSCXA:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXA_OFF);
bus_space_read_multi_1(t, h, ASI_OFF_RW, buf, size);
break;
case ISIC_WHAT_HSCXB:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXB_OFF);
bus_space_read_multi_1(t, h, ASI_OFF_RW, buf, size);
break;
}
}
#endif
/*---------------------------------------------------------------------------*
* Asuscom ISDNlink 128K PnP ISAC put fifo routine
*---------------------------------------------------------------------------*/
#ifdef __FreeBSD__
static void
asi_write_fifo(void *base, const void *buf, size_t len)
{
u_int asus_base;
asus_base = ((u_int) base) & ASI_BASE_MASK;
switch (((u_int) base) & ASI_OFF_MASK) {
case ASI_IDHSCXB:
outb(asus_base + ASI_OFF_ALE, IPAC_HSCXB_OFF);
outsb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len);
break;
case ASI_IDHSCXA:
outb(asus_base + ASI_OFF_ALE, IPAC_HSCXA_OFF);
outsb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len);
break;
case ASI_IDISAC:
outb(asus_base + ASI_OFF_ALE, IPAC_ISAC_OFF);
outsb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len);
break;
}
}
#else
static void
asi_write_fifo(struct isic_softc *sc,
int what, const void *buf, size_t size)
{
bus_space_tag_t t = sc->sc_maps[1].t;
bus_space_handle_t h = sc->sc_maps[1].h;
switch (what) {
case ISIC_WHAT_ISAC:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_ISAC_OFF);
bus_space_write_multi_1(t, h, ASI_OFF_RW, (u_int8_t*)buf,size);
break;
case ISIC_WHAT_HSCXA:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXA_OFF);
bus_space_write_multi_1(t, h, ASI_OFF_RW, (u_int8_t*)buf,size);
break;
case ISIC_WHAT_HSCXB:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXB_OFF);
bus_space_write_multi_1(t, h, ASI_OFF_RW, (u_int8_t*)buf,size);
break;
}
}
#endif
/*---------------------------------------------------------------------------*
* Asuscom ISDNlink 128K PnP ISAC put register routine
*---------------------------------------------------------------------------*/
#ifdef __FreeBSD__
static void
asi_write_reg(u_char *base, u_int offset, u_int v)
{
u_int asus_base;
asus_base = ((u_int) base) & ASI_BASE_MASK;
switch (((u_int) base) & ASI_OFF_MASK) {
case ASI_IDHSCXB:
outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF));
outb(asus_base + ASI_OFF_RW, (u_char)v);
break;
case ASI_IDHSCXA:
outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF));
outb(asus_base + ASI_OFF_RW, (u_char)v);
break;
case ASI_IDISAC:
outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF));
outb(asus_base + ASI_OFF_RW, (u_char)v);
break;
case ASI_IDIPAC:
outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF));
outb(asus_base + ASI_OFF_RW, (u_char)v);
break;
}
}
#else
static void
asi_write_reg(struct isic_softc *sc,
int what, bus_size_t offs, u_int8_t data)
{
bus_space_tag_t t = sc->sc_maps[1].t;
bus_space_handle_t h = sc->sc_maps[1].h;
switch (what) {
case ISIC_WHAT_ISAC:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_ISAC_OFF+offs);
bus_space_write_1(t, h, ASI_OFF_RW, data);
break;
case ISIC_WHAT_HSCXA:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXA_OFF+offs);
bus_space_write_1(t, h, ASI_OFF_RW, data);
break;
case ISIC_WHAT_HSCXB:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXB_OFF+offs);
bus_space_write_1(t, h, ASI_OFF_RW, data);
break;
case ISIC_WHAT_IPAC:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_IPAC_OFF+offs);
bus_space_write_1(t, h, ASI_OFF_RW, data);
break;
}
}
#endif
/*---------------------------------------------------------------------------*
* Asuscom ISDNlink 128K PnP ISAC get register routine
*---------------------------------------------------------------------------*/
#ifdef __FreeBSD__
static u_char
asi_read_reg(u_char *base, u_int offset)
{
u_int asus_base;
asus_base = ((u_int) base) & ASI_BASE_MASK;
switch (((u_int) base) & ASI_OFF_MASK) {
case ASI_IDHSCXB:
outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF));
return(inb(asus_base + ASI_OFF_RW));
case ASI_IDHSCXA:
outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF));
return(inb(asus_base + ASI_OFF_RW));
case ASI_IDISAC:
outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF));
return(inb(asus_base + ASI_OFF_RW));
case ASI_IDIPAC:
outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF));
return(inb(asus_base + ASI_OFF_RW));
}
return 0; /* NOTREACHED */
}
#else
static u_int8_t
asi_read_reg(struct isic_softc *sc, int what, bus_size_t offs)
{
bus_space_tag_t t = sc->sc_maps[1].t;
bus_space_handle_t h = sc->sc_maps[1].h;
switch (what) {
case ISIC_WHAT_ISAC:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_ISAC_OFF+offs);
return bus_space_read_1(t, h, ASI_OFF_RW);
case ISIC_WHAT_HSCXA:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXA_OFF+offs);
return bus_space_read_1(t, h, ASI_OFF_RW);
case ISIC_WHAT_HSCXB:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXB_OFF+offs);
return bus_space_read_1(t, h, ASI_OFF_RW);
case ISIC_WHAT_IPAC:
bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_IPAC_OFF+offs);
return bus_space_read_1(t, h, ASI_OFF_RW);
}
return 0;
}
#endif
/*---------------------------------------------------------------------------*
* isic_attach_asi - attach for Asuscom ISDNlink 128K PnP
*---------------------------------------------------------------------------*/
#ifdef __FreeBSD__
int
isic_probe_asi(struct isa_device *dev, unsigned int iobase2)
{
struct isic_softc *sc = &isic_sc[dev->id_unit];
/* check max unit range */
if(dev->id_unit >= ISIC_MAXUNIT)
{
printf("isic%d: Error, unit %d >= ISIC_MAXUNIT "
"for Asuscom ISDNlink 128K PnP!\n",
dev->id_unit, dev->id_unit);
return(0);
}
sc->sc_unit = dev->id_unit;
/* setup iobase */
if((dev->id_iobase <= 0) || (dev->id_iobase > 0xffff))
{
printf("isic%d: Error, invalid iobase 0x%x specified "
"for Asuscom ISDNlink 128K PnP\n",
dev->id_unit, iobase2);
return(0);
}
sc->sc_port = dev->id_iobase;
/* setup access routines */
sc->clearirq = NULL;
sc->readreg = asi_read_reg;
sc->writereg = asi_write_reg;
sc->readfifo = asi_read_fifo;
sc->writefifo = asi_write_fifo;
/* setup card type */
sc->sc_cardtyp = CARD_TYPEP_ASUSCOMIPAC;
/* setup IOM bus type */
sc->sc_bustyp = BUS_TYPE_IOM2;
/* setup chip type = IPAC ! */
sc->sc_ipac = 1;
sc->sc_bfifolen = IPAC_BFIFO_LEN;
/* setup ISAC and HSCX base addr */
ISAC_BASE = (caddr_t) ((u_int)dev->id_iobase | ASI_IDISAC);
HSCX_A_BASE = (caddr_t) ((u_int)dev->id_iobase | ASI_IDHSCXA);
HSCX_B_BASE = (caddr_t) ((u_int)dev->id_iobase | ASI_IDHSCXB);
IPAC_BASE = (caddr_t) ((u_int)dev->id_iobase | ASI_IDIPAC);
return (1);
}
int
isic_attach_asi(struct isa_device *dev, unsigned int iobase2)
{
struct isic_softc *sc = &isic_sc[dev->id_unit];
/* enable hscx/isac irq's */
#if 0
/*
* This is for ELSA driver
*/
IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
IPAC_WRITE(IPAC_ACFG, 0); /* outputs are open drain */
IPAC_WRITE(IPAC_AOE, /* aux 5..2 are inputs, 7, 6 outputs */
(IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2));
IPAC_WRITE(IPAC_ATX, 0xff); /* set all output lines high */
outb(dev->id_iobase + 0x4c, 0x41); /* enable card interrupt */
#endif
/*
* This has been taken from Linux driver.
* XXX Figure out bits to use defines as original driver did.
*/
IPAC_WRITE (IPAC_CONF, 0x0);
IPAC_WRITE (IPAC_ACFG, 0xff);
IPAC_WRITE (IPAC_AOE, 0x0);
IPAC_WRITE (IPAC_MASK, 0xc0);
IPAC_WRITE (IPAC_PCFG, 0x12);
return (1);
}
#else /* !FreeBSD */
void
isic_attach_asi(psc, pa)
struct pci_isic_softc *psc;
struct pci_attach_args *pa;
{
struct isic_softc *sc = &psc->sc_isic;
/* setup io mappings */
sc->sc_num_mappings = 2;
MALLOC_MAPS(sc);
sc->sc_maps[0].size = 0;
if (pci_mapreg_map(pa, ASI_PORT0_MAPOFF, PCI_MAPREG_TYPE_IO, 0,
&sc->sc_maps[0].t, &sc->sc_maps[0].h, NULL, NULL)) {
printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
return;
}
sc->sc_maps[1].size = 0;
if (pci_mapreg_map(pa, ASI_PORT1_MAPOFF, PCI_MAPREG_TYPE_IO, 0,
&sc->sc_maps[1].t, &sc->sc_maps[1].h, NULL, NULL)) {
printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
return;
}
/* setup access routines */
sc->clearirq = NULL;
sc->readreg = asi_read_reg;
sc->writereg = asi_write_reg;
sc->readfifo = asi_read_fifo;
sc->writefifo = asi_write_fifo;
/* setup card type */
sc->sc_cardtyp = CARD_TYPEP_ASUSCOMIPAC;
/* setup IOM bus type */
sc->sc_bustyp = BUS_TYPE_IOM2;
/* setup chip type = IPAC ! */
sc->sc_ipac = 1;
sc->sc_bfifolen = IPAC_BFIFO_LEN;
#if 0
/*
* This for ELSA card in original driver.
*/
/* enable hscx/isac irq's */
IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
IPAC_WRITE(IPAC_ACFG, 0); /* outputs are open drain */
IPAC_WRITE(IPAC_AOE, /* aux 5..2 are inputs, 7, 6 outputs */
(IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2));
IPAC_WRITE(IPAC_ATX, 0xff); /* set all output lines high */
bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, 0x4c, 0x41); /* enable card interrupt */
#endif
/*
* This has been taken from Linux driver.
* XXX Figure out bits to use defines as original driver did.
*/
IPAC_WRITE (IPAC_CONF, 0x0);
IPAC_WRITE (IPAC_ACFG, 0xff);
IPAC_WRITE (IPAC_AOE, 0x0);
IPAC_WRITE (IPAC_MASK, 0xc0);
IPAC_WRITE (IPAC_PCFG, 0x12);
}
#endif
#endif /* (NISIC > 0) && defined(ASUSCOM_IPAC) */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-317
View File
@@ -1,317 +0,0 @@
/*
* Copyright (c) 1999 Udo Schweigert. 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.
*
*---------------------------------------------------------------------------
* Based on ELSA Quickstep 1000pro PCI driver (i4b_elsa_qs1p.c)
*---------------------------------------------------------------------------
* In case of trouble please contact Udo Schweigert <ust@cert.siemens.de>
*---------------------------------------------------------------------------
*
* Siemens I-Surf 2.0 PnP specific routines for isic driver
* --------------------------------------------------------
*
* $FreeBSD$
*
* last edit-date: [Mon 14 Jun 16:46:27 CEST 1999]
*
*---------------------------------------------------------------------------*/
#if defined(__FreeBSD__)
#include "isic.h"
#include "opt_i4b.h"
#if NISIC > 0 && defined(SIEMENS_ISURF2)
#include <sys/param.h>
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
#include <sys/ioccom.h>
#else
#include <sys/ioctl.h>
#endif
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <machine/clock.h>
#include <i386/isa/isa_device.h>
#include <sys/socket.h>
#include <net/if.h>
#include <machine/i4b_debug.h>
#include <machine/i4b_ioctl.h>
#include <i4b/include/i4b_global.h>
#include <i4b/include/i4b_l1l2.h>
#include <i4b/include/i4b_mbuf.h>
#include <i4b/layer1/i4b_l1.h>
#include <i4b/layer1/i4b_ipac.h>
#include <i4b/layer1/i4b_isac.h>
#include <i4b/layer1/i4b_hscx.h>
/* masks for register encoded in base addr */
#define SIE_ISURF_BASE_MASK 0x0ffff
#define SIE_ISURF_OFF_MASK 0xf0000
/* register id's to be encoded in base addr */
#define SIE_ISURF_IDISAC 0x00000
#define SIE_ISURF_IDHSCXA 0x10000
#define SIE_ISURF_IDHSCXB 0x20000
#define SIE_ISURF_IDIPAC 0x40000
/* offsets from base address */
#define SIE_ISURF_OFF_ALE 0x00
#define SIE_ISURF_OFF_RW 0x01
/*---------------------------------------------------------------------------*
* Siemens I-Surf 2.0 PnP ISAC get fifo routine
*---------------------------------------------------------------------------*/
static void
siemens_isurf_read_fifo(void *buf, const void *base, size_t len)
{
if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXB)
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_HSCXB_OFF);
insb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (u_char *)buf, (u_int)len);
}
else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXA)
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_HSCXA_OFF);
insb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (u_char *)buf, (u_int)len);
}
else /* if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDISAC) */
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_ISAC_OFF);
insb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (u_char *)buf, (u_int)len);
}
}
/*---------------------------------------------------------------------------*
* Siemens I-Surf 2.0 PnP ISAC put fifo routine
*---------------------------------------------------------------------------*/
static void
siemens_isurf_write_fifo(void *base, const void *buf, size_t len)
{
if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXB)
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_HSCXB_OFF);
outsb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (const u_char *)buf, (u_int)len);
}
else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXA)
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_HSCXA_OFF);
outsb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (const u_char *)buf, (u_int)len);
}
else /* if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDISAC) */
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_ISAC_OFF);
outsb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (const u_char *)buf, (u_int)len);
}
}
/*---------------------------------------------------------------------------*
* Siemens I-Surf 2.0 PnP ISAC put register routine
*---------------------------------------------------------------------------*/
static void
siemens_isurf_write_reg(u_char *base, u_int offset, u_int v)
{
if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXB)
{
outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF));
outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW, (u_char)v);
}
else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXA)
{
outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF));
outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW, (u_char)v);
}
else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDISAC)
{
outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF));
outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW, (u_char)v);
}
else /* IPAC */
{
outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF));
outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW, (u_char)v);
}
}
/*---------------------------------------------------------------------------*
* Siemens I-Surf 2.0 PnP ISAC get register routine
*---------------------------------------------------------------------------*/
static u_char
siemens_isurf_read_reg(u_char *base, u_int offset)
{
if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXB)
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF));
return(inb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW));
}
else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXA)
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF));
return(inb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW));
}
else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDISAC)
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF));
return(inb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW));
}
else /* IPAC */
{
outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF));
return(inb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW));
}
}
/*---------------------------------------------------------------------------*
* isic_probe_siemens_isurf - probe for Siemens I-Surf 2.0 PnP
*---------------------------------------------------------------------------*/
int
isic_probe_siemens_isurf(struct isa_device *dev, unsigned int iobase2)
{
struct isic_softc *sc = &isic_sc[dev->id_unit];
/* check max unit range */
if(dev->id_unit >= ISIC_MAXUNIT)
{
printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Siemens I-Surf 2.0 PnP\n",
dev->id_unit, dev->id_unit);
return(0);
}
sc->sc_unit = dev->id_unit;
/* check IRQ validity */
switch(ffs(dev->id_irq) - 1)
{
case 3:
case 4:
case 5:
case 7:
case 10:
case 11:
case 12:
case 15:
break;
default:
printf("isic%d: Error, invalid IRQ [%d] specified for Siemens I-Surf 2.0 PnP!\n",
dev->id_unit, ffs(dev->id_irq)-1);
return(0);
break;
}
sc->sc_irq = dev->id_irq;
/* check if memory addr specified */
if(dev->id_maddr)
{
printf("isic%d: Error, mem addr 0x%lx specified for Siemens I-Surf 2.0 PnP!\n",
dev->id_unit, (u_long)dev->id_maddr);
return(0);
}
dev->id_msize = 0;
/* check if we got an iobase */
if(!((dev->id_iobase >= 0x100) && (dev->id_iobase <= 0xff0)))
{
printf("isic%d: Error, invalid iobase 0x%x specified for Siemens I-Surf 2.0 PnP!\n",
dev->id_unit, dev->id_iobase);
return(0);
}
sc->sc_port = dev->id_iobase;
/* setup access routines */
sc->clearirq = NULL;
sc->readreg = siemens_isurf_read_reg;
sc->writereg = siemens_isurf_write_reg;
sc->readfifo = siemens_isurf_read_fifo;
sc->writefifo = siemens_isurf_write_fifo;
/* setup card type */
sc->sc_cardtyp = CARD_TYPEP_SIE_ISURF2;
/* setup IOM bus type */
sc->sc_bustyp = BUS_TYPE_IOM2;
/* setup chip type = IPAC ! */
sc->sc_ipac = 1;
sc->sc_bfifolen = IPAC_BFIFO_LEN;
return (1);
}
/*---------------------------------------------------------------------------*
* isic_attach_siemens_isurf - attach for Siemens I-Surf 2.0 PnP
*---------------------------------------------------------------------------*/
int
isic_attach_siemens_isurf(struct isa_device *dev, unsigned int iobase2)
{
struct isic_softc *sc = &isic_sc[dev->id_unit];
/* setup ISAC and HSCX base addr */
ISAC_BASE = (caddr_t) ((u_int)sc->sc_port | SIE_ISURF_IDISAC);
HSCX_A_BASE = (caddr_t) ((u_int)sc->sc_port | SIE_ISURF_IDHSCXA);
HSCX_B_BASE = (caddr_t) ((u_int)sc->sc_port | SIE_ISURF_IDHSCXB);
IPAC_BASE = (caddr_t) ((u_int)sc->sc_port | SIE_ISURF_IDIPAC);
/* enable hscx/isac irq's */
IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
IPAC_WRITE(IPAC_ACFG, 0); /* outputs are open drain */
IPAC_WRITE(IPAC_AOE, /* aux 5..2 are inputs, 7, 6 outputs */
(IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2));
IPAC_WRITE(IPAC_ATX, 0xff); /* set all output lines high */
return(1);
}
#endif /* NISIC > 0 && defined(SIEMENS_ISURF2) */
#endif /* FreeBSD */
-53
View File
@@ -1,53 +0,0 @@
/*
* Copyright (c) 1999 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.
*
*---------------------------------------------------------------------------
*
* pci_isic.h - pci bus frontend for i4b_isic driver
* -------------------------------------------------
*
* $FreeBSD$
*
* last edit-date: [Wed Mar 10 07:22:08 1999]
*
* -mh original implementation
*
*---------------------------------------------------------------------------*/
struct pci_isic_softc {
struct isic_softc sc_isic; /* parent class */
/* PCI-specific goo */
void *sc_ih; /* interrupt handler */
};
extern void isic_attach_Eqs1pp __P((struct pci_isic_softc *psc, struct pci_attach_args *pa));
extern void isic_attach_fritzPci __P((struct pci_isic_softc *psc, struct pci_attach_args *pa));
-666
View File
@@ -1,666 +0,0 @@
/*-
* Copyright (c) 1998, 1999 Nicolas Souchu
* 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.
*
* $FreeBSD$
*
*/
/*
* Power Management support for the Acer M15x3 chipsets
*/
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <machine/clock.h>
#include <machine/bus_pio.h>
#include <machine/bus_memio.h>
#include <machine/bus.h>
#include <pci/pcivar.h>
#include <pci/pcireg.h>
#include <dev/iicbus/iiconf.h>
#include <dev/smbus/smbconf.h>
#include "smbus_if.h"
#include "alpm.h"
#define ALPM_DEBUG(x) if (alpm_debug) (x)
#ifdef DEBUG
static int alpm_debug = 1;
#else
static int alpm_debug = 0;
#endif
#define ACER_M1543_PMU_ID 0x710110b9
/* Uncomment this line to force another I/O base address for SMB */
/* #define ALPM_SMBIO_BASE_ADDR 0x3a80 */
/* I/O registers offsets - the base address is programmed via the
* SMBBA PCI configuration register
*/
#define SMBSTS 0x0 /* SMBus host/slave status register */
#define SMBCMD 0x1 /* SMBus host/slave command register */
#define SMBSTART 0x2 /* start to generate programmed cycle */
#define SMBHADDR 0x3 /* host address register */
#define SMBHDATA 0x4 /* data A register for host controller */
#define SMBHDATB 0x5 /* data B register for host controller */
#define SMBHBLOCK 0x6 /* block register for host controller */
#define SMBHCMD 0x7 /* command register for host controller */
/* SMBSTS masks */
#define TERMINATE 0x80
#define BUS_COLLI 0x40
#define DEVICE_ERR 0x20
#define SMI_I_STS 0x10
#define HST_BSY 0x08
#define IDL_STS 0x04
#define HSTSLV_STS 0x02
#define HSTSLV_BSY 0x01
/* SMBCMD masks */
#define SMB_BLK_CLR 0x80
#define T_OUT_CMD 0x08
#define ABORT_HOST 0x04
/* SMBus commands */
#define SMBQUICK 0x00
#define SMBSRBYTE 0x10 /* send/receive byte */
#define SMBWRBYTE 0x20 /* write/read byte */
#define SMBWRWORD 0x30 /* write/read word */
#define SMBWRBLOCK 0x40 /* write/read block */
/* PCI configuration registers and masks
*/
#define COM 0x4
#define COM_ENABLE_IO 0x1
#define SMBBA 0x14
#define ATPC 0x5b
#define ATPC_SMBCTRL 0x04
#define SMBHSI 0xe0
#define SMBHSI_SLAVE 0x2
#define SMBHSI_HOST 0x1
#define SMBHCBC 0xe2
#define SMBHCBC_CLOCK 0x70
#define SMBCLOCK_149K 0x0
#define SMBCLOCK_74K 0x20
#define SMBCLOCK_37K 0x40
#define SMBCLOCK_223K 0x80
#define SMBCLOCK_111K 0xa0
#define SMBCLOCK_55K 0xc0
struct alpm_data {
int base;
bus_space_tag_t smbst;
bus_space_handle_t smbsh;
pcici_t tag;
};
struct alpm_data alpmdata[NALPM];
struct alsmb_softc {
int base;
device_t smbus;
struct alpm_data *alpm;
};
#define ALPM_SMBINB(alsmb,register) \
(bus_space_read_1(alsmb->alpm->smbst, alsmb->alpm->smbsh, register))
#define ALPM_SMBOUTB(alsmb,register,value) \
(bus_space_write_1(alsmb->alpm->smbst, alsmb->alpm->smbsh, register, value))
static int alsmb_probe(device_t);
static int alsmb_attach(device_t);
static int alsmb_smb_callback(device_t, int, caddr_t *);
static int alsmb_smb_quick(device_t dev, u_char slave, int how);
static int alsmb_smb_sendb(device_t dev, u_char slave, char byte);
static int alsmb_smb_recvb(device_t dev, u_char slave, char *byte);
static int alsmb_smb_writeb(device_t dev, u_char slave, char cmd, char byte);
static int alsmb_smb_readb(device_t dev, u_char slave, char cmd, char *byte);
static int alsmb_smb_writew(device_t dev, u_char slave, char cmd, short word);
static int alsmb_smb_readw(device_t dev, u_char slave, char cmd, short *word);
static int alsmb_smb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf);
static int alsmb_smb_bread(device_t dev, u_char slave, char cmd, u_char count, char *byte);
static devclass_t alsmb_devclass;
static device_method_t alsmb_methods[] = {
/* device interface */
DEVMETHOD(device_probe, alsmb_probe),
DEVMETHOD(device_attach, alsmb_attach),
/* bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
/* smbus interface */
DEVMETHOD(smbus_callback, alsmb_smb_callback),
DEVMETHOD(smbus_quick, alsmb_smb_quick),
DEVMETHOD(smbus_sendb, alsmb_smb_sendb),
DEVMETHOD(smbus_recvb, alsmb_smb_recvb),
DEVMETHOD(smbus_writeb, alsmb_smb_writeb),
DEVMETHOD(smbus_readb, alsmb_smb_readb),
DEVMETHOD(smbus_writew, alsmb_smb_writew),
DEVMETHOD(smbus_readw, alsmb_smb_readw),
DEVMETHOD(smbus_bwrite, alsmb_smb_bwrite),
DEVMETHOD(smbus_bread, alsmb_smb_bread),
{ 0, 0 }
};
static driver_t alsmb_driver = {
"alsmb",
alsmb_methods,
sizeof(struct alsmb_softc),
};
static const char* alpm_pci_probe(pcici_t tag, pcidi_t type);
static void alpm_pci_attach(pcici_t tag, int unit);
static u_long alpm_count;
static struct pci_device alpm_device = {
"alpm",
alpm_pci_probe,
alpm_pci_attach,
&alpm_count
};
COMPAT_PCI_DRIVER (alpm, alpm_device);
static const char*
alpm_pci_probe(pcici_t tag, pcidi_t type)
{
if (type == ACER_M1543_PMU_ID)
return ("AcerLabs M15x3 Power Management Unit");
return ((char *)0);
}
static void
alpm_pci_attach(pcici_t tag, int unit)
{
struct alpm_data *alpm;
u_long l;
if (unit >= NALPM) {
printf("alpm%d: attach: only %d units configured.\n",
unit, NALPM);
return;
}
alpm = &alpmdata[unit];
alpm->tag = tag;
/* Unlock SMBIO base register access */
l = pci_cfgread(tag, ATPC, 1);
pci_cfgwrite(tag, ATPC, l & ~ATPC_SMBCTRL, 1);
if (bootverbose) {
l = pci_cfgread(tag, SMBHSI, 1);
printf("alsmb%d: %s/%s", unit,
(l & SMBHSI_HOST) ? "host":"nohost",
(l & SMBHSI_SLAVE) ? "slave":"noslave");
l = pci_cfgread(tag, SMBHCBC, 1);
switch (l & SMBHCBC_CLOCK) {
case SMBCLOCK_149K:
printf(" 149K");
break;
case SMBCLOCK_74K:
printf(" 74K");
break;
case SMBCLOCK_37K:
printf(" 37K");
break;
case SMBCLOCK_223K:
printf(" 223K");
break;
case SMBCLOCK_111K:
printf(" 111K");
break;
case SMBCLOCK_55K:
printf(" 55K");
break;
}
}
alpm->smbst = I386_BUS_SPACE_IO;
#ifdef ALPM_SMBIO_BASE_ADDR
/* disable I/O */
l = pci_cfgread(tag, COM, 2);
pci_cfgwrite(tag, COM, l & ~COM_ENABLE_IO, 2);
/* set the I/O base address */
pci_cfgwrite(tag, SMBBA, ALPM_SMBIO_BASE_ADDR | 0x1, 4);
/* enable I/O */
pci_cfgwrite(tag, COM, l | COM_ENABLE_IO, 2);
alpm->smbsh = ALPM_SMBIO_BASE_ADDR;
#else
alpm->smbsh = pci_cfgread(tag, SMBBA, 4) & ~0x1;
#endif
if (bootverbose)
printf(" at 0x%x\n", alpm->smbsh);
/* XXX add the I2C interface to the root_bus until pcibus is ready */
device_add_child(root_bus, "alsmb", unit, NULL);
return;
}
/*
* Not a real probe, we know the device exists since the device has
* been added after the successfull pci probe.
*/
static int
alsmb_probe(device_t dev)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
sc->alpm = &alpmdata[device_get_unit(dev)];
device_set_desc(dev, "Aladdin IV/V/Pro2 SMBus controller");
return (0);
}
static int
alsmb_attach(device_t dev)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
/* allocate a new smbus device */
sc->smbus = smbus_alloc_bus(dev);
/* probe and attach the smbus */
device_probe_and_attach(sc->smbus);
return (0);
}
static int
alsmb_smb_callback(device_t dev, int index, caddr_t *data)
{
int error = 0;
switch (index) {
case SMB_REQUEST_BUS:
case SMB_RELEASE_BUS:
/* ok, bus allocation accepted */
break;
default:
error = EINVAL;
}
return (error);
}
static int
alsmb_clear(struct alsmb_softc *sc)
{
ALPM_SMBOUTB(sc, SMBSTS, 0xff);
DELAY(10);
return (0);
}
#if 0
static int
alsmb_abort(struct alsmb_softc *sc)
{
ALPM_SMBOUTB(sc, SMBCMD, T_OUT_CMD | ABORT_HOST);
return (0);
}
#endif
static int
alsmb_idle(struct alsmb_softc *sc)
{
u_char sts;
sts = ALPM_SMBINB(sc, SMBSTS);
ALPM_DEBUG(printf("alpm: idle? STS=0x%x\n", sts));
return (sts & IDL_STS);
}
/*
* Poll the SMBus controller
*/
static int
alsmb_wait(struct alsmb_softc *sc)
{
int count = 10000;
u_char sts;
int error;
/* wait for command to complete and SMBus controller is idle */
while(count--) {
DELAY(10);
sts = ALPM_SMBINB(sc, SMBSTS);
if (sts & SMI_I_STS)
break;
}
ALPM_DEBUG(printf("alpm: STS=0x%x\n", sts));
error = SMB_ENOERR;
if (!count)
error |= SMB_ETIMEOUT;
if (sts & TERMINATE)
error |= SMB_EABORT;
if (sts & BUS_COLLI)
error |= SMB_ENOACK;
if (sts & DEVICE_ERR)
error |= SMB_EBUSERR;
if (error != SMB_ENOERR)
alsmb_clear(sc);
return (error);
}
static int
alsmb_smb_quick(device_t dev, u_char slave, int how)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
int error;
alsmb_clear(sc);
if (!alsmb_idle(sc))
return (EBUSY);
switch (how) {
case SMB_QWRITE:
ALPM_DEBUG(printf("alpm: QWRITE to 0x%x", slave));
ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB);
break;
case SMB_QREAD:
ALPM_DEBUG(printf("alpm: QREAD to 0x%x", slave));
ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB);
break;
default:
panic("%s: unknown QUICK command (%x)!", __FUNCTION__,
how);
}
ALPM_SMBOUTB(sc, SMBCMD, SMBQUICK);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
error = alsmb_wait(sc);
ALPM_DEBUG(printf(", error=0x%x\n", error));
return (error);
}
static int
alsmb_smb_sendb(device_t dev, u_char slave, char byte)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
int error;
alsmb_clear(sc);
if (!alsmb_idle(sc))
return (SMB_EBUSY);
ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB);
ALPM_SMBOUTB(sc, SMBCMD, SMBSRBYTE);
ALPM_SMBOUTB(sc, SMBHDATA, byte);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
error = alsmb_wait(sc);
ALPM_DEBUG(printf("alpm: SENDB to 0x%x, byte=0x%x, error=0x%x\n", slave, byte, error));
return (error);
}
static int
alsmb_smb_recvb(device_t dev, u_char slave, char *byte)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
int error;
alsmb_clear(sc);
if (!alsmb_idle(sc))
return (SMB_EBUSY);
ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB);
ALPM_SMBOUTB(sc, SMBCMD, SMBSRBYTE);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
if ((error = alsmb_wait(sc)) == SMB_ENOERR)
*byte = ALPM_SMBINB(sc, SMBHDATA);
ALPM_DEBUG(printf("alpm: RECVB from 0x%x, byte=0x%x, error=0x%x\n", slave, *byte, error));
return (error);
}
static int
alsmb_smb_writeb(device_t dev, u_char slave, char cmd, char byte)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
int error;
alsmb_clear(sc);
if (!alsmb_idle(sc))
return (SMB_EBUSY);
ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB);
ALPM_SMBOUTB(sc, SMBCMD, SMBWRBYTE);
ALPM_SMBOUTB(sc, SMBHDATA, byte);
ALPM_SMBOUTB(sc, SMBHCMD, cmd);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
error = alsmb_wait(sc);
ALPM_DEBUG(printf("alpm: WRITEB to 0x%x, cmd=0x%x, byte=0x%x, error=0x%x\n", slave, cmd, byte, error));
return (error);
}
static int
alsmb_smb_readb(device_t dev, u_char slave, char cmd, char *byte)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
int error;
alsmb_clear(sc);
if (!alsmb_idle(sc))
return (SMB_EBUSY);
ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB);
ALPM_SMBOUTB(sc, SMBCMD, SMBWRBYTE);
ALPM_SMBOUTB(sc, SMBHCMD, cmd);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
if ((error = alsmb_wait(sc)) == SMB_ENOERR)
*byte = ALPM_SMBINB(sc, SMBHDATA);
ALPM_DEBUG(printf("alpm: READB from 0x%x, cmd=0x%x, byte=0x%x, error=0x%x\n", slave, cmd, *byte, error));
return (error);
}
static int
alsmb_smb_writew(device_t dev, u_char slave, char cmd, short word)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
int error;
alsmb_clear(sc);
if (!alsmb_idle(sc))
return (SMB_EBUSY);
ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB);
ALPM_SMBOUTB(sc, SMBCMD, SMBWRWORD);
ALPM_SMBOUTB(sc, SMBHDATA, word & 0x00ff);
ALPM_SMBOUTB(sc, SMBHDATB, (word & 0xff00) >> 8);
ALPM_SMBOUTB(sc, SMBHCMD, cmd);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
error = alsmb_wait(sc);
ALPM_DEBUG(printf("alpm: WRITEW to 0x%x, cmd=0x%x, word=0x%x, error=0x%x\n", slave, cmd, word, error));
return (error);
}
static int
alsmb_smb_readw(device_t dev, u_char slave, char cmd, short *word)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
int error;
u_char high, low;
alsmb_clear(sc);
if (!alsmb_idle(sc))
return (SMB_EBUSY);
ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB);
ALPM_SMBOUTB(sc, SMBCMD, SMBWRWORD);
ALPM_SMBOUTB(sc, SMBHCMD, cmd);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
if ((error = alsmb_wait(sc)) == SMB_ENOERR) {
low = ALPM_SMBINB(sc, SMBHDATA);
high = ALPM_SMBINB(sc, SMBHDATB);
*word = ((high & 0xff) << 8) | (low & 0xff);
}
ALPM_DEBUG(printf("alpm: READW from 0x%x, cmd=0x%x, word=0x%x, error=0x%x\n", slave, cmd, *word, error));
return (error);
}
static int
alsmb_smb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
u_char remain, len, i;
int error = SMB_ENOERR;
alsmb_clear(sc);
if(!alsmb_idle(sc))
return (SMB_EBUSY);
remain = count;
while (remain) {
len = min(remain, 32);
ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB);
/* set the cmd and reset the
* 32-byte long internal buffer */
ALPM_SMBOUTB(sc, SMBCMD, SMBWRBLOCK | SMB_BLK_CLR);
ALPM_SMBOUTB(sc, SMBHDATA, len);
/* fill the 32-byte internal buffer */
for (i=0; i<len; i++) {
ALPM_SMBOUTB(sc, SMBHBLOCK, buf[count-remain+i]);
DELAY(2);
}
ALPM_SMBOUTB(sc, SMBHCMD, cmd);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
if ((error = alsmb_wait(sc)) != SMB_ENOERR)
goto error;
remain -= len;
}
error:
ALPM_DEBUG(printf("alpm: WRITEBLK to 0x%x, count=0x%x, cmd=0x%x, error=0x%x", slave, count, cmd, error));
return (error);
}
static int
alsmb_smb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf)
{
struct alsmb_softc *sc = (struct alsmb_softc *)device_get_softc(dev);
u_char remain, len, i;
int error = SMB_ENOERR;
alsmb_clear(sc);
if (!alsmb_idle(sc))
return (SMB_EBUSY);
remain = count;
while (remain) {
ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB);
/* set the cmd and reset the
* 32-byte long internal buffer */
ALPM_SMBOUTB(sc, SMBCMD, SMBWRBLOCK | SMB_BLK_CLR);
ALPM_SMBOUTB(sc, SMBHCMD, cmd);
ALPM_SMBOUTB(sc, SMBSTART, 0xff);
if ((error = alsmb_wait(sc)) != SMB_ENOERR)
goto error;
len = ALPM_SMBINB(sc, SMBHDATA);
/* read the 32-byte internal buffer */
for (i=0; i<len; i++) {
buf[count-remain+i] = ALPM_SMBINB(sc, SMBHBLOCK);
DELAY(2);
}
remain -= len;
}
error:
ALPM_DEBUG(printf("alpm: READBLK to 0x%x, count=0x%x, cmd=0x%x, error=0x%x", slave, count, cmd, error));
return (error);
}
DRIVER_MODULE(alsmb, root, alsmb_driver, alsmb_devclass, 0, 0);
-404
View File
@@ -1,404 +0,0 @@
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ee.columbia.edu>. 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Bill Paul.
* 4. 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 Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
* 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.
*
* $FreeBSD$
*/
/*
* Register definitions for the SiS 900 and SiS 7016 chipsets. The
* 7016 is actually an older chip and some of its registers differ
* from the 900, however the core operational registers are the same:
* the differences lie in the OnNow/Wake on LAN stuff which we don't
* use anyway. The 7016 needs an external MII compliant PHY while the
* SiS 900 has one built in. All registers are 32-bits wide.
*/
/* Registers common to SiS 900 and SiS 7016 */
#define SIS_CSR 0x00
#define SIS_CFG 0x04
#define SIS_EECTL 0x08
#define SIS_PCICTL 0x0C
#define SIS_ISR 0x10
#define SIS_IMR 0x14
#define SIS_IER 0x18
#define SIS_PHYCTL 0x1C
#define SIS_TX_LISTPTR 0x20
#define SIS_TX_CFG 0x24
#define SIS_RX_LISTPTR 0x30
#define SIS_RX_CFG 0x34
#define SIS_FLOWCTL 0x38
#define SIS_RXFILT_CTL 0x48
#define SIS_RXFILT_DATA 0x4C
#define SIS_PWRMAN_CTL 0xB0
#define SIS_PWERMAN_WKUP_EVENT 0xB4
#define SIS_WKUP_FRAME_CRC 0xBC
#define SIS_WKUP_FRAME_MASK0 0xC0
#define SIS_WKUP_FRAME_MASKXX 0xEC
/* SiS 7016 specific registers */
#define SIS_SILICON_REV 0x5C
#define SIS_MIB_CTL0 0x60
#define SIS_MIB_CTL1 0x64
#define SIS_MIB_CTL2 0x68
#define SIS_MIB_CTL3 0x6C
#define SIS_MIB 0x80
#define SIS_LINKSTS 0xA0
#define SIS_TIMEUNIT 0xA4
#define SIS_GPIO 0xB8
#define SIS_CSR_TX_ENABLE 0x00000001
#define SIS_CSR_TX_DISABLE 0x00000002
#define SIS_CSR_RX_ENABLE 0x00000004
#define SIS_CSR_RX_DISABLE 0x00000008
#define SIS_CSR_TX_RESET 0x00000010
#define SIS_CSR_RX_RESET 0x00000020
#define SIS_CSR_SOFTINTR 0x00000080
#define SIS_CSR_RESET 0x00000100
#define SIS_CFG_BIGENDIAN 0x00000001
#define SIS_CFG_PERR_DETECT 0x00000008
#define SIS_CFG_DEFER_DISABLE 0x00000010
#define SIS_CFG_OUTOFWIN_TIMER 0x00000020
#define SIS_CFG_SINGLE_BACKOFF 0x00000040
#define SIS_CFG_PCIREQ_ALG 0x00000080
#define SIS_EECTL_DIN 0x00000001
#define SIS_EECTL_DOUT 0x00000002
#define SIS_EECTL_CLK 0x00000004
#define SIS_EECTL_CSEL 0x00000008
#define SIS_EECMD_WRITE 0x140
#define SIS_EECMD_READ 0x180
#define SIS_EECMD_ERASE 0x1c0
#define SIS_EE_NODEADDR 0x8
#define SIS_PCICTL_SRAMADDR 0x0000001F
#define SIS_PCICTL_RAMTSTENB 0x00000020
#define SIS_PCICTL_TXTSTENB 0x00000040
#define SIS_PCICTL_RXTSTENB 0x00000080
#define SIS_PCICTL_BMTSTENB 0x00000200
#define SIS_PCICTL_RAMADDR 0x001F0000
#define SIS_PCICTL_ROMTIME 0x0F000000
#define SIS_PCICTL_DISCTEST 0x40000000
#define SIS_ISR_RX_OK 0x00000001
#define SIS_ISR_RX_DESC_OK 0x00000002
#define SIS_ISR_RX_ERR 0x00000004
#define SIS_ISR_RX_EARLY 0x00000008
#define SIS_ISR_RX_IDLE 0x00000010
#define SIS_ISR_RX_OFLOW 0x00000020
#define SIS_ISR_TX_OK 0x00000040
#define SIS_ISR_TX_DESC_OK 0x00000080
#define SIS_ISR_TX_ERR 0x00000100
#define SIS_ISR_TX_IDLE 0x00000200
#define SIS_ISR_TX_UFLOW 0x00000400
#define SIS_ISR_SOFTINTR 0x00000800
#define SIS_ISR_HIBITS 0x00008000
#define SIS_ISR_RX_FIFO_OFLOW 0x00010000
#define SIS_ISR_TGT_ABRT 0x00100000
#define SIS_ISR_BM_ABRT 0x00200000
#define SIS_ISR_SYSERR 0x00400000
#define SIS_ISR_PARITY_ERR 0x00800000
#define SIS_ISR_RX_RESET_DONE 0x01000000
#define SIS_ISR_TX_RESET_DONE 0x02000000
#define SIS_ISR_TX_PAUSE_START 0x04000000
#define SIS_ISR_TX_PAUSE_DONE 0x08000000
#define SIS_ISR_WAKE_EVENT 0x10000000
#define SIS_IMR_RX_OK 0x00000001
#define SIS_IMR_RX_DESC_OK 0x00000002
#define SIS_IMR_RX_ERR 0x00000004
#define SIS_IMR_RX_EARLY 0x00000008
#define SIS_IMR_RX_IDLE 0x00000010
#define SIS_IMR_RX_OFLOW 0x00000020
#define SIS_IMR_TX_OK 0x00000040
#define SIS_IMR_TX_DESC_OK 0x00000080
#define SIS_IMR_TX_ERR 0x00000100
#define SIS_IMR_TX_IDLE 0x00000200
#define SIS_IMR_TX_UFLOW 0x00000400
#define SIS_IMR_SOFTINTR 0x00000800
#define SIS_IMR_HIBITS 0x00008000
#define SIS_IMR_RX_FIFO_OFLOW 0x00010000
#define SIS_IMR_TGT_ABRT 0x00100000
#define SIS_IMR_BM_ABRT 0x00200000
#define SIS_IMR_SYSERR 0x00400000
#define SIS_IMR_PARITY_ERR 0x00800000
#define SIS_IMR_RX_RESET_DONE 0x01000000
#define SIS_IMR_TX_RESET_DONE 0x02000000
#define SIS_IMR_TX_PAUSE_START 0x04000000
#define SIS_IMR_TX_PAUSE_DONE 0x08000000
#define SIS_IMR_WAKE_EVENT 0x10000000
#define SIS_INTRS \
(SIS_IMR_RX_OFLOW|SIS_IMR_TX_UFLOW|SIS_IMR_TX_OK|\
SIS_IMR_TX_IDLE|SIS_IMR_RX_OK|SIS_IMR_RX_ERR|\
SIS_IMR_SYSERR)
#define SIS_IER_INTRENB 0x00000001
#define SIS_PHYCTL_ACCESS 0x00000010
#define SIS_PHYCTL_OP 0x00000020
#define SIS_PHYCTL_REGADDR 0x000007C0
#define SIS_PHYCTL_PHYADDR 0x0000F800
#define SIS_PHYCTL_PHYDATA 0xFFFF0000
#define SIS_PHYOP_READ 0x00000020
#define SIS_PHYOP_WRITE 0x00000000
#define SIS_TXCFG_DRAIN_THRESH 0x0000003F /* 32-byte units */
#define SIS_TXCFG_FILL_THRESH 0x00003F00 /* 32-byte units */
#define SIS_TXCFG_DMABURST 0x00700000
#define SIS_TXCFG_AUTOPAD 0x10000000
#define SIS_TXCFG_LOOPBK 0x20000000
#define SIS_TXCFG_IGN_HBEAT 0x40000000
#define SIS_TXCFG_IGN_CARR 0x80000000
#define SIS_TXCFG_DRAIN(x) (((x) >> 5) & SIS_TXCFG_DRAIN_THRESH)
#define SIS_TXCFG_FILL(x) ((((x) >> 5) << 8) & SIS_TXCFG_FILL_THRESH)
#define SIS_TXDMA_512BYTES 0x00000000
#define SIS_TXDMA_4BYTES 0x00100000
#define SIS_TXDMA_8BYTES 0x00200000
#define SIS_TXDMA_16BYTES 0x00300000
#define SIS_TXDMA_32BYTES 0x00400000
#define SIS_TXDMA_64BYTES 0x00500000
#define SIS_TXDMA_128BYTES 0x00600000
#define SIS_TXDMA_256BYTES 0x00700000
#define SIS_TXCFG \
(SIS_TXDMA_64BYTES|SIS_TXCFG_AUTOPAD|\
SIS_TXCFG_FILL(64)|SIS_TXCFG_DRAIN(1500))
#define SIS_RXCFG_DRAIN_THRESH 0x0000003E /* 8-byte units */
#define SIS_RXCFG_DMABURST 0x00700000
#define SIS_RXCFG_RX_JABBER 0x08000000
#define SIS_RXCFG_RX_TXPKTS 0x10000000
#define SIS_RXCFG_RX_RUNTS 0x40000000
#define SIS_RXCFG_RX_GIANTS 0x80000000
#define SIS_RXCFG_DRAIN(x) ((((x) >> 3) << 1) & SIS_RXCFG_DRAIN_THRESH)
#define SIS_RXDMA_512BYTES 0x00000000
#define SIS_RXDMA_4BYTES 0x00100000
#define SIS_RXDMA_8BYTES 0x00200000
#define SIS_RXDMA_16BYTES 0x00300000
#define SIS_RXDMA_32BYTES 0x00400000
#define SIS_RXDMA_64BYTES 0x00500000
#define SIS_RXDMA_128BYTES 0x00600000
#define SIS_RXDMA_256BYTES 0x00700000
#define SIS_RXCFG \
(SIS_RXCFG_DRAIN(64)|SIS_RXDMA_256BYTES)
#define SIS_RXFILTCTL_ADDR 0x000F0000
#define SIS_RXFILTCTL_ALLPHYS 0x10000000
#define SIS_RXFILTCTL_ALLMULTI 0x20000000
#define SIS_RXFILTCTL_BROAD 0x40000000
#define SIS_RXFILTCTL_ENABLE 0x80000000
#define SIS_FILTADDR_PAR0 0x00000000
#define SIS_FILTADDR_PAR1 0x00010000
#define SIS_FILTADDR_PAR2 0x00020000
#define SIS_FILTADDR_MAR0 0x00040000
#define SIS_FILTADDR_MAR1 0x00050000
#define SIS_FILTADDR_MAR2 0x00060000
#define SIS_FILTADDR_MAR3 0x00070000
#define SIS_FILTADDR_MAR4 0x00080000
#define SIS_FILTADDR_MAR5 0x00090000
#define SIS_FILTADDR_MAR6 0x000A0000
#define SIS_FILTADDR_MAR7 0x000B0000
/*
* DMA descriptor structures. The first part of the descriptor
* is the hardware descriptor format, which is just three longwords.
* After this, we include some additional structure members for
* use by the driver. Note that for this structure will be a different
* size on the alpha, but that's okay as long as it's a multiple of 4
* bytes in size.
*/
struct sis_desc {
/* SiS hardware descriptor section */
u_int32_t sis_next;
u_int32_t sis_cmdsts;
#define sis_rxstat sis_cmdsts
#define sis_txstat sis_cmdsts
#define sis_ctl sis_cmdsts
u_int32_t sis_ptr;
/* Driver software section */
struct mbuf *sis_mbuf;
struct sis_desc *sis_nextdesc;
};
#define SIS_CMDSTS_BUFLEN 0x00000FFF
#define SIS_CMDSTS_PKT_OK 0x08000000
#define SIS_CMDSTS_CRC 0x10000000
#define SIS_CMDSTS_INTR 0x20000000
#define SIS_CMDSTS_MORE 0x40000000
#define SIS_CMDSTS_OWN 0x80000000
#define SIS_LASTDESC(x) (!((x)->sis_ctl & SIS_CMDSTS_MORE)))
#define SIS_OWNDESC(x) ((x)->sis_ctl & SIS_CMDSTS_OWN)
#define SIS_INC(x, y) (x) = (x + 1) % y
#define SIS_RXBYTES(x) ((x)->sis_ctl & SIS_CMDSTS_BUFLEN)
#define SIS_RXSTAT_COLL 0x00010000
#define SIS_RXSTAT_LOOPBK 0x00020000
#define SIS_RXSTAT_ALIGNERR 0x00040000
#define SIS_RXSTAT_CRCERR 0x00080000
#define SIS_RXSTAT_SYMBOLERR 0x00100000
#define SIS_RXSTAT_RUNT 0x00200000
#define SIS_RXSTAT_GIANT 0x00400000
#define SIS_RXSTAT_DSTCLASS 0x01800000
#define SIS_RXSTAT_OVERRUN 0x02000000
#define SIS_RXSTAT_RX_ABORT 0x04000000
#define SIS_DSTCLASS_REJECT 0x00000000
#define SIS_DSTCLASS_UNICAST 0x00800000
#define SIS_DSTCLASS_MULTICAST 0x01000000
#define SIS_DSTCLASS_BROADCAST 0x02000000
#define SIS_TXSTAT_COLLCNT 0x000F0000
#define SIS_TXSTAT_EXCESSCOLLS 0x00100000
#define SIS_TXSTAT_OUTOFWINCOLL 0x00200000
#define SIS_TXSTAT_EXCESS_DEFER 0x00400000
#define SIS_TXSTAT_DEFERED 0x00800000
#define SIS_TXSTAT_CARR_LOST 0x01000000
#define SIS_TXSTAT_UNDERRUN 0x02000000
#define SIS_TXSTAT_TX_ABORT 0x04000000
#define SIS_RX_LIST_CNT 64
#define SIS_TX_LIST_CNT 128
struct sis_list_data {
struct sis_desc sis_rx_list[SIS_RX_LIST_CNT];
struct sis_desc sis_tx_list[SIS_TX_LIST_CNT];
};
struct sis_ring_data {
int sis_rx_prod;
int sis_tx_prod;
int sis_tx_cons;
int sis_tx_cnt;
};
/*
* SiS PCI vendor ID.
*/
#define SIS_VENDORID 0x1039
/*
* SiS PCI device IDs
*/
#define SIS_DEVICEID_900 0x0900
#define SIS_DEVICEID_7016 0x7016
struct sis_type {
u_int16_t sis_vid;
u_int16_t sis_did;
char *sis_name;
};
#define SIS_TYPE_900 1
#define SIS_TYPE_7016 2
struct sis_softc {
struct arpcom arpcom; /* interface info */
bus_space_handle_t sis_bhandle;
bus_space_tag_t sis_btag;
struct resource *sis_res;
struct resource *sis_irq;
void *sis_intrhand;
device_t sis_miibus;
u_int8_t sis_unit;
u_int8_t sis_type;
struct sis_list_data *sis_ldata;
struct sis_ring_data sis_cdata;
struct callout_handle sis_stat_ch;
};
/*
* register space access macros
*/
#define CSR_WRITE_4(sc, reg, val) \
bus_space_write_4(sc->sis_btag, sc->sis_bhandle, reg, val)
#define CSR_READ_4(sc, reg) \
bus_space_read_4(sc->sis_btag, sc->sis_bhandle, reg)
#define SIS_TIMEOUT 1000
#define ETHER_ALIGN 2
#define SIS_RXLEN 1536
#define SIS_MIN_FRAMELEN 60
/*
* PCI low memory base and low I/O base register, and
* other PCI registers.
*/
#define SIS_PCI_VENDOR_ID 0x00
#define SIS_PCI_DEVICE_ID 0x02
#define SIS_PCI_COMMAND 0x04
#define SIS_PCI_STATUS 0x06
#define SIS_PCI_REVID 0x08
#define SIS_PCI_CLASSCODE 0x09
#define SIS_PCI_CACHELEN 0x0C
#define SIS_PCI_LATENCY_TIMER 0x0D
#define SIS_PCI_HEADER_TYPE 0x0E
#define SIS_PCI_LOIO 0x10
#define SIS_PCI_LOMEM 0x14
#define SIS_PCI_BIOSROM 0x30
#define SIS_PCI_INTLINE 0x3C
#define SIS_PCI_INTPIN 0x3D
#define SIS_PCI_MINGNT 0x3E
#define SIS_PCI_MINLAT 0x0F
#define SIS_PCI_RESETOPT 0x48
#define SIS_PCI_EEPROM_DATA 0x4C
/* power management registers */
#define SIS_PCI_CAPID 0x50 /* 8 bits */
#define SIS_PCI_NEXTPTR 0x51 /* 8 bits */
#define SIS_PCI_PWRMGMTCAP 0x52 /* 16 bits */
#define SIS_PCI_PWRMGMTCTRL 0x54 /* 16 bits */
#define SIS_PSTATE_MASK 0x0003
#define SIS_PSTATE_D0 0x0000
#define SIS_PSTATE_D1 0x0001
#define SIS_PSTATE_D2 0x0002
#define SIS_PSTATE_D3 0x0003
#define SIS_PME_EN 0x0010
#define SIS_PME_STATUS 0x8000
#ifdef __alpha__
#undef vtophys
#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va)
#endif
-77
View File
@@ -1,77 +0,0 @@
/*-
* Copyright (c) 1998, 1999 Takanori Watanabe
* 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.
*
* $FreeBSD$
*/
/*Register Difinition for Intel Chipset with ACPI Support*/
#define PCI_BASE_ADDR_SMB 0x90 /*Where to MAP IO*/
#define PCI_BASE_ADDR_PM 0x40
#define PCI_HST_CFG_SMB 0xd2 /*Host Configuration*/
#define PCI_INTR_SMB_SMI 0
#define PCI_INTR_SMB_IRQ9 8
#define PCI_INTR_SMB_ENABLE 1
#define PCI_SLV_CMD_SMB 0xd3 /*SLAVE COMMAND*/
#define PCI_SLV_SDW_SMB_1 0xd4 /*SLAVE SHADOW PORT 1*/
#define PCI_SLV_SDW_SMB_2 0xd5 /*SLAVE SHADOW PORT 2*/
#define PCI_REVID_SMB 0xd6
#define LSB 0x1
#define PIIX4_SMBHSTSTS 0x00
#define PIIX4_SMBHSTSTAT_BUSY (1<<0)
#define PIIX4_SMBHSTSTAT_INTR (1<<1)
#define PIIX4_SMBHSTSTAT_ERR (1<<2)
#define PIIX4_SMBHSTSTAT_BUSC (1<<3)
#define PIIX4_SMBHSTSTAT_FAIL (1<<4)
#define PIIX4_SMBSLVSTS 0x01
#define PIIX4_SMBSLVSTS_ALART (1<<5)
#define PIIX4_SMBSLVSTS_SDW2 (1<<4)
#define PIIX4_SMBSLVSTS_SDW1 (1<<3)
#define PIIX4_SMBSLVSTS_SLV (1<<2)
#define PIIX4_SMBSLVSTS_BUSY (1<<0)
#define PIIX4_SMBHSTCNT 0x02
#define PIIX4_SMBHSTCNT_START (1<<6)
#define PIIX4_SMBHSTCNT_PROT_QUICK 0
#define PIIX4_SMBHSTCNT_PROT_BYTE (1<<2)
#define PIIX4_SMBHSTCNT_PROT_BDATA (2<<2)
#define PIIX4_SMBHSTCNT_PROT_WDATA (3<<2)
#define PIIX4_SMBHSTCNT_PROT_BLOCK (5<<2)
#define SMBBLOCKTRANS_MAX 32
#define PIIX4_SMBHSTCNT_KILL (1<<1)
#define PIIX4_SMBHSTCNT_INTREN (1)
#define PIIX4_SMBHSTCMD 0x03
#define PIIX4_SMBHSTADD 0x04
#define PIIX4_SMBHSTDAT0 0x05
#define PIIX4_SMBHSTDAT1 0x06
#define PIIX4_SMBBLKDAT 0x07
#define PIIX4_SMBSLVCNT 0x08
#define PIIX4_SMBSLVCNT_ALTEN (1<<3)
#define PIIX4_SMBSLVCNT_SD2EN (1<<2)
#define PIIX4_SMBSLVCNT_SD1EN (1<<1)
#define PIIX4_SMBSLVCNT_SLVEN (1)
#define PIIX4_SMBSLVCMD 0x09
#define PIIX4_SMBSLVEVT 0x0a
#define PIIX4_SMBSLVDAT 0x0c
/*This is SMBus alart response address*/
#define SMBALTRESP 0x18
-15
View File
@@ -1,15 +0,0 @@
#---------------------------------------------------------------------------
#
# $FreeBSD$
#
# last edit-date: [Thu May 20 12:04:05 1999]
#
#---------------------------------------------------------------------------
PROG = dtmfdecode
SRC = dtmfdecode.c
#LDADD += -lm
CFLAGS += -Wall -g -DDEBUG
MAN1 = dtmfdecode.1
.include <bsd.prog.mk>
-64
View File
@@ -1,64 +0,0 @@
.\"
.\" Copyright (c) 1999 Hellmuth Michaelis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.\" last edit-date: [Mon Apr 26 13:42:15 1999]
.\"
.\"
.Dd February, 15 1999
.Dt DTMFDECODE 1
.Os
.Sh NAME
.Nm dtmfdecode
.Nd decodes DTMF tones from A-law audio data
.Sh SYNOPSIS
.Nm
.Sh DESCRIPTION
.Nm dtmfdecode
is part of the isdn4bsd package and is used to detect DTMF tones in the
audio stream.
.Pp
It reads audio G.711 A-Law coded data from stdin and outputs the detected
numbers values as ASCII charcters to stdout.
.Pp
The detector is implemented as 8 narrow band-pass filters realized with
an integer double-cross recursive algorithm. Various ad-hoc methods are
employed to provide hysteresis and anti-bounce for the detected signals.
.Sh EXAMPLES
The command:
.Bd -literal -offset indent
dtmfdecode < beep.al
.Ed
.Pp
will print a "1" to stdout.
.Sh STANDARDS
ITU Recommendations G.711
.Sh AUTHORS
The
.Nm
utility was written by
.An Poul-Henning Kamp Aq [email protected] .
This man page was written by
.An Hellmuth Michaelis Aq [email protected] .
-150
View File
@@ -1,150 +0,0 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $FreeBSD$
*
* Extract DTMF signalling from ISDN4BSD A-law coded audio data
*
* A-Law to linear conversion from the sox package.
*
*/
#include <stdio.h>
#include <math.h>
/* Integer math scaling factor */
#define FSC (1<<12)
/* Alaw parameters */
#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
#define QUANT_MASK (0xf) /* Quantization field mask. */
#define SEG_SHIFT (4) /* Left shift for segment number. */
#define SEG_MASK (0x70) /* Segment field mask. */
static int
alaw2linear(a_val)
unsigned char a_val;
{
int t;
int seg;
a_val ^= 0x55;
t = (a_val & QUANT_MASK) << 4;
seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
switch (seg) {
case 0:
t += 8;
break;
case 1:
t += 0x108;
break;
default:
t += 0x108;
t <<= seg - 1;
}
return ((a_val & SIGN_BIT) ? t : -t);
}
#ifdef USE_COS
/* The frequencies we're trying to detect */
static int dtmf[8] = {697, 770, 852, 941, 1209, 1336, 1477, 1633};
#else
/* precalculated: p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0) * FSC) */
static int p1[8] = {-3497, -3369, -3212, -3027, -2384, -2040, -1635, -1164};
#endif
/* This is the Q of the filter (pole radius) */
#define POLRAD .99
#define P2 ((int)(POLRAD*POLRAD*FSC))
int
main(int argc, char **argv)
{
int i, kk, t, nn, s, so, ia;
int x, c, d, f, h[8], k[8], n, y[8];
#ifdef USE_COS
int p1[8];
#endif
int alaw[256];
char key[256];
for (kk = 0; kk < 8; kk++) {
y[kk] = h[kk] = k[kk] = 0;
#ifdef USE_COS
p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0) * FSC);
#endif
}
for (i = 0; i < 256; i++) {
key[i] = '?';
alaw[i] = alaw2linear(i) / (32768/FSC);
}
/* We encode the tones in 8 bits, translate those to symbol */
key[0x00] = '\0';
key[0x11] = '1'; key[0x12] = '4'; key[0x14] = '7'; key[0x18] = '*';
key[0x21] = '2'; key[0x22] = '5'; key[0x24] = '8'; key[0x28] = '0';
key[0x41] = '3'; key[0x42] = '6'; key[0x44] = '9'; key[0x48] = '#';
key[0x81] = 'A'; key[0x82] = 'B'; key[0x84] = 'C'; key[0x88] = 'D';
nn = 0;
ia = 0;
so = 0;
t = 0;
while ((i = getchar()) != EOF)
{
t++;
/* Convert to our format */
x = alaw[i];
/* Input amplitude */
if (x > 0)
ia += (x - ia) / 128;
else
ia += (-x - ia) / 128;
/* For each tone */
s = 0;
for(kk = 0; kk < 8; kk++) {
/* Turn the crank */
c = (P2 * (x - k[kk])) / FSC;
d = x + c;
f = (p1[kk] * (d - h[kk])) / FSC;
n = x - k[kk] - c;
k[kk] = h[kk] + f;
h[kk] = f + d;
/* Detect and Average */
if (n > 0)
y[kk] += (n - y[kk]) / 64;
else
y[kk] += (-n - y[kk]) / 64;
/* Threshold */
if (y[kk] > FSC/10 && y[kk] > ia)
s |= 1 << kk;
}
/* Hysteresis and noise supressor */
if (s != so) {
/* printf("x %d %x -> %x\n",t,so, s); */
nn = 0;
so = s;
} else if (nn++ == 520 && key[s]) {
putchar(key[s]);
/* printf(" %d %x\n",t,s); */
}
}
putchar('\n');
return (0);
}
-14
View File
@@ -1,14 +0,0 @@
#---------------------------------------------------------------------------
#
# $FreeBSD$
#
# last edit-date: [Thu May 20 11:58:43 1999]
#
#---------------------------------------------------------------------------
PROG = g711conv
SRC = g711conv.c
CFLAGS += -Wall -g
MAN1 = g711conv.1
.include <bsd.prog.mk>
-96
View File
@@ -1,96 +0,0 @@
.\"
.\" Copyright (c) 1999 Hellmuth Michaelis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.\" last edit-date: [Mon Mar 15 16:17:23 1999]
.\"
.Dd March 15, 1999
.Dt G711CONV 1
.Os
.Sh NAME
.Nm g711conv
.Nd conversions according to G.711
.Sh SYNOPSIS
.Nm
.Op Fl a
.Op Fl u
.Op Fl P
.Op Fl A
.Op Fl R
.Sh DESCRIPTION
.Nm g711conv
is part of the isdn4bsd package and is used to convert between the A-Law and
u-law formats as specified in ITU G.711. It is based on a freely available
and freely usable reference implementation done by Sun Microsystems, Inc.
.Pp
The following options are available:
.Bl -tag -width Ds
.It Fl a
Convert A-law to u-law
.It Fl u
Convert u-law to A-law
.It Fl r
Reverse bits before conversion
.It Fl R
Reverse bits after conversion
.It Fl P
Print the resulting conversion tables (as C-source) to stdout instead of
doing the actual conversion.
.El
.Pp
.Sh STANDARDS
A-Law and u-Law conversions are specified in ITU Recommendation G.711.
.Pp
The reference implementation done by Sun Microsystems, Inc. is available
from http://www.itu.int/itudoc/itu-t/rec/g/g700-799/refimpl.txt
.Pp
.Sh EXAMPLES
The command:
.Bd -literal -offset indent
g711conv -P -a
.Ed
.Pp
prints out the A-law to u-law conversion table as C-source to stdout.
.Pp
The command:
.Bd -literal -offset indent
cat max_headroom.ul | g711conv -u -R > /dev/i4btel0
.Ed
.Pp
converts the u-law coded voice of Max Headroom to A-law, reverses the
bits of the result and moves that to an active isdn4bsd telephone connection.
.Pp
.Sh AUTHORS
The
.Nm
utility and this manpage were written by
.An Hellmuth Michaelis Aq [email protected]
based on the G.711 conversion reference code written by Sun Microsystems,
Inc. and code contributed to isdn4bsd by
.An Stefan Bethke .
-304
View File
@@ -1,304 +0,0 @@
/*
* Copyright (c) 1999 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* ---
*
* The A-law to u-law and u-law to A-law conversion routines and tables
* were taken from the G.711 reference implementation from Sun and freely
* available as http://www.itu.int/itudoc/itu-t/rec/g/g700-799/refimpl.txt.
*
* Therefore for that part of the code, the following restrictions apply:
*
*
* This source code is a product of Sun Microsystems, Inc. and is provided
* for unrestricted use. Users may copy or modify this source code without
* charge.
*
* SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
* THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
*
* Sun source code is provided with no support and without any obligation on
* the part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
*
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
* OR ANY PART THEREOF.
*
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
*
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*
* ---
*
* The bitreverse table was contributed by Stefan Bethke.
*
*---------------------------------------------------------------------------
*
* A-law / u-law conversions as specified in G.711
* -----------------------------------------------
*
* last edit-date: [Mon Apr 26 14:00:31 1999]
*
* $FreeBSD$
*
*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <unistd.h>
#include <machine/i4b_ioctl.h>
/* copy from CCITT G.711 specifications */
/* u- to A-law conversions */
unsigned char _u2a[128] = {
1, 1, 2, 2, 3, 3, 4, 4,
5, 5, 6, 6, 7, 7, 8, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24,
25, 27, 29, 31, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44,
46, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, 62,
64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79,
81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 91, 92, 93, 94, 95, 96,
97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120,
121, 122, 123, 124, 125, 126, 127, 128
};
/* A- to u-law conversions */
unsigned char _a2u[128] = {
1, 3, 5, 7, 9, 11, 13, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,
32, 32, 33, 33, 34, 34, 35, 35,
36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 48, 49, 49,
50, 51, 52, 53, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, 64,
65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 79,
80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 123, 124, 125, 126, 127
};
/* reverse bits (7->0, 6->1, 5->2 etc) for tx to / rx from ISDN */
unsigned char bitreverse[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
/* A-law to u-law conversion */
unsigned char alaw2ulaw(unsigned char aval)
{
aval &= 0xff;
return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) :
(0x7F ^ _a2u[aval ^ 0x55]));
}
/* u-law to A-law conversion */
unsigned char ulaw2alaw(unsigned char uval)
{
uval &= 0xff;
return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) :
(0x55 ^ (_u2a[0x7F ^ uval] - 1)));
}
void
usage(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "g711conv - do conversions according to ITU G.711, (version %d.%d.%d)\n",VERSION, REL, STEP);
fprintf(stderr, "usage: g711conv -a -r -R -u -P\n");
fprintf(stderr, " -a A-law to u-law conversion\n");
fprintf(stderr, " -r reverse bits before conversion\n");
fprintf(stderr, " -R reverse bits after conversion\n");
fprintf(stderr, " -u u-law to A-law conversion\n");
fprintf(stderr, " -P print conversion table as C source\n");
fprintf(stderr, "\n");
exit(1);
}
int
main(int argc, char **argv)
{
int i;
int c;
int opt_a = 0;
int opt_u = 0;
int opt_r = 0;
int opt_P = 0;
int opt_R = 0;
unsigned char uc;
while ((c = getopt(argc, argv, "aurPR?")) != -1)
{
switch(c)
{
case 'a':
opt_a = 1;
break;
case 'u':
opt_u = 1;
break;
case 'r':
opt_r = 1;
break;
case 'R':
opt_R = 1;
break;
case 'P':
opt_P = 1;
break;
case '?':
default:
usage();
break;
}
}
if((opt_a + opt_u) > 1)
usage();
if(opt_P)
{
printf("\n/* ");
if((opt_a + opt_u) == 0)
printf("No Conversion");
if(opt_a)
printf("A-law to u-law conversion");
if(opt_u)
printf("u-law to A-law conversion");
if(opt_r)
printf(", reverse bits BEFORE conversion");
if(opt_R)
printf(", reverse bits AFTER conversion");
if(opt_a)
{
printf(" */\n\nunsigned char a2u_tab[256] = {");
}
else if(opt_u)
{
printf(" */\n\nunsigned char u2a_tab[256] = {");
}
else
{
printf(" */\n\nunsigned char table[256] = {");
}
for(i=0; i < 256; i++)
{
uc = i;
if(!(i % 8))
printf("\n/* %02x */\t", i);
if(opt_r)
uc = bitreverse[uc];
if(opt_u)
uc = ulaw2alaw(uc);
if(opt_a)
uc = alaw2ulaw(uc);
if(opt_R)
uc = bitreverse[uc];
if(i == 255)
printf("0x%02x", uc);
else
printf("0x%02x, ", uc);
}
printf("\n};\n");
}
else
{
unsigned char ib[1];
while(fread(ib, 1, 1, stdin) == 1)
{
if(opt_r)
ib[0] = bitreverse[ib[0]];
if(opt_u)
ib[0] = ulaw2alaw(ib[0]);
if(opt_a)
ib[0] = alaw2ulaw(ib[0]);
if(opt_R)
ib[0] = bitreverse[ib[0]];
fwrite(ib, 1, 1, stdout);
}
}
return(0);
}
/* EOF */
-682
View File
@@ -1,682 +0,0 @@
/*-
* Copyright (c) 1983, 1991, 1993, 1994
* The Regents of the University of California. 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.
*
* $FreeBSD$
*
*/
#include <sys/filio.h>
#include <sys/ioccom.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/ucred.h>
#include <sys/uio.h>
#include <sys/utsname.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <syslog.h>
#include <unistd.h>
#include "inetd.h"
extern int debug;
extern struct servtab *servtab;
char ring[128];
char *endring;
int check_loop __P((struct sockaddr_in *, struct servtab *sep));
void inetd_setproctitle __P((char *, int));
struct biltin biltins[] = {
/* Echo received data */
{ "echo", SOCK_STREAM, 1, -1, echo_stream },
{ "echo", SOCK_DGRAM, 0, 1, echo_dg },
/* Internet /dev/null */
{ "discard", SOCK_STREAM, 1, -1, discard_stream },
{ "discard", SOCK_DGRAM, 0, 1, discard_dg },
/* Return 32 bit time since 1970 */
{ "time", SOCK_STREAM, 0, -1, machtime_stream },
{ "time", SOCK_DGRAM, 0, 1, machtime_dg },
/* Return human-readable time */
{ "daytime", SOCK_STREAM, 0, -1, daytime_stream },
{ "daytime", SOCK_DGRAM, 0, 1, daytime_dg },
/* Familiar character generator */
{ "chargen", SOCK_STREAM, 1, -1, chargen_stream },
{ "chargen", SOCK_DGRAM, 0, 1, chargen_dg },
{ "tcpmux", SOCK_STREAM, 1, -1, (void (*)())tcpmux },
{ "auth", SOCK_STREAM, 1, -1, ident_stream },
{ NULL }
};
/*
* RFC864 Character Generator Protocol. Generates character data without
* any regard for input.
*/
void
initring()
{
int i;
endring = ring;
for (i = 0; i <= 128; ++i)
if (isprint(i))
*endring++ = i;
}
/* ARGSUSED */
void
chargen_dg(s, sep) /* Character generator */
int s;
struct servtab *sep;
{
struct sockaddr_in sin;
static char *rs;
int len, size;
char text[LINESIZ+2];
if (endring == 0) {
initring();
rs = ring;
}
size = sizeof(sin);
if (recvfrom(s, text, sizeof(text), 0,
(struct sockaddr *)&sin, &size) < 0)
return;
if (check_loop(&sin, sep))
return;
if ((len = endring - rs) >= LINESIZ)
memmove(text, rs, LINESIZ);
else {
memmove(text, rs, len);
memmove(text + len, ring, LINESIZ - len);
}
if (++rs == endring)
rs = ring;
text[LINESIZ] = '\r';
text[LINESIZ + 1] = '\n';
(void) sendto(s, text, sizeof(text), 0,
(struct sockaddr *)&sin, sizeof(sin));
}
/* ARGSUSED */
void
chargen_stream(s, sep) /* Character generator */
int s;
struct servtab *sep;
{
int len;
char *rs, text[LINESIZ+2];
inetd_setproctitle(sep->se_service, s);
if (!endring) {
initring();
rs = ring;
}
text[LINESIZ] = '\r';
text[LINESIZ + 1] = '\n';
for (rs = ring;;) {
if ((len = endring - rs) >= LINESIZ)
memmove(text, rs, LINESIZ);
else {
memmove(text, rs, len);
memmove(text + len, ring, LINESIZ - len);
}
if (++rs == endring)
rs = ring;
if (write(s, text, sizeof(text)) != sizeof(text))
break;
}
exit(0);
}
/*
* RFC867 Daytime Protocol. Sends the current date and time as an ascii
* character string without any regard for input.
*/
/* ARGSUSED */
void
daytime_dg(s, sep) /* Return human-readable time of day */
int s;
struct servtab *sep;
{
char buffer[256];
time_t clock;
struct sockaddr_in sin;
int size;
clock = time((time_t *) 0);
size = sizeof(sin);
if (recvfrom(s, buffer, sizeof(buffer), 0,
(struct sockaddr *)&sin, &size) < 0)
return;
if (check_loop(&sin, sep))
return;
(void) sprintf(buffer, "%.24s\r\n", ctime(&clock));
(void) sendto(s, buffer, strlen(buffer), 0,
(struct sockaddr *)&sin, sizeof(sin));
}
/* ARGSUSED */
void
daytime_stream(s, sep) /* Return human-readable time of day */
int s;
struct servtab *sep;
{
char buffer[256];
time_t clock;
clock = time((time_t *) 0);
(void) sprintf(buffer, "%.24s\r\n", ctime(&clock));
(void) write(s, buffer, strlen(buffer));
}
/*
* RFC863 Discard Protocol. Any data received is thrown away and no response
* is sent.
*/
/* ARGSUSED */
void
discard_dg(s, sep) /* Discard service -- ignore data */
int s;
struct servtab *sep;
{
char buffer[BUFSIZE];
(void) read(s, buffer, sizeof(buffer));
}
/* ARGSUSED */
void
discard_stream(s, sep) /* Discard service -- ignore data */
int s;
struct servtab *sep;
{
int ret;
char buffer[BUFSIZE];
inetd_setproctitle(sep->se_service, s);
while (1) {
while ((ret = read(s, buffer, sizeof(buffer))) > 0)
;
if (ret == 0 || errno != EINTR)
break;
}
exit(0);
}
/*
* RFC862 Echo Protocol. Any data received is sent back to the sender as
* received.
*/
/* ARGSUSED */
void
echo_dg(s, sep) /* Echo service -- echo data back */
int s;
struct servtab *sep;
{
char buffer[BUFSIZE];
int i, size;
struct sockaddr_in sin;
size = sizeof(sin);
if ((i = recvfrom(s, buffer, sizeof(buffer), 0,
(struct sockaddr *)&sin, &size)) < 0)
return;
if (check_loop(&sin, sep))
return;
(void) sendto(s, buffer, i, 0, (struct sockaddr *)&sin,
sizeof(sin));
}
/* ARGSUSED */
void
echo_stream(s, sep) /* Echo service -- echo data back */
int s;
struct servtab *sep;
{
char buffer[BUFSIZE];
int i;
inetd_setproctitle(sep->se_service, s);
while ((i = read(s, buffer, sizeof(buffer))) > 0 &&
write(s, buffer, i) > 0)
;
exit(0);
}
/*
* RFC1413 Identification Protocol. Given a TCP port number pair, return a
* character string which identifies the owner of that connection on the
* server's system. Extended to allow for ~/.fakeid support and ~/.noident
* support.
*/
/* ARGSUSED */
void
iderror(lport, fport, s, er) /* Generic ident_stream error-sending func */
int lport, fport, s, er;
{
char *p;
asprintf(&p, "%d , %d : ERROR : %s\r\n", lport, fport,
er == -1 ? "HIDDEN-USER" : er ? strerror(er) : "UNKNOWN-ERROR");
if (p == NULL) {
syslog(LOG_ERR, "asprintf: %m");
exit(EX_OSERR);
}
write(s, p, strlen(p));
free(p);
exit(0);
}
/* ARGSUSED */
void
ident_stream(s, sep) /* Ident service (AKA "auth") */
int s;
struct servtab *sep;
{
struct utsname un;
struct stat sb;
struct sockaddr_in sin[2];
struct ucred uc;
struct timeval tv = {
10,
0
};
struct passwd *pw;
fd_set fdset;
char buf[BUFSIZE], *cp = NULL, *p, **av, *osname = NULL;
int len, c, fflag = 0, nflag = 0, rflag = 0, argc = 0;
u_short lport, fport;
inetd_setproctitle(sep->se_service, s);
/*
* Reset getopt() since we are a fork() but not an exec() from
* a parent which used getopt() already.
*/
optind = 1;
optreset = 1;
/*
* Take the internal argument vector and count it out to make an
* argument count for getopt. This can be used for any internal
* service to read arguments and use getopt() easily.
*/
for (av = sep->se_argv; *av; av++)
argc++;
if (argc) {
int sec, usec;
while ((c = getopt(argc, sep->se_argv, "fno:rt:")) != -1)
switch (c) {
case 'f':
fflag = 1;
break;
case 'n':
nflag = 1;
break;
case 'o':
osname = optarg;
break;
case 'r':
rflag = 1;
break;
case 't':
switch (sscanf(optarg, "%d.%d", &sec, &usec)) {
case 2:
tv.tv_usec = usec;
case 1:
tv.tv_sec = sec;
break;
default:
if (debug)
warnx("bad -t argument");
break;
}
break;
default:
break;
}
}
if (osname == NULL) {
if (uname(&un) == -1)
iderror(0, 0, s, errno);
osname = un.sysname;
}
len = sizeof(sin[0]);
if (getsockname(s, (struct sockaddr *)&sin[0], &len) == -1)
iderror(0, 0, s, errno);
len = sizeof(sin[1]);
if (getpeername(s, (struct sockaddr *)&sin[1], &len) == -1)
iderror(0, 0, s, errno);
/*
* We're going to prepare for and execute reception of a
* packet of data from the user. The data is in the format
* "local_port , foreign_port\r\n" (with local being the
* server's port and foreign being the client's.)
*/
FD_ZERO(&fdset);
FD_SET(s, &fdset);
if (select(s + 1, &fdset, NULL, NULL, &tv) == -1)
iderror(0, 0, s, errno);
if (ioctl(s, FIONREAD, &len) == -1)
iderror(0, 0, s, errno);
if (len >= sizeof(buf))
len = sizeof(buf) - 1;
len = read(s, buf, len);
if (len == -1)
iderror(0, 0, s, errno);
buf[len] = '\0';
if (sscanf(buf, "%hu , %hu", &lport, &fport) != 2)
iderror(0, 0, s, 0);
if (!rflag) /* Send HIDDEN-USER immediately if not "real" */
iderror(lport, fport, s, -1);
/*
* We take the input and construct an array of two sockaddr_ins
* which contain the local address information and foreign
* address information, respectively, used to look up the
* credentials for the socket (which are returned by the
* sysctl "net.inet.tcp.getcred" when we call it.) The
* arrays have been filled in above via get{peer,sock}name(),
* so right here we are only setting the ports.
*/
sin[0].sin_port = htons(lport);
sin[1].sin_port = htons(fport);
len = sizeof(uc);
if (sysctlbyname("net.inet.tcp.getcred", &uc, &len, sin,
sizeof(sin)) == -1)
iderror(lport, fport, s, errno);
pw = getpwuid(uc.cr_uid); /* Look up the pw to get the username */
if (pw == NULL)
iderror(lport, fport, s, errno);
/*
* If enabled, we check for a file named ".noident" in the user's
* home directory. If found, we return HIDDEN-USER.
*/
if (nflag) {
if (asprintf(&p, "%s/.noident", pw->pw_dir) == -1)
iderror(lport, fport, s, errno);
if (lstat(p, &sb) == 0) {
free(p);
iderror(lport, fport, s, -1);
}
free(p);
}
/*
* Here, if enabled, we read a user's ".fakeid" file in their
* home directory. It consists of a line containing the name
* they want.
*/
if (fflag) {
FILE *fakeid = NULL;
if (asprintf(&p, "%s/.fakeid", pw->pw_dir) == -1)
iderror(lport, fport, s, errno);
/*
* Here we set ourself to effectively be the user, so we don't
* open any files we have no permission to open, especially
* symbolic links to sensitive root-owned files or devices.
*/
seteuid(pw->pw_uid);
setegid(pw->pw_gid);
/*
* If we were to lstat() here, it would do no good, since it
* would introduce a race condition and could be defeated.
* Therefore, we open the file we have permissions to open
* and if it's not a regular file, we close it and end up
* returning the user's real username.
*/
fakeid = fopen(p, "r");
free(p);
if (fakeid != NULL &&
fstat(fileno(fakeid), &sb) != -1 && S_ISREG(sb.st_mode)) {
buf[sizeof(buf) - 1] = '\0';
if (fgets(buf, sizeof(buf), fakeid) == NULL) {
cp = pw->pw_name;
fclose(fakeid);
goto printit;
}
fclose(fakeid);
/*
* Usually, the file will have the desired identity
* in the form "identity\n", so we use strtok() to
* end the string (which fgets() doesn't do.)
*/
strtok(buf, "\r\n");
/* User names of >16 characters are invalid */
if (strlen(buf) > 16)
buf[16] = '\0';
cp = buf;
/* Allow for beginning white space... */
while (isspace(*cp))
cp++;
/* ...and ending white space. */
strtok(cp, " \t");
/*
* If the name is a zero-length string or matches
* the name of another user, it's invalid, so
* we will return their real identity instead.
*/
if (!*cp || getpwnam(cp))
cp = getpwuid(uc.cr_uid)->pw_name;
} else
cp = pw->pw_name;
} else
cp = pw->pw_name;
printit:
/* Finally, we make and send the reply. */
if (asprintf(&p, "%d , %d : USERID : %s : %s\r\n", lport, fport, osname,
cp) == -1) {
syslog(LOG_ERR, "asprintf: %m");
exit(EX_OSERR);
}
write(s, p, strlen(p));
free(p);
exit(0);
}
/*
* RFC738 Time Server.
* Return a machine readable date and time, in the form of the
* number of seconds since midnight, Jan 1, 1900. Since gettimeofday
* returns the number of seconds since midnight, Jan 1, 1970,
* we must add 2208988800 seconds to this figure to make up for
* some seventy years Bell Labs was asleep.
*/
unsigned long
machtime()
{
struct timeval tv;
if (gettimeofday(&tv, (struct timezone *)NULL) < 0) {
if (debug)
warnx("unable to get time of day");
return (0L);
}
#define OFFSET ((u_long)25567 * 24*60*60)
return (htonl((long)(tv.tv_sec + OFFSET)));
#undef OFFSET
}
/* ARGSUSED */
void
machtime_dg(s, sep)
int s;
struct servtab *sep;
{
unsigned long result;
struct sockaddr_in sin;
int size;
size = sizeof(sin);
if (recvfrom(s, (char *)&result, sizeof(result), 0,
(struct sockaddr *)&sin, &size) < 0)
return;
if (check_loop(&sin, sep))
return;
result = machtime();
(void) sendto(s, (char *) &result, sizeof(result), 0,
(struct sockaddr *)&sin, sizeof(sin));
}
/* ARGSUSED */
void
machtime_stream(s, sep)
int s;
struct servtab *sep;
{
unsigned long result;
result = machtime();
(void) write(s, (char *) &result, sizeof(result));
}
/*
* RFC1078 TCP Port Service Multiplexer (TCPMUX). Service connections to
* services based on the service name sent.
*
* Based on TCPMUX.C by Mark K. Lottor November 1988
* sri-nic::ps:<mkl>tcpmux.c
*/
#define MAX_SERV_LEN (256+2) /* 2 bytes for \r\n */
#define strwrite(fd, buf) (void) write(fd, buf, sizeof(buf)-1)
static int /* # of characters upto \r,\n or \0 */
getline(fd, buf, len)
int fd;
char *buf;
int len;
{
int count = 0, n;
struct sigaction sa;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_DFL;
sigaction(SIGALRM, &sa, (struct sigaction *)0);
do {
alarm(10);
n = read(fd, buf, len-count);
alarm(0);
if (n == 0)
return (count);
if (n < 0)
return (-1);
while (--n >= 0) {
if (*buf == '\r' || *buf == '\n' || *buf == '\0')
return (count);
count++;
buf++;
}
} while (count < len);
return (count);
}
struct servtab *
tcpmux(s)
int s;
{
struct servtab *sep;
char service[MAX_SERV_LEN+1];
int len;
/* Get requested service name */
if ((len = getline(s, service, MAX_SERV_LEN)) < 0) {
strwrite(s, "-Error reading service name\r\n");
return (NULL);
}
service[len] = '\0';
if (debug)
warnx("tcpmux: someone wants %s", service);
/*
* Help is a required command, and lists available services,
* one per line.
*/
if (!strcasecmp(service, "help")) {
for (sep = servtab; sep; sep = sep->se_next) {
if (!ISMUX(sep))
continue;
(void)write(s,sep->se_service,strlen(sep->se_service));
strwrite(s, "\r\n");
}
return (NULL);
}
/* Try matching a service in inetd.conf with the request */
for (sep = servtab; sep; sep = sep->se_next) {
if (!ISMUX(sep))
continue;
if (!strcasecmp(service, sep->se_service)) {
if (ISMUXPLUS(sep)) {
strwrite(s, "+Go\r\n");
}
return (sep);
}
}
strwrite(s, "-Service not available\r\n");
return (NULL);
}
-134
View File
@@ -1,134 +0,0 @@
/*
* Copyright (c) 1983, 1991, 1993, 1994
* The Regents of the University of California. 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* $FreeBSD$
*/
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#define BUFSIZE 8192
#define LINESIZ 72
#define NORM_TYPE 0
#define MUX_TYPE 1
#define MUXPLUS_TYPE 2
#define TTCP_TYPE 3
#define ISMUX(sep) (((sep)->se_type == MUX_TYPE) || \
((sep)->se_type == MUXPLUS_TYPE))
#define ISMUXPLUS(sep) ((sep)->se_type == MUXPLUS_TYPE)
#define ISTTCP(sep) ((sep)->se_type == TTCP_TYPE)
struct servtab {
char *se_service; /* name of service */
int se_socktype; /* type of socket to use */
char *se_proto; /* protocol used */
int se_maxchild; /* max number of children */
int se_maxcpm; /* max connects per IP per minute */
int se_numchild; /* current number of children */
pid_t *se_pids; /* array of child pids */
char *se_user; /* user name to run as */
char *se_group; /* group name to run as */
#ifdef LOGIN_CAP
char *se_class; /* login class name to run with */
#endif
struct biltin *se_bi; /* if built-in, description */
char *se_server; /* server program */
char *se_server_name; /* server program without path */
#define MAXARGV 20
char *se_argv[MAXARGV+1]; /* program arguments */
int se_fd; /* open descriptor */
struct sockaddr_in se_ctrladdr;/* bound address */
u_char se_type; /* type: normal, mux, or mux+ */
u_char se_checked; /* looked at during merge */
u_char se_accept; /* i.e., wait/nowait mode */
u_char se_rpc; /* ==1 if RPC service */
int se_rpc_prog; /* RPC program number */
u_int se_rpc_lowvers; /* RPC low version */
u_int se_rpc_highvers; /* RPC high version */
int se_count; /* number started since se_time */
struct timeval se_time; /* start of se_count */
struct servtab *se_next;
};
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 daytime_dg __P((int, struct servtab *));
void daytime_stream __P((int, struct servtab *));
void discard_dg __P((int, struct servtab *));
void discard_stream __P((int, struct servtab *));
void echo_dg __P((int, struct servtab *));
void echo_stream __P((int, struct servtab *));
void endconfig __P((void));
struct servtab *enter __P((struct servtab *));
void freeconfig __P((struct servtab *));
struct servtab *getconfigent __P((void));
void iderror __P((int, int, int, int));
void ident_stream __P((int, struct servtab *));
void machtime_dg __P((int, struct servtab *));
void machtime_stream __P((int, struct servtab *));
int matchservent __P((char *, char *, char *));
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 enable __P((struct servtab *));
void disable __P((struct servtab *));
void flag_retry __P((int));
void retry __P((void));
int setconfig __P((void));
void setup __P((struct servtab *));
char *sskip __P((char **));
char *skip __P((char **));
struct servtab *tcpmux __P((int));
int cpmip __P((struct servtab *, int));
void inetd_setproctitle __P((char *, int));
void unregisterrpc __P((register struct servtab *sep));
struct biltin {
char *bi_service; /* internally provided service name */
int bi_socktype; /* type of socket supported */
short bi_fork; /* 1 if should fork before call */
int bi_maxchild; /* max number of children, -1=default */
void (*bi_fn)(); /* function which performs it */
};
+1 -1
View File
@@ -193,7 +193,7 @@ getpackagesite(void)
strcpy(sitepath, u.machine);
if (reldate == 330000)
strcat(sitepath, "/packages-3.3/");
strcat(sitepath, "/packages-3.3-release/");
else if (330000 < reldate && reldate < 400000)
strcat(sitepath, "/packages-3-stable/Latest/");
else
-434
View File
@@ -1,434 +0,0 @@
/*-
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
* who places it in the public domain without restriction.
*
* $FreeBSD$
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <sys/un.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#ifdef __FreeBSD__
#include <alias.h>
#else
#include "alias.h"
#endif
#include "layer.h"
#include "proto.h"
#include "defs.h"
#include "command.h"
#include "log.h"
#include "nat_cmd.h"
#include "descriptor.h"
#include "prompt.h"
#include "timer.h"
#include "fsm.h"
#include "slcompress.h"
#include "throughput.h"
#include "iplist.h"
#include "mbuf.h"
#include "lqr.h"
#include "hdlc.h"
#include "ipcp.h"
#include "lcp.h"
#include "ccp.h"
#include "link.h"
#include "mp.h"
#include "filter.h"
#ifndef NORADIUS
#include "radius.h"
#endif
#include "bundle.h"
static int StrToAddr(const char *, struct in_addr *);
static int StrToPortRange(const char *, u_short *, u_short *, const char *);
static int StrToAddrAndPort(const char *, struct in_addr *, u_short *,
u_short *, const char *);
static void
lowhigh(u_short *a, u_short *b)
{
if (a > b) {
u_short c;
c = *b;
*b = *a;
*a = c;
}
}
int
nat_RedirectPort(struct cmdargs const *arg)
{
if (!arg->bundle->NatEnabled) {
prompt_Printf(arg->prompt, "Alias not enabled\n");
return 1;
} else if (arg->argc == arg->argn + 3 || arg->argc == arg->argn + 4) {
char proto_constant;
const char *proto;
struct in_addr localaddr;
u_short hlocalport, llocalport;
struct in_addr aliasaddr;
u_short haliasport, laliasport;
struct in_addr remoteaddr;
u_short hremoteport, lremoteport;
struct alias_link *link;
int error;
proto = arg->argv[arg->argn];
if (strcmp(proto, "tcp") == 0) {
proto_constant = IPPROTO_TCP;
} else if (strcmp(proto, "udp") == 0) {
proto_constant = IPPROTO_UDP;
} else {
prompt_Printf(arg->prompt, "port redirect: protocol must be"
" tcp or udp\n");
return -1;
}
error = StrToAddrAndPort(arg->argv[arg->argn+1], &localaddr, &llocalport,
&hlocalport, proto);
if (error) {
prompt_Printf(arg->prompt, "nat port: error reading localaddr:port\n");
return -1;
}
error = StrToPortRange(arg->argv[arg->argn+2], &laliasport, &haliasport,
proto);
if (error) {
prompt_Printf(arg->prompt, "nat port: error reading alias port\n");
return -1;
}
aliasaddr.s_addr = INADDR_ANY;
if (arg->argc == arg->argn + 4) {
error = StrToAddrAndPort(arg->argv[arg->argn+3], &remoteaddr,
&lremoteport, &hremoteport, proto);
if (error) {
prompt_Printf(arg->prompt, "nat port: error reading "
"remoteaddr:port\n");
return -1;
}
} else {
remoteaddr.s_addr = INADDR_ANY;
lremoteport = hremoteport = 0;
}
lowhigh(&llocalport, &hlocalport);
lowhigh(&laliasport, &haliasport);
lowhigh(&lremoteport, &hremoteport);
if (haliasport - laliasport != hlocalport - llocalport) {
prompt_Printf(arg->prompt, "nat port: local & alias port ranges "
"are not equal\n");
return -1;
}
if (hremoteport && hremoteport - lremoteport != hlocalport - llocalport) {
prompt_Printf(arg->prompt, "nat port: local & remote port ranges "
"are not equal\n");
return -1;
}
while (laliasport <= haliasport) {
link = PacketAliasRedirectPort(localaddr, htons(llocalport),
remoteaddr, htons(lremoteport),
aliasaddr, htons(laliasport),
proto_constant);
if (link == NULL) {
prompt_Printf(arg->prompt, "nat port: %d: error %d\n", laliasport,
error);
return 1;
}
llocalport++;
laliasport++;
if (hremoteport)
lremoteport++;
}
return 0;
}
return -1;
}
int
nat_RedirectAddr(struct cmdargs const *arg)
{
if (!arg->bundle->NatEnabled) {
prompt_Printf(arg->prompt, "nat not enabled\n");
return 1;
} else if (arg->argc == arg->argn+2) {
int error;
struct in_addr localaddr, aliasaddr;
struct alias_link *link;
error = StrToAddr(arg->argv[arg->argn], &localaddr);
if (error) {
prompt_Printf(arg->prompt, "address redirect: invalid local address\n");
return 1;
}
error = StrToAddr(arg->argv[arg->argn+1], &aliasaddr);
if (error) {
prompt_Printf(arg->prompt, "address redirect: invalid alias address\n");
prompt_Printf(arg->prompt, "Usage: nat %s %s\n", arg->cmd->name,
arg->cmd->syntax);
return 1;
}
link = PacketAliasRedirectAddr(localaddr, aliasaddr);
if (link == NULL) {
prompt_Printf(arg->prompt, "address redirect: packet aliasing"
" engine error\n");
prompt_Printf(arg->prompt, "Usage: nat %s %s\n", arg->cmd->name,
arg->cmd->syntax);
}
} else
return -1;
return 0;
}
static int
StrToAddr(const char *str, struct in_addr *addr)
{
struct hostent *hp;
if (inet_aton(str, addr))
return 0;
hp = gethostbyname(str);
if (!hp) {
log_Printf(LogWARN, "StrToAddr: Unknown host %s.\n", str);
return -1;
}
*addr = *((struct in_addr *) hp->h_addr);
return 0;
}
static int
StrToPort(const char *str, u_short *port, const char *proto)
{
struct servent *sp;
char *end;
*port = strtol(str, &end, 10);
if (*end != '\0') {
sp = getservbyname(str, proto);
if (sp == NULL) {
log_Printf(LogWARN, "StrToAddr: Unknown port or service %s/%s.\n",
str, proto);
return -1;
}
*port = ntohs(sp->s_port);
}
return 0;
}
static int
StrToPortRange(const char *str, u_short *low, u_short *high, const char *proto)
{
char *minus;
int res;
minus = strchr(str, '-');
if (minus)
*minus = '\0'; /* Cheat the const-ness ! */
res = StrToPort(str, low, proto);
if (minus)
*minus = '-'; /* Cheat the const-ness ! */
if (res == 0) {
if (minus)
res = StrToPort(minus + 1, high, proto);
else
*high = *low;
}
return res;
}
static int
StrToAddrAndPort(const char *str, struct in_addr *addr, u_short *low,
u_short *high, const char *proto)
{
char *colon;
int res;
colon = strchr(str, ':');
if (!colon) {
log_Printf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n", str);
return -1;
}
*colon = '\0'; /* Cheat the const-ness ! */
res = StrToAddr(str, addr);
*colon = ':'; /* Cheat the const-ness ! */
if (res != 0)
return -1;
return StrToPortRange(colon + 1, low, high, proto);
}
int
nat_ProxyRule(struct cmdargs const *arg)
{
char cmd[LINE_LEN];
int f, pos;
size_t len;
if (arg->argn >= arg->argc)
return -1;
for (f = arg->argn, pos = 0; f < arg->argc; f++) {
len = strlen(arg->argv[f]);
if (sizeof cmd - pos < len + (f ? 1 : 0))
break;
if (f)
cmd[pos++] = ' ';
strcpy(cmd + pos, arg->argv[f]);
pos += len;
}
return PacketAliasProxyRule(cmd);
}
int
nat_Pptp(struct cmdargs const *arg)
{
struct in_addr addr;
if (arg->argc == arg->argn) {
addr.s_addr = INADDR_NONE;
PacketAliasPptp(addr);
return 0;
}
if (arg->argc != arg->argn + 1)
return -1;
addr = GetIpAddr(arg->argv[arg->argn]);
if (addr.s_addr == INADDR_NONE) {
log_Printf(LogWARN, "%s: invalid address\n", arg->argv[arg->argn]);
return 1;
}
PacketAliasPptp(addr);
return 0;
}
static struct mbuf *
nat_PadMbuf(struct mbuf *bp, int type)
{
struct mbuf **last;
int len;
mbuf_SetType(bp, type);
for (last = &bp, len = 0; *last != NULL; last = &(*last)->next)
len += (*last)->cnt;
len = MAX_MRU - len;
*last = mbuf_Alloc(len, type);
return bp;
}
static struct mbuf *
nat_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
int pri, u_short *proto)
{
if (!bundle->NatEnabled || *proto != PROTO_IP)
return bp;
log_Printf(LogDEBUG, "nat_LayerPush: PROTO_IP -> PROTO_IP\n");
bp = mbuf_Contiguous(nat_PadMbuf(bp, MB_NATOUT));
PacketAliasOut(MBUF_CTOP(bp), bp->cnt);
bp->cnt = ntohs(((struct ip *)MBUF_CTOP(bp))->ip_len);
return bp;
}
static struct mbuf *
nat_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp,
u_short *proto)
{
struct ip *pip, *piip;
int ret, len;
struct mbuf **last;
char *fptr;
if (!bundle->NatEnabled || *proto != PROTO_IP)
return bp;
log_Printf(LogDEBUG, "nat_LayerPull: PROTO_IP -> PROTO_IP\n");
bp = mbuf_Contiguous(nat_PadMbuf(bp, MB_NATIN));
pip = (struct ip *)MBUF_CTOP(bp);
piip = (struct ip *)((char *)pip + (pip->ip_hl << 2));
if (pip->ip_p == IPPROTO_IGMP ||
(pip->ip_p == IPPROTO_IPIP && IN_CLASSD(ntohl(piip->ip_dst.s_addr))))
return bp;
ret = PacketAliasIn(MBUF_CTOP(bp), bp->cnt);
bp->cnt = ntohs(pip->ip_len);
if (bp->cnt > MAX_MRU) {
log_Printf(LogWARN, "nat_LayerPull: Problem with IP header length (%d)\n",
bp->cnt);
mbuf_Free(bp);
return NULL;
}
switch (ret) {
case PKT_ALIAS_OK:
break;
case PKT_ALIAS_UNRESOLVED_FRAGMENT:
/* Save the data for later */
fptr = malloc(bp->cnt);
bp = mbuf_Read(bp, fptr, bp->cnt);
PacketAliasSaveFragment(fptr);
break;
case PKT_ALIAS_FOUND_HEADER_FRAGMENT:
/* Fetch all the saved fragments and chain them on the end of `bp' */
last = &bp->pnext;
while ((fptr = PacketAliasGetFragment(MBUF_CTOP(bp))) != NULL) {
PacketAliasFragmentIn(MBUF_CTOP(bp), fptr);
len = ntohs(((struct ip *)fptr)->ip_len);
*last = mbuf_Alloc(len, MB_NATIN);
memcpy(MBUF_CTOP(*last), fptr, len);
free(fptr);
last = &(*last)->pnext;
}
break;
default:
mbuf_Free(bp);
bp = NULL;
break;
}
return bp;
}
struct layer natlayer =
{ LAYER_NAT, "nat", nat_LayerPush, nat_LayerPull };
-15
View File
@@ -1,15 +0,0 @@
/*-
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
* who places it in the public domain without restriction.
*
* $FreeBSD$
*/
struct cmdargs;
extern int nat_RedirectPort(struct cmdargs const *);
extern int nat_RedirectAddr(struct cmdargs const *);
extern int nat_ProxyRule(struct cmdargs const *);
extern int nat_Pptp(struct cmdargs const *);
extern struct layer natlayer;
-316
View File
@@ -1,316 +0,0 @@
/*-
* Copyright (C) 1996
* David L. Nugent. 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 DAVID L. NUGENT 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 DAVID L. NUGENT 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.
*
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/param.h>
#include "pwupd.h"
static FILE * pwd_fp = NULL;
void
vendpwent(void)
{
if (pwd_fp != NULL) {
fclose(pwd_fp);
pwd_fp = NULL;
}
}
void
vsetpwent(void)
{
vendpwent();
}
static struct passwd *
vnextpwent(char const * nam, uid_t uid, int doclose)
{
struct passwd * pw = NULL;
static char pwtmp[1024];
strncpy(pwtmp, getpwpath(_MASTERPASSWD), sizeof pwtmp);
pwtmp[sizeof pwtmp - 1] = '\0';
if (pwd_fp != NULL || (pwd_fp = fopen(pwtmp, "r")) != NULL) {
int done = 0;
static struct passwd pwd;
while (!done && fgets(pwtmp, sizeof pwtmp, pwd_fp) != NULL)
{
int i, quickout = 0;
char * q;
char * p = strchr(pwtmp, '\n');
if (p == NULL) {
while (fgets(pwtmp, sizeof pwtmp, pwd_fp) != NULL && strchr(pwtmp, '\n')==NULL)
; /* Skip long lines */
continue;
}
/* skip comments & empty lines */
if (*pwtmp =='\n' || *pwtmp == '#')
continue;
i = 0;
q = p = pwtmp;
bzero(&pwd, sizeof pwd);
while (!quickout && (p = strsep(&q, ":\n")) != NULL) {
switch (i++)
{
case 0: /* username */
pwd.pw_name = p;
if (nam) {
if (strcmp(nam, p) == 0)
done = 1;
else
quickout = 1;
}
break;
case 1: /* password */
pwd.pw_passwd = p;
break;
case 2: /* uid */
pwd.pw_uid = atoi(p);
if (uid != (uid_t)-1) {
if (uid == pwd.pw_uid)
done = 1;
else
quickout = 1;
}
break;
case 3: /* gid */
pwd.pw_gid = atoi(p);
break;
case 4: /* class */
if (nam == NULL && uid == (uid_t)-1)
done = 1;
pwd.pw_class = p;
break;
case 5: /* change */
pwd.pw_change = (time_t)atol(p);
break;
case 6: /* expire */
pwd.pw_expire = (time_t)atol(p);
break;
case 7: /* gecos */
pwd.pw_gecos = p;
break;
case 8: /* directory */
pwd.pw_dir = p;
break;
case 9: /* shell */
pwd.pw_shell = p;
break;
}
}
}
if (doclose)
vendpwent();
if (done && pwd.pw_name) {
pw = &pwd;
#define CKNULL(s) s = s ? s : ""
CKNULL(pwd.pw_passwd);
CKNULL(pwd.pw_class);
CKNULL(pwd.pw_gecos);
CKNULL(pwd.pw_dir);
CKNULL(pwd.pw_shell);
}
}
return pw;
}
struct passwd *
vgetpwent(void)
{
return vnextpwent(NULL, -1, 0);
}
struct passwd *
vgetpwuid(uid_t uid)
{
return vnextpwent(NULL, uid, 1);
}
struct passwd *
vgetpwnam(const char * nam)
{
return vnextpwent(nam, -1, 1);
}
int vpwdb(char *arg, ...)
{
arg=arg;
return 0;
}
static FILE * grp_fp = NULL;
void
vendgrent(void)
{
if (grp_fp != NULL) {
fclose(grp_fp);
grp_fp = NULL;
}
}
int
vsetgrent(void)
{
vendgrent();
return 0;
}
static struct group *
vnextgrent(char const * nam, gid_t gid, int doclose)
{
struct group * gr = NULL;
static char * grtmp = NULL;
static int grlen = 0;
static char ** mems = NULL;
static int memlen = 0;
extendline(&grtmp, &grlen, MAXPATHLEN);
strncpy(grtmp, getgrpath(_GROUP), MAXPATHLEN);
grtmp[MAXPATHLEN - 1] = '\0';
if (grp_fp != NULL || (grp_fp = fopen(grtmp, "r")) != NULL) {
int done = 0;
static struct group grp;
while (!done && fgets(grtmp, grlen, grp_fp) != NULL)
{
int i, quickout = 0;
int mno = 0;
char * q, * p;
char * sep = ":\n";
if ((p = strchr(grtmp, '\n')) == NULL) {
int l;
extendline(&grtmp, &grlen, grlen + PWBUFSZ);
l = strlen(grtmp);
if (fgets(grtmp + l, grlen - l, grp_fp) == NULL)
break; /* No newline terminator on last line */
}
/* Skip comments and empty lines */
if (*grtmp == '\n' || *grtmp == '#')
continue;
i = 0;
q = p = grtmp;
bzero(&grp, sizeof grp);
extendarray(&mems, &memlen, 200);
while (!quickout && (p = strsep(&q, sep)) != NULL) {
switch (i++)
{
case 0: /* groupname */
grp.gr_name = p;
if (nam) {
if (strcmp(nam, p) == 0)
done = 1;
else
quickout = 1;
}
break;
case 1: /* password */
grp.gr_passwd = p;
break;
case 2: /* gid */
grp.gr_gid = atoi(p);
if (gid != (gid_t)-1) {
if (gid == (gid_t)grp.gr_gid)
done = 1;
else
quickout = 1;
} else if (nam == NULL)
done = 1;
break;
case 3:
q = p;
sep = ",\n";
break;
default:
if (*p) {
extendarray(&mems, &memlen, mno + 2);
mems[mno++] = p;
}
break;
}
}
grp.gr_mem = mems;
mems[mno] = NULL;
}
if (doclose)
vendgrent();
if (done && grp.gr_name) {
gr = &grp;
CKNULL(grp.gr_passwd);
}
}
return gr;
}
struct group *
vgetgrent(void)
{
return vnextgrent(NULL, -1, 0);
}
struct group *
vgetgrgid(gid_t gid)
{
return vnextgrent(NULL, gid, 1);
}
struct group *
vgetgrnam(const char * nam)
{
return vnextgrent(nam, -1, 1);
}
int
vgrdb(char *arg, ...)
{
arg=arg;
return 0;
}