From 3bab9ab140e1a3f5525b749cdaf021c93f94765d Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Sun, 22 Oct 1995 11:59:20 +0100 Subject: [PATCH] isdn-14 reconstructed by extracting isdn-18.tar.gz and reverse applying the various diffs back to isdn-14. --- DOKU | 175 +++- Make.config | 46 + Make.rules | 241 +++++ Makefile | 59 +- README | 40 + alaw/Makefile | 67 +- alaw/dtmf/dtmf.c | 251 +++++ alaw/dtmf/dtmfsin.c | 459 +++++++++ alaw/toalaw.pl | 28 - alaw/tools/Makefile | 5 + alaw/{ => tools}/toalaw.c | 0 alaw/{ => tools}/tosnd.c | 0 alaw/tosnd.pl | 27 - bin/Makefile | 19 - cards/Makefile | 15 +- cards/arnet/Makefile | 44 +- cards/arnet/README | 2 - cards/capi/Makefile | 7 + cards/capi/bintec.c | 1490 +++++++++++++++++++++++++++++ cards/capi/bintec.h | 73 ++ cards/capi/bri.h | 252 +++++ cards/capi/capi.h | 1055 ++++++++++++++++++++ cards/capi/insert.c | 55 ++ cards/dumb/Makefile | 96 +- cards/dumb/avm_io.c | 82 +- cards/dumb/bsc_io.c | 36 +- cards/dumb/ncp16_io.c | 46 +- cards/dumb/ncp_io.c | 46 +- cards/dumb/shell.c | 208 ++-- cards/dumb/shell.h | 11 +- cards/dumb/teles_io.c | 46 +- cards/{dumb/insert.c => loader.c} | 30 +- cards/test/Config.c | 48 - cards/test/Config.h | 48 - cards/test/Makefile | 51 - cards/test/test.c | 355 ------- compat/Makefile | 52 +- compat/compat.c | 46 +- config/Makefile | 53 +- config/config.data | 193 ---- config/config.data.aux | 182 ---- config/config.data.linux | 191 ---- config/config.data.pc | 182 ---- config/config.dist | 219 ++++- config/files.list | 33 +- config/subst.s | 1294 ------------------------- fakeh/Makefile | 53 +- final/Makefile | 56 -- iftrue.sh | 25 - include/Makefile | 19 +- include/config.h | 4 +- include/isdn3_phone.h | 10 - include/isdn_23.h | 4 +- include/isdn_3.h | 20 +- include/isdn_34.h | 7 + include/isdn_proto.h | 1 + include/kernel.h | 34 +- include/lap.h | 1 - include/loader.h | 15 + include/primitives.h | 11 +- include/sapi.h | 23 + include/streamlib.h | 17 +- include/streams.h | 11 +- include/vanj.h | 2 + ip_mon/Makefile | 65 +- ip_mon/ip_mon.c | 10 +- ip_mon/tools/Makefile | 6 + ip_mon/{ => tools}/monitor.c | 22 +- isdn_2/Makefile | 49 +- isdn_2/isdn_2.c | 360 ++++--- isdn_3/Makefile | 64 +- isdn_3/capi.c | 1449 +++++++++++++++++++++++++++- isdn_3/fixed.c | 17 +- isdn_3/isdn_3.c | 1077 +++++++++++++-------- isdn_3/phone.c | 60 +- isdn_3/prot_1TR6_0.c | 5 +- isdn_3/prot_1TR6_1.c | 103 +- isdn_3/prot_ETS.c | 142 +-- isdn_3/tei.c | 39 +- isdn_4/Makefile | 50 +- isdn_4/cf.c | 27 +- isdn_4/conn.c | 56 +- isdn_4/devs.c | 7 +- isdn_4/info.c | 435 ++++++--- isdn_4/libs.sh | 10 - isdn_4/loader.c | 105 +- isdn_4/master.c | 96 +- isdn_4/master.h | 42 +- isdn_4/match.c | 195 ++-- isdn_4/stream.c | 40 +- isdn_4/texts.c | 9 +- isdn_4/util.c | 137 ++- isdn_4/work.c | 90 +- ksupport/Makefile | 56 +- ksupport/dump.c | 132 ++- ksupport/log.c | 34 +- ksupport/logh.c | 15 +- ksupport/proto.c | 14 +- ksupport/streamlib.c | 157 +-- ksupport/x75lib.c | 116 +-- make.isdn | 24 +- patches/biglog | 20 - patches/debugmsg | 158 --- patches/loadable.slip | 2 - patches/loadserial | 307 ------ patches/more_free | 18 - patches/nm.background | 15 - patches/panicreboot | 120 --- patches/setnoswap | 21 - patches/symbols | 70 -- pr_on/Makefile | 48 +- rate/Makefile | 48 +- reconnect/Makefile | 48 +- str_if/Makefile | 76 +- str_if/slipto.c.orig | 711 -------------- str_if/str_if.h | 5 +- str_if/str_linux.c | 32 +- str_if/tools/Makefile | 7 + str_if/{ => tools}/slipto.c | 0 streams/Makefile | 56 +- streams/log/Makefile | 43 - streams/log/log.c | 383 -------- streams/log/log.h | 3 - streams/loop/Makefile | 43 +- streams/streams_io.c | 52 +- streams/streams_sys.c | 145 +-- streams/stropts.h | 20 +- strslip/Makefile | 50 +- support/Makefile | 66 +- support/kernel.c | 2 + support/streams.c | 74 +- t70/Makefile | 65 +- t70/test_t70.c | 106 -- timer/Makefile | 48 +- tools/Makefile | 81 +- {bin => tools}/catfone | 0 tools/d_insmod | 14 + tools/getvers | 2 - tools/getversion | 8 +- tools/insmod | 7 +- cf => tools/isdn.conf | 8 +- bin/tester => tools/nologin | 0 tools/rc.isdn | 2 +- v110/Makefile | 48 +- van_j/Makefile | 54 +- van_j/van_j.c | 21 +- x75/Makefile | 54 +- x75/test_x75.c | 134 --- x75/x75.c | 12 +- 149 files changed, 8725 insertions(+), 8168 deletions(-) create mode 100644 Make.config create mode 100644 Make.rules create mode 100644 alaw/dtmf/dtmf.c create mode 100644 alaw/dtmf/dtmfsin.c delete mode 100644 alaw/toalaw.pl create mode 100644 alaw/tools/Makefile rename alaw/{ => tools}/toalaw.c (100%) rename alaw/{ => tools}/tosnd.c (100%) delete mode 100644 alaw/tosnd.pl delete mode 100644 bin/Makefile delete mode 100644 cards/arnet/README create mode 100644 cards/capi/Makefile create mode 100644 cards/capi/bintec.c create mode 100644 cards/capi/bintec.h create mode 100644 cards/capi/bri.h create mode 100644 cards/capi/capi.h create mode 100644 cards/capi/insert.c rename cards/{dumb/insert.c => loader.c} (59%) delete mode 100644 cards/test/Config.c delete mode 100644 cards/test/Config.h delete mode 100644 cards/test/Makefile delete mode 100644 cards/test/test.c delete mode 100644 config/config.data delete mode 100644 config/config.data.aux delete mode 100644 config/config.data.linux delete mode 100644 config/config.data.pc delete mode 100644 config/subst.s delete mode 100644 final/Makefile delete mode 100644 iftrue.sh create mode 100644 include/loader.h create mode 100644 include/sapi.h create mode 100644 ip_mon/tools/Makefile rename ip_mon/{ => tools}/monitor.c (93%) delete mode 100644 isdn_4/libs.sh delete mode 100644 patches/biglog delete mode 100644 patches/debugmsg delete mode 100644 patches/loadable.slip delete mode 100644 patches/loadserial delete mode 100644 patches/more_free delete mode 100644 patches/nm.background delete mode 100644 patches/panicreboot delete mode 100644 patches/setnoswap delete mode 100644 patches/symbols delete mode 100644 str_if/slipto.c.orig create mode 100644 str_if/tools/Makefile rename str_if/{ => tools}/slipto.c (100%) delete mode 100644 streams/log/Makefile delete mode 100644 streams/log/log.c delete mode 100644 streams/log/log.h delete mode 100644 t70/test_t70.c rename {bin => tools}/catfone (100%) create mode 100644 tools/d_insmod delete mode 100644 tools/getvers rename cf => tools/isdn.conf (96%) rename bin/tester => tools/nologin (100%) delete mode 100644 x75/test_x75.c diff --git a/DOKU b/DOKU index 474733b..bc86590 100644 --- a/DOKU +++ b/DOKU @@ -16,6 +16,9 @@ unter der GPL bzw. ihrem deutschen Achtung: ======= +Version 14: Die CL- und DL-Zeilen haben sich geändert (erweitert um +-Parameter). Intelligente Karten funktionieren NOCH NICHT. + In der Version 11 lagen noch ein paar .depend-Dateien und anderer Kram rum, die den Buildprozeß gestört haben. Abhilfe: "make clean". @@ -226,6 +229,7 @@ done # Danach: vi config/config.data +# Zeile "PROTOCOLS" und "SUBPROTOCOLS" ansehen. Siehe unten "DL-Zeile". make.isdn # Als Superuser: make.isdn @@ -346,6 +350,7 @@ AT/Q Programmende. Kann nur vom Superuser ausgeführt werden. AT/R Reload der Konfigdatei. Kann nur vom Superuser ausgeführt werden. + Alle wegen eines Fehlers deaktivierten Programme werden wieder aufgeweckt. AT/Xn Abbruch der Verbindung . Kann nur vom Superuser ausgeführt werden. ATD/sys/proto @@ -404,6 +409,16 @@ nicht ohne weiteres beobachten lassen.) Zum Gl "normale" Betriebsarten herauskristallisiert, an die sich die meisten Systeme halten. +Paketformate +------------ +Im einfachsten Fall werden IP-Pakete direkt auf die Leitung geschickt. Wer +zusätzlich noch Appletalk oder IPX oder so machen will, kann diese entweder +in IP einpacken (Overhead, kein Kernelsupport unter Linux) oder ein paar +Bytes vor die Daten stellen, die angeben, um was für Daten es sich handelt. + +Die Bytes können entweder genauso aussehen wie im Ethernet, oder so wie der +Pakettyp von PPP. Wer PPP macht, braucht offensichtlich letzteres (PPP +selber wird auch bald kommen...); normale Leute nehmen die Ethernet-Codes. Noch ein Einschub: TCP-IP-Routing ================================= @@ -523,12 +538,23 @@ Alle Zeilentypen: Zeilen in der Konfigdatei müssen zueinander passende Keys haben, d.h. mindestens ein Zeichen muß in allen Keys übereinstimmen. "*" paßt zu allen anderen Zeichen. + Der resultierende String ist also die Schnittmenge aller Zeichen in + den -Parametern aller verwendeter Konfigurationszeilen. + -Zeilen mit einem Pluszeichen an erster Stelle werden nur auf + Vorhandensein eines Zeichens geprüft, aber die Menge wird nicht + eingeschränkt. Beispiel: + "ab" "cd" -> leere Menge + "ab" "xay" -> "a" + "ab" "+x" -> leere Menge + "ab" "+bx" -> "b" + "ab" "+bx" "a" -> leere Menge + Damit läßt sich sehr flexibel einstellen, wer auf welcher Leitung / + Nummer mit welchen Parametern anrufen kann. sind einzelne Buchstaben, der der betreffenden Zeile eine Sonder- behandlung verpassen. ist eine Folge von einem oder mehr Parameter-Wert-Angaben. (Manche Parameter haben keine Wertangabe.) - Merke: Zeilen ohne Parameter sind im allgemeinen nicht sinnvoll - und führen (momentan noch) zu Fehlverhalten des Treibers. + Merke: Zeilen ohne Parameter sind nicht besonders sinnvoll. P-Zeile ("Protokoll") @@ -547,33 +573,37 @@ Parameter: Verbindungen wird das handhabende Programm nicht unterbrochen. Ein "reconn"-Streamsmodul stellt sicher, daß das Programm davon nichts mitbekommt, außer wenn der Wiederaufbau der Verbindung nicht klappt. -:cd Karte. Welche ISDN-Leitung verwendet werden soll. (Wichtig für SPVs.) - Bei Festverbindungen wird dieser Parameter nicht benötigt. :bc Zu verwendender B-Kanal, 1 oder 2. Nur für Festverbindungen interessant; im normalen ISDN managt die Vermittlung B-Kanäle für uns. :nj Kann der Ruf nicht angenommen werden, wird BUSY statt CallRejected gesendet. :xi Wenn ankommende und abgehende Anrufe kollidieren, soll der an- kommende abgewiesen werden. (Default: Der abgehende Ruf wird - abgebrochen.) (Nicht allzu gut getestet.) + abgebrochen.) :yi Bei einem ankommeden Ruf wird automatisch ein abgehender gestartet und - der ankommende wird abgewiesen. (Ungetestet.) + der ankommende wird abgewiesen. :bi Bei einem ankommenden Ruf, der nicht angenommen werden kann (belegt?), - wird automatisch hoffentlich auf einer anderen Leitung zurückgerufen. + wird automatisch auf einer anderen Leitung zurückgerufen. :fr ebenfalls zu setzen ist meist sinnvoll. :il Die CL-Zeile wird ignoriert. :fX Ankommende Anrufe, die (zB wegen besetzt) abgewiesen werden, werden - "schnell" abgelehnt. (Andere Geräte am Bus können nicht abheben.) + "schnell" abgelehnt. (Andere Geräte am Bus können nicht abheben, da die + Vermittlung nicht abwartet, ob sich noch jemand meldet.) :fr Abgehende Anrufe, die nicht durchkommen, werden "sofort" und "oft" wiederholt. +:ib Wenn ankommend kein B-Kanal mitgeliefert wird, wird die Verbindung + abgewiesen. (zB wenn man dich den Anschluß mit einem anderen gerät + teilt.) Fehlt :ib, hört die Gegenseite in diesem Fall ein normales + Rufzeichen ("Anklopfen"); die Verbindung wird nach 40 Sekunden + ausgelöst, wenn bis dahin kein B-Kanal frei wird.. Logischerweise darf :xi oder :yi nicht auf beiden Seiten angegeben sein..! -Spezifisch für 1TR6: +Spezifisch für 1TR6 und CAPI: :sv Dienstkennung; zwei Bytes in Hex. Telefon ist 0101 und 0102; DFÜ ist 07xx (xx ist üblicherweise 00). -:pv Semipermanente Verbindung bei abgehenden Rufen. +:pv Semipermanente Verbindung bei abgehenden Rufen. (Noch nicht bei CAPI.) Ankommend werden SPVs automatisch unterstützt. Spezifisch für Euro-ISDN: @@ -611,10 +641,11 @@ f f d für Wählverbindungen p für Verbindungsaufbau nach Bedarf -Der Suchalgorithmus findet zunächst eine zur Verbindung passende R-Zeile -und hängt an deren Parameterliste dann alle ebenfalls passenden M-Zeilen -an (dabei werden bereits angegebene Werte beibehalten, die spezifischen -Einträge also nach oben!), bis er auf eine X-Zeile trifft. +Der Suchalgorithmus findet zunächst eine zur Verbindung passende Zeile mit +R-Flag und hängt an deren Parameterliste alle ebenfalls passenden Zeilen +mit M-Flag an (dabei werden bereits angegebene Werte beibehalten, die +spezifischen Einträge also nach oben!), bis er auf eine Zeile mit X-Flag +trifft. ML-Zeile ("Modulliste") @@ -704,32 +735,39 @@ DL-Zeile ("Dial Local") -------- Form: -DL +DL Beispiel: -DL Tel? +49=911-995962. :pr 0 :sp 65 :pr 63 +DL * Tel? +49=911-995962. :pr 0 :sp 65 :pr 63 Eigene Telefonnummer. Im Beispiel sind alle Karten, auf die "Tel?" paßt, an einer ISDN-Leitung mit dieser Nummer angeschlossen. Diese Zeile wird verwendet, um die kürzestmögliche Rufnummer für abgehende Verbindungen zu finden und um die verwendeten Protokolle zu -spezifizieren. +spezifizieren. Hat eine Karte mehrere Rufnummern (MSNs), werden die +Protokolle nur in der ersten DL-Zeile angegeben. -Beispiel 1TR6: -DL Tel0 +49=911-23456. :pr 0 :sp 65 :pr 63 +Zusätzlich werden in der DL-Zeile die Protokolle beschrieben, mit denen der +ISDN-Treiber mit der Karte redet. Diese Protokolle müssen natürlich auch in +den Treiber eingebaut werden, und zwar in der Datei config/config.data, +Eintrag PROTOCOLS (spitze Klammer) und SUBPROTOCOLS (eckige Klammer). -Beispiel Euro-ISDN: -DL Tel0 +49=911-34567. :pr 0 :sp 8 :pr 63 +Beispiel 1TR6: [german] +DL * Tel0 +49=911-23456. :pr 0 :sp 65 :pr 63 -Beispiel Festverbindung: -DL Tel2 - :pr 64 +Beispiel Euro-ISDN: [euro] +DL * Tel0 +49=911-34567. :pr 0 :sp 8 :pr 63 -Beispiel intelligente Karte mit CAPI: -DL Bin0 +49=911-45678. :pr 65 +Beispiel Festverbindung: +DL * Tel2 - :pr 64 + +Beispiel intelligente Karte mit CAPI: [bintec] +DL * Bin0 +49=911-45678. :pr 65 :sp 0 Bedeutung der Spezialzeichen in der Nummer: Siehe "DP" unten. + Protokolle und Flags in der DL-Zeile: -------------------- @@ -751,7 +789,7 @@ Die Reihenfolge ist wichtig. :pr 0 Normaler ISDN-D-Kanal, angeschlossen am Netz oder an einer Telefonanlage. Darf nur zusammen mit TEI-Handler (:pr 63) - verwendet werden. + verwendet werden. :kl Level-2-Verbindung zur Vermittlung nicht trennen. Bei Punkt- zu-Punkt-Verbindungen und bei entsprechend konfigurierten ISDN-Anschlüssen ("Dauerüberwachung oder sowas ähnliches") @@ -759,8 +797,8 @@ Die Reihenfolge ist wichtig. :cl Level-2-Verbindung zur Vermittlung trennen, wenn keine Verbindung besteht. Default. - :sp 8 DSS1, Euro-ISDN. - :sp 65 1TR6, deutscher Standard. + :sp 8 DSS1, Euro-ISDN. [euro] + :sp 65 1TR6, deutscher Standard. [german] Entweder :sp 8 oder :sp 65 muß angegeben werden, NICHT beides! :ai Ankommenden Anruf mit dem ISDN-Äquivalent von "RINGING" @@ -768,13 +806,24 @@ Die Reihenfolge ist wichtig. Notwendig bei langsamen Rechnern. :ad Ankommende Anrufe erst prüfen, dann annehmen (oder auch nicht). Default. -:pr 63 TEI-Handler (Transport Endpoint Identifier). +:pr 63 TEI-Handler (Transport Endpoint Identifier). :ti TEI sofort zuordnen lassen. Notwendig bei langsamen / sehr beschäftigten Rechnern und bei manchen Telefonanlagen. :td TEI beim ersten Verbindungsaufbau zuordnen lassen. Default. -:pr 64 Festverbindung: kein D-Kanal. -:pr 65 Intelligente Karte mit CAPI 1.x-Schnittstelle. - (Noch nicht implementiert.) +:pr 64 Festverbindung: kein D-Kanal. +:pr 65 Intelligente Karte mit CAPI-1.x-Schnittstelle. (Noch nicht!) + In der Konfiguration verhält sich eine CAPI-Karte ansonsten wie + der 1TR6-Treiber, und zwar AUCH DANN WENN DAS TEIl AM EURO-ISDN + HÄNGT. + :sp 0 Bintec-Karte. [bintec] + Auf diese Karte muß zunächst boot.68k und dann entweder bri.68k, + bri_4.68k oder pmx.68k geladen werden. + :lp X X X CAPI-Bitmasken für EAZ, Service, Infos. Hexadezimal. + Default: 3FFF FFFF 003F. + :st XXXXX Protokollstack XXXXX laden. Siehe Handbuch zur Karte. + Default ist u_dss1_pmp. + :ea N NNN EAZ N auf (lokale) Endnummer NNN mappen. + Default ist die letzte Ziffer der Nummer. DP-Zeile ("Dial Prefix") @@ -844,6 +893,7 @@ Mod: implementiert) $ Die Befehlszeile wird nicht direkt ausgeführt, sondern der Shell übergeben. E Beim Auftreten eines Fehlers wird dieses Programm deaktiviert. + (Reaktivieren: AT/R.) D /dev/ttyiXX wird angelegt und nach Programmende gelöscht. F Das Programm wird sofort gestartet, und die Verbindung wird aufgebaut. Interessant insbesondere bei Festverbindungen und SPVs. @@ -910,10 +960,10 @@ framelo ... oder die unteren Bits. Sinnvoll dann, wenn jemand den Daten- CL-Zeile ("Card Limit") -------- -Form: CL +Form: CL Beispiel> -CM Tel? 2 +CM Tel? * 2 Begrenzt die Zahl der verwendbaren B-Kanäle einer Karte. Ueber das Limit hinausgehende Anrufe werden mit BUSY abgelehnt, es sei denn in der entsprechenden P-Zeile steht der entsprechende Parameter. @@ -925,7 +975,8 @@ LF-Zeile ("Load File") Form: LF Lädt die Datei auf die (aktive) Karte. Mehrere LF-Zeilen können angegeben -werden. +werden (in der richtigen Reihenfolge!). Die maximal mögliche Segmentgröße +ist 4096. RP-Zeile ("Run Program") @@ -1030,6 +1081,10 @@ Paketformat: :.N TCP/IP (Default). :.E Ethernet-Paketheader. :.P PPP-Paketheader. +:eT xxxx xxxx: hexadezimal. Angabe des übertragenen Pakettyps (:.N). + TCP/IP ist 0800 (Default). Damit können zB statt + "nackter" IP-Pakete ebensolche Appletalk-Pakete + übertragen werden. ioctl(x,SIOCGETU,int) ioctl-Aufruf zur Uebertragung der Unit-Nummer ("strX", 0 <= X <= 15) an ein Anwenderprogramm. Das Programm kann damit die IP- @@ -1394,3 +1449,53 @@ Beispiel: Ansonsten: Sich von der Gegenstelle anrufen zu lassen und die betreffenden Daten einfach einzutragen ist wohl die einfachste Methode. + +Karten mit CAPI: Die CAPI ist doof... +=============== + +Im Internet heißt es in so gut wie jedem RFC, daß reservierte Bits beim +Senden auf Null zu setzen und beim Empfangen zu ignorieren sind. Nicht so +in der CAPI 1.1, dort sind gesetzte reservierte Bits ein Grund für eine +Fehlermeldung. Da aber nirgends definiert oder abfragbar ist, welche Bits +eigentlich erlaubt sind, ist es so gut wie unmöglich, ohne Ratespiel neue +Features zu unterstützen... + +Wie dem auch sei, die Infobits haben folgende Bedeutung: +00000001 Gebühreneinheiten +00000002 Datum +00000004 Display +00000008 User-User Info +00000010 Cause +00000020 Status des gerufenen Teilnehmers +00000040... +80000000 reserviert + +Die EAZ-Bits: +0001 Null ("Global Call", wird aber nicht besonders behandelt) +0002 Eins ... +0200 Neun +0400... +8000 reserviert + +Die Dienstkennungen, entsprechend :sv 00xx ... 0Fxx: +0001 Bildtelefon +0002 Telefonie +0004 a/b-Dienste +0008 X.21-Dienste +0010 Telefax Gruppe 4 +0020 BTX, 64 KBit/sec +0040 ? +0080 DFÜ +0100 X.25 +0200 Teletext +0400 Mixed Mode +0800 ? +1000 ? +2000 Fernwirken +4000 Grafiktelefon +8000 BTX (CEPT-Standard) + +Ankommende Rufe, die zu diesen EAZs und Diensten passen, werden +durchgereicht (und die angeforderten Informationen werden gemeldet, wenn +die Vermittlung sie sendet(!)); andere Rufe werden ignoriert. + diff --git a/Make.config b/Make.config new file mode 100644 index 0000000..f18eeac --- /dev/null +++ b/Make.config @@ -0,0 +1,46 @@ +.PHONY: dummy + + +SHELL = /bin/sh + +## =()@>()= +CARDS = teles +## =()@>()= +PROTOCOLS = phone tei +## =()@>()= +SUBPROTOCOLS = euro german + +## =()@>()= +KERNELSRC := /usr/src/linux + +ifdef KERNEL +## =()@>()= +CC = gcc +## =()@ >()= +CFLAGS = -g -O2 -Wall -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE + +else + +## =()@>()= +CC = gcc +## =()@ >()= +CFLAGS = -g -O2 -Wall +## =()@>()= +LIBS = -lbsd +endif + + +## =()@>()= +DESTDIR = /usr/local/isdn +## =()@>()= +LD = ld +## =()@>()= +LDFLAGS = +## =()@>()= +RANLIB = echo +## =()@>()= +STR_IF = str_linux +## =()@>()= +SYS = linux + + diff --git a/Make.rules b/Make.rules new file mode 100644 index 0000000..cab3554 --- /dev/null +++ b/Make.rules @@ -0,0 +1,241 @@ +# This Makefile is chaotic. Sorry. +# It gets (most of) the job done and that's what counts. +# + +all:: first_rule + +unexport KERNEL +unexport PROGRAM +unexport PROGRAMS +unexport CC +unexport CFLAGS +unexport SOURCES +unexport HEADERS +unexport LIB +unexport LIBS +unexport OBJ +unexport OBJS +unexport DOCARDS +unexport WHAT +unexport REALSOURCE +unexport DOSRC + +ifneq ($(strip $(DOCARDS)),) +KERNEL=1 +endif + +include $(TOPDIR)/Make.config + +export KERNELSRC +export TOPDIR + +VERSION := $(shell $(TOPDIR)/tools/getversion $(KERNELSRC)) + +.PHONY: dummy + +ifeq ($(strip $(HEADERS)),) +HEADERS := $(wildcard *.h) +endif + +DOSRC:=1 +ifneq ($(strip $(REALSOURCE)),) +DOSRC:=0 +endif +ifneq ($(strip $(DOCARDS)),) +DOSRC:=1 +endif + +ifeq ($(DOSRC),1) +ifneq ($(strip $(KERNEL)),) +ifeq ($(strip $(SOURCES)),) +SOURCES := $(wildcard *.c) +endif +else +ifeq ($(strip $(PSOURCES)),) +PSOURCES := $(wildcard *.c) +endif +endif +endif + +ifneq ($(strip $(DOCARDS)),) +OLDSOURCES := $(SOURCES) +SOURCES := $(filter $(addsuffix .c,$(CARDS)),$(SOURCES)) +endif + + +INCLUDES = -I$(TOPDIR)/include -I$(TOPDIR)/compat -I$(TOPDIR)/streams -I$(KERNELSRC)/include $(EXTRA_INCLUDES) + +first_rule:: libs programs modules + + +all depend indent clean install:: +ifneq ($(strip $(SUBDIRS)),) + $(MAKE) WHAT=$@ subdirs + +subdirs:: + set -e; for i in $(SUBDIRS); do $(MAKE) TOPDIR=../$(TOPDIR) -C $$i $(WHAT); done +endif + +depend:: + +ifneq ($(strip $(SOURCES)),) +OBJS = $(addsuffix .o, $(basename $(SOURCES))) +endif +ifneq ($(strip $(PSOURCES)),) +POBJS = $(addsuffix .o, $(basename $(PSOURCES))) +ifeq ($(strip $(PROGRAM)),) +ifeq ($(strip $(PROGRAMS)),) +ifeq ($(strip $(LIB)),) +PROGRAMS = $(basename $(PSOURCES)) +endif +endif +endif +endif + +ifneq ($(strip $(REALSOURCE)),) +$(OBJS): $(REALSOURCE) + $(CC) $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) -DREALNAME=$(basename $@) -D_$(basename $@)_ -c -o $@ $< +else +ifeq ($(DOCARDS),1) +.c.o: + $(CC) $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) -DREALNAME=$(basename $@) -D_$(basename $@)_ -c -o $@ $< +else +.c.o: + $(CC) $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) -c -o $@ $< +endif +endif + +clean:: + rm -f .depend core + rm -f *.vi? +ifneq ($(strip $(TARGET)),) + rm -f $(TARGET) +endif +ifneq ($(strip $(POBJS)),) + rm -f $(POBJS) +endif +ifneq ($(strip $(OBJ)),) + rm -f $(OBJ) +endif +ifneq ($(strip $(OBJS)),) + rm -f $(OBJS) +endif +ifneq ($(strip $(PROGRAM)),) + rm -f $(PROGRAM) +endif +ifneq ($(strip $(filter-out $(NOCLEAN),$(PROGRAMS))),) + rm -f $(filter-out $(NOCLEAN),$(PROGRAMS)) +endif +ifneq ($(strip $(LIB)),) + rm -f $(LIB) +endif + +ifneq ($(strip $(PROGRAM)),) +programs:: $(PROGRAM) +$(PROGRAM): $(POBJS) $(filter %.a,$(LIBS) $(EXTRA_LIBS)) + $(CC) -o $@ $(POBJS) $(EXTRA_LIBS) $(LIBS) +else +ifneq ($(strip $(PROGRAMS)),) +programs:: $(PROGRAMS) + +%: %.o $(filter %.a,$(LIBS) $(EXTRA_LIBS)) + $(CC) $(LDFLAGS) -o $@ $< $(EXTRA_LIBS) $(LIBS) +else +programs:: + +endif +endif + +ifneq ($(strip $(PROGRAMS)),) +programs:: $(PROGRAMS) + +else +programs:: + +endif + +ifneq ($(strip $(LIB)),) +libs: $(LIB) + +$(LIB): $(POBJS) + rm -f $@ + $(AR) rcs $@ $^ +else +libs: +endif + + +lib:: +ifneq ($(strip $(P_LIB)),) + $(MAKE) $(P_OBJ) +endif + +ifneq ($(strip $(OBJS)),) +ifeq ($(strip $(OBJ)),) +modules: $(OBJS) +else +modules: $(OBJ) + +$(OBJ): $(OBJS) + $(LD) -r -o $@ $^ +endif + +else +modules: + +endif + +install:: +ifeq ($(strip $(KERNEL)),1) +ifneq ($(strip $(OBJ)),) + $(TOPDIR)/tools/insmod $(OBJ) +else +ifeq ($(strip $(DOCARDS)),1) + $(foreach OBJ,$(OBJS),$(TOPDIR)/tools/d_insmod $(OBJ); ) +else + $(foreach OBJ,$(OBJS),$(TOPDIR)/tools/insmod $(OBJ); ) +endif +endif +else +ifneq ($(strip $(PROGRAM)),) + install $(PROGRAM) $(DESTDIR)/bin-$(VERSION) +endif +ifneq ($(strip $(PROGRAMS)),) + install $(PROGRAMS) $(DESTDIR)/bin-$(VERSION) +endif +endif + + +indent:: +ifneq ($(strip $(PSOURCES)),) + $(TOPDIR)/tools/indent.sh $(PSOURCES) +endif +ifneq ($(strip $(SOURCES)),) + $(TOPDIR)/tools/indent.sh $(SOURCES) +endif +ifneq ($(strip $(HEADERS)),) + $(TOPDIR)/tools/indent.sh $(HEADERS) +endif + +ifeq (.depend,$(wildcard .depend)) +include .depend +endif + +depend:: + rm -f .depend + +ifneq ($(strip $(PSOURCES)),) +depend:: Makefile $(PSOURCES) $(HEADERS) + $(CC) -M $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) $(PSOURCES) >> .depend +endif + +ifneq ($(strip $(SOURCES)),) +ifneq ($(strip $(REALSOURCE)),) +depend:: Makefile $(REALSOURCE) $(HEADERS) + $(foreach SOURCE,$(SOURCES), $(CC) -M $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) $(REALSOURCE) -D_$(SOURCE:.c=)_ | sed -e s/$(REALSOURCE:.c=.o)/$(SOURCE:.c=.o)/ >> .depend ; ) +else +depend:: Makefile $(SOURCES) $(HEADERS) + $(CC) -M $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) $(SOURCES) >> .depend +endif +endif + diff --git a/Makefile b/Makefile index 063d916..61a6ac4 100644 --- a/Makefile +++ b/Makefile @@ -1,48 +1,19 @@ +# config and include are first, tools is next +SUBDIRS = config include tools compat streams support isdn_3 isdn_4 \ + ksupport isdn_2 str_if cards x75 alaw tools van_j strslip \ + v110 pr_on strslip fakeh t70 rate timer reconnect ip_mon -# config and include are first, final is last -DIRS = config compat streams include bin support isdn_3 isdn_4 \ - ksupport isdn_2 str_if cards x75 alaw \ - v110 pr_on strslip fakeh t70 rate timer reconnect ip_mon final -ADIRS = config include bin support isdn_3 isdn_4 str_if ip_mon alaw tools -KDIRS = config compat streams include ksupport isdn_2 str_if cards x75 \ - alaw v110 pr_on strslip fakeh t70 rate timer reconnect ip_mon final -# dumbmgr portman port_m - -SYSTEMS = linux -#SYSTEMS = aux sco svr4 linux - -all prog:: .depend - -.depend: - @$(MAKE) $(MAKEFLAGS) depend - @touch .depend - -all update load:: - set -e;for i in $(KDIRS);do echo -n "$$i: "; $(MAKE) $(MAKEFLAGS) -C $$i $@ ; done - -prog:: - set -e;for i in $(ADIRS);do echo -n "$$i: "; $(MAKE) $(MAKEFLAGS) -C $$i $@ ; done - -depend clean indent:: - set -e;for i in $(DIRS);do echo -n "$$i: "; $(MAKE) $(MAKEFLAGS) -C $$i $@ ; done - -install: all - $(MAKE) $(MAKEFLAGS) -C final doinstall - -conf: - cd config ; $(MAKE) $(MAKEFLAGS) - -clean:: - for i in $(ALLDIRS) ; do ( cd $$i; \ - for j in $(SYSTEMS) ; do echo $$i/$$j ; \ - sh ../iftrue.sh "-d $$j" "cd $$j ; $(MAKE) $(MAKEFLAGS) clean" ; done \ - ) ; done - find . -name .depend -print|xargs rm -f - rm -f .toldem - -iprog: - cd final && $(MAKE) $(MAKEFLAGS) install.bin - +.PHONY: depend +all:: .diddepend dep: depend +TOPDIR=. +include Make.rules + +.diddepend:: Makefile + $(MAKE) depend + touch .diddepend + +clean:: + rm -f .toldem .diddepend diff --git a/README b/README index 17c0f72..175cff7 100644 --- a/README +++ b/README @@ -4,6 +4,46 @@ Die Anleitung und der ganze Kram findet sich in der Datei DOKU, oder README.isdn in den Kernelsourcen. +*** 1995-10-21 + +Release 14. + +Mit dem RP-Zeilen gibt es anscheinend Probleme. Wäre nett, wenn das jemand +anders debuggen könnte, sonst dauert das nämlich bis Version 16 oder so. + +Wer kennt sich mit tcl/tk oder tclperl oder wish oder was-auch-immer aus? +Gebraucht wird ein vernünftiges Frontend für die Konfigdatei... + +Login und Kermit, nächster Versuch... + +Aktive Karten (momentan: Bintec) tun NOCH NICHT, aber ich arbeite dran. + +Mehr Kommentare im Source. (Immer noch zuwenige, ich weiß. Working.) + +Fehler bereinigt. Insbesondere sollte der Treiber nun ca. eine Sekunde +schneller sein beim Verbindungsaufbau, wenn gerade keine andere Verbindung +offen ist. Grr... + +Debugmeldungen schreiben nun das Intervall (in Jiffies, also normalerweise +Hundertstelsekunden) seit der letzten Debugmeldung mit. + +ACHTUNG, leichte Änderungen im Format der Konfigdatei (DL- und CL-Zeile: +-Parameter ist dazugekommen); siehe Doku. + +Kann jemand aus Taylor-UUCP (oder sonstwoher) den Code "ist die aktuelle +Zeit in dem durch diesen String angegebenen Zeitfenster" klauen und um die +Angabe der Anzahl Sekunden bis zum Verlassen des Zeitfensters erweitern? +Beispiel: wenn es jetzt Sonntag 23:00:01 Uhr ist: +- isintime("Mon") => 0 +- isintime("Sun") => 3599 +Sonst muß ich das machen und dafür habe ich keine Zeit. Das Ganze wird +benötigt, um zB Logins nur abends zu erlauben oder den Zeittakt +umzustellen. Momentan braucht es dazu ein per cron aufgerufenes externes +Programm, das /etc/isdn.conf.times von isdn.conf.times.day nach +isdn.conf.times.night umlinkt und AT/R anstößt; geht, aber ist nicht +besonders schön. + + *** 1995-09-31 Release 13. diff --git a/alaw/Makefile b/alaw/Makefile index 6fd6a28..a878658 100644 --- a/alaw/Makefile +++ b/alaw/Makefile @@ -1,66 +1,7 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = -## =()@>()= -CCU = gcc -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@ >()= -DEFSN = -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -## =()@ $(DEFSN)>()= -NCFLAGS = -O2 -Wall $(DEFSN) -## =()@>()= -LIBS = -lbsd -## =()@>()= -LDFLAGS = -v +KERNEL=1 +SUBDIRS=tools -## =()@>()= -SYS = linux - -SOURCES = alaw.c -OBJ = alaw.o tosnd.o toalaw.o -ALL = tosnd toalaw - -all: alaw.o -prog: tosnd toalaw - -toalaw: toalaw.o - ${CCU} ${LDFLAGS} -o $@ toalaw.o ${LIBS} -tosnd: tosnd.o - ${CCU} ${LDFLAGS} -o $@ tosnd.o ${LIBS} -toalaw.o: toalaw.c - ${CCU} ${NCFLAGS} -c toalaw.c -tosnd.o: tosnd.c - ${CCU} ${NCFLAGS} -c tosnd.c - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -clean: - rm -f $(ALL) $(OBJ) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - insmod alaw.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/alaw/dtmf/dtmf.c b/alaw/dtmf/dtmf.c new file mode 100644 index 0000000..cfa0249 --- /dev/null +++ b/alaw/dtmf/dtmf.c @@ -0,0 +1,251 @@ +/* + Code to extract Touch-Tones from PCM Sample Data + sample data is assumed to be signed 8 bit, sampled at 8000 HZ + written by Johannes Deisenhofer 14.6.95 +*/ + +#include +#include +#include + +#undef DEBUG + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* Our timebase, sampling frequency for ISDN */ +#define BUFFREQU 8000 + +/* We check samples of this length */ +/* min 128, max. 512 */ +#define CHUNKLEN 512 + +/* Soviele aufeinanderfolgende DTMF-Toene muessen uebereinstimmen, mind. 1 */ +#define PROOF 1 + +/* Mindestpegel fuer Erkennung eines Touchtones */ +#define MINPEGEL 20000 + +/* Minimaler Faktor, um den der Pegel eines Tones hoeher als der naechste */ +/* sein muss */ +#define MINDIFF 30 + +#define DATA_IS_SIGNED + + +#ifdef DATA_IS_SIGNED +#define DATAFORM signed +#define SUB 0x0 +#else +#define DATAFORM unsigned +#define SUB 0x80 +#endif + + +/* Touch-Tone Frequencies in Hz */ +/* from CCC Hackerbibel #1 */ + +int frequencies[] = + { + 1209, 1336, 1477 , /* Rows */ + 697 , /* 1 2 3 */ + 770 , /* 4 5 6 */ + 852 , /* 7 8 9 */ + 941 /* * 0 # */ + }; + +/* Key mapping */ +static char taste[] = + { '1' , '2' , '3' , + '4' , '5' , '6' , + '7' , '8' , '9' , + '*' , '0' , '#' }; + + +/* sin/cos table, calculated for max.chunksize 512 */ +extern signed char dtmfpre[7][512*2]; + +#ifdef PRECALC +/* initialize sine-table */ +int fillpre(void) +{ + int k,x; + for(k=0;k<7;k++) + { + char* cmpr=dtmfpre[k]; + for(x=0;xvalval) + { + stx = *s2; + *s2=*s1; + *s1=stx; + } +} + + +int checkchunk(char* buf, int len) +{ + int row,col,k,valid; + struct st tbl[7]; + for (k= 0; k<7;k++) + { + tbl[k].num = k; + tbl[k].val = fk(buf,k,len); +#ifdef DEBUG + /* If you want to play with the heuristics below, you probably */ + /* need to know the koefficients. Uncomment this */ + fprintf(stderr,"%6d ",tbl[k].val); +#endif + } + + /* Hard-coded bubble-Sort */ + /* First the rows */ + swap(tbl,tbl+1); + swap(tbl+1,tbl+2); + swap(tbl,tbl+1); + + /* Then columns */ + swap(tbl+3,tbl+4); + swap(tbl+4,tbl+5); + swap(tbl+5,tbl+6); + swap(tbl+3,tbl+4); + swap(tbl+4,tbl+5); + swap(tbl+3,tbl+4); + + /* Highest Coeff. is row or col */ + row=tbl[0].num; + col=tbl[3].num-3; + + /* Diese (heuristische) Regel bestimmt, ob es sich um einen */ + /* DTMF-Ton handelt oder nicht. Abhaengig vom Pegel der Toene */ + /* Und der gewuenschten Erkennungssicherheit */ + + valid = (tbl[0].val>tbl[1].val*MINDIFF) + && (tbl[3].val>tbl[4].val*MINDIFF) + && (tbl[0].val>MINPEGEL) + && (tbl[3].val>MINPEGEL); + + #ifdef DEBUG + fprintf(stderr,"Taste: %c\n",valid?taste[row+col*3]:'?'); + #endif + + if (!valid) return -1; + else return row+col*3; +} + + +/* + Main-Routine: von stdin lesen und auf DTMF testen, + Erkannte Tasten nach stderr +*/ + +char buffer[CHUNKLEN]; + +int main(int argc, char**argv) +{ + int val, l1val=-1,same=0; + int inbuf; + int buflen; + int count=0; + do { + /* Fill input buffer */ + inbuf=0; + do { + buflen=fread(buffer,1,sizeof(buffer)-inbuf,stdin); + inbuf+=buflen; + } while (!feof(stdin) && inbuf < sizeof(buffer) ); + if (inbuf>=CHUNKLEN ) + { + val=checkchunk(buffer,CHUNKLEN); + if (val==l1val ) same++; + else same=0; + if (same==(PROOF-1) && l1val!=-1) + { + fprintf(stderr,"Taste %c\n",taste[l1val]); + } + l1val=val; + } + } while(!feof(stdin)); +} + + diff --git a/alaw/dtmf/dtmfsin.c b/alaw/dtmf/dtmfsin.c new file mode 100644 index 0000000..bff6a68 --- /dev/null +++ b/alaw/dtmf/dtmfsin.c @@ -0,0 +1,459 @@ +signed char dtmfpre[7][512*2] + = +{ { + 0, 127, 103, 73, 120, -40, 36,-121, -77,-100,-126, 4, -70, 105, 45, 118, + 122, 32, 97, -81, -8,-126,-108, -66,-117, 49, -27, 123, 84, 94, 126, -13, + 62,-110, -53,-115,-124, -23, -91, 87, 17, 125, 112, 58, 113, -57, 19,-125, + -90, -88,-125, 22, -54, 114, 61, 111, 126, 14, 85, -94, -26,-124,-116, -50, + -108, 65, -10, 126, 96, 82, 123, -31, 46,-118, -69,-106,-126, -5, -78, 99, + 35, 121, 119, 42, 104, -72, 1,-126,-102, -74,-120, 39, -37, 121, 76, 101, + 126, -3, 71,-105, -43,-119,-122, -33, -98, 80, 7, 126, 107, 67, 117, -48, + 29,-123, -83, -95,-126, 12, -63, 109, 52, 115, 124, 24, 92, -86, -16,-125, + -112, -59,-113, 56, -20, 125, 90, 89, 125, -21, 55,-114, -60,-111,-125, -16, + -86, 93, 25, 124, 115, 51, 109, -64, 11,-126, -96, -83,-123, 29, -47, 117, + 68, 107, 126, 7, 79, -98, -34,-122,-119, -43,-104, 71, -2, 126, 101, 76, + 121, -38, 39,-120, -75,-102,-126, 1, -72, 104, 42, 119, 122, 34, 99, -79, + -6,-126,-106, -68,-118, 46, -30, 123, 82, 96, 126, -10, 64,-109, -51,-116, + -124, -26, -93, 85, 15, 126, 111, 60, 114, -55, 21,-125, -89, -90,-125, 19, + -56, 113, 59, 112, 125, 17, 87, -92, -24,-124,-115, -52,-110, 63, -12, 126, + 95, 83, 123, -28, 48,-117, -66,-107,-126, -8, -80, 98, 32, 122, 118, 44, + 105, -70, 3,-126,-100, -77,-121, 37, -40, 120, 74, 102, 126, 0, 73,-103, + -41,-120,-121, -36,-100, 77, 5, 126, 106, 69, 118, -45, 31,-122, -81, -97, + -126, 9, -65, 108, 49, 116, 124, 27, 94, -84, -14,-126,-110, -62,-114, 53, + -23, 124, 88, 91, 125, -18, 58,-112, -58,-112,-125, -18, -88, 91, 22, 124, + 114, 54, 110, -61, 14,-126, -94, -84,-124, 27, -49, 116, 65, 108, 126, 9, + 81, -97, -31,-122,-118, -45,-106, 69, -5, 126, 100, 78, 121, -36, 41,-119, + -73,-103,-126, 0, -74, 102, 40, 120, 121, 37, 101, -76, -3,-126,-105, -70, + -118, 44, -33, 122, 80, 98, 126, -8, 67,-107, -48,-117,-123, -28, -95, 83, + 12, 126, 110, 63, 115, -52, 24,-124, -87, -92,-125, 17, -59, 112, 56, 113, + 125, 19, 89, -90, -21,-125,-114, -55,-111, 60, -15, 126, 93, 85, 124, -26, + 51,-116, -64,-109,-126, -10, -82, 96, 30, 123, 117, 47, 106, -68, 6,-126, + -99, -79,-122, 34, -42, 119, 72, 104, 126, 1, 75,-102, -39,-120,-120, -38, + -101, 75, 2, 126, 104, 71, 119, -43, 34,-122, -79, -99,-126, 6, -68, 107, + 47, 117, 123, 29, 96, -82, -11,-126,-109, -64,-116, 51, -25, 124, 86, 93, + 125, -15, 60,-111, -55,-114,-125, -21, -90, 89, 20, 125, 113, 56, 112, -59, + 16,-125, -92, -86,-124, 24, -52, 115, 63, 109, 126, 12, 83, -95, -29,-123, + -117, -48,-107, 67, -7, 126, 98, 80, 122, -33, 44,-119, -71,-105,-126, -3, + -76, 101, 37, 121, 120, 39, 102, -74, -1,-126,-103, -72,-119, 42, -35, 121, + 78, 99, 126, -5, 69,-106, -46,-118,-123, -31, -97, 81, 10, 126, 108, 65, + 116, -50, 26,-124, -85, -94,-126, 14, -61, 111, 54, 114, 125, 22, 90, -88, + -19,-125,-113, -57,-112, 58, -17, 125, 91, 87, 124, -23, 53,-115, -62,-110, + -126, -13, -84, 94, 27, 123, 116, 49, 108, -66, 9,-126, -97, -81,-122, 32, + -45, 118, 70, 105, 126, 4, 77,-100, -36,-121,-120, -41,-103, 73, 0, 126, + 103, 74, 120, -40, 36,-121, -77,-100,-126, 4, -70, 105, 45, 118, 122, 32, + 97, -80, -8,-126,-108, -66,-117, 49, -28, 123, 84, 94, 126, -13, 62,-110, + -53,-115,-124, -23, -91, 87, 17, 125, 112, 58, 113, -57, 19,-125, -90, -88, + -125, 22, -54, 114, 61, 111, 126, 14, 85, -93, -26,-124,-116, -50,-108, 65, + -10, 126, 96, 82, 123, -31, 46,-118, -69,-106,-126, -5, -78, 99, 35, 121, + 119, 42, 104, -72, 1,-126,-102, -75,-120, 39, -38, 121, 76, 101, 126, -3, + 71,-105, -43,-119,-122, -33, -98, 79, 7, 126, 107, 67, 117, -48, 29,-123, + -83, -95,-126, 12, -63, 109, 52, 115, 124, 24, 92, -86, -16,-125,-112, -59, + -113, 56, -20, 125, 89, 89, 125, -20, 55,-114, -60,-111,-125, -16, -86, 93, + 25, 124, 115, 51, 109, -64, 11,-126, -96, -83,-123, 29, -47, 117, 67, 107, + 126, 7, 79, -98, -34,-122,-119, -43,-104, 71, -2, 126, 101, 76, 121, -38, + 39,-120, -75,-102,-126, 1, -72, 104, 42, 119, 122, 34, 99, -78, -6,-126, + -106, -68,-118, 46, -30, 123, 82, 96, 126, -10, 64,-109, -50,-116,-124, -26, + -93, 85, 15, 126, 111, 61, 114, -55, 21,-125, -89, -90,-125, 19, -57, 113, + 59, 112, 125, 17, 87, -92, -24,-124,-115, -52,-110, 63, -12, 126, 95, 84, + 123, -28, 48,-117, -66,-107,-126, -8, -80, 98, 32, 122, 118, 44, 105, -70, + 3,-126,-100, -77,-121, 37, -40, 120, 74, 102, 126, 0, 73,-103, -41,-120, + -121, -36,-100, 77, 4, 126, 106, 69, 118, -45, 31,-122, -81, -97,-126, 9, + -66, 108, 49, 116, 123, 27, 94, -84, -13,-126,-110, -62,-114, 53, -23, 124, + 88, 91, 125, -18, 58,-112, -57,-113,-125, -18, -88, 91, 22, 124, 114, 54, + 110, -61, 14,-126, -94, -85,-124, 27, -50, 116, 65, 108, 126, 9, 81, -97, + -31,-123,-118, -45,-106, 69, -5, 126, 100, 78, 121, -35, 41,-119, -73,-103, + -126, 0, -74, 102, 40, 120, 121, 37, 101, -76, -3,-126,-105, -70,-118, 44, + -33, 122, 80, 98, 126, -8, 67,-107, -48,-117,-123, -28, -95, 83, 12, 126, + 110, 63, 115, -52, 24,-124, -87, -92,-125, 17, -59, 112, 56, 113, 125, 19, +} , { + 0, 127, 110, 63, 109, -63, 0,-126,-110, -62,-109, 64, 1, 126, 110, 61, + 108, -65, -2,-126,-111, -61,-108, 66, 3, 126, 111, 60, 108, -66, -3,-126, + -112, -59,-107, 67, 4, 126, 112, 59, 107, -68, -5,-126,-112, -58,-106, 68, + 6, 126, 113, 57, 106, -69, -7,-126,-113, -56,-105, 70, 7, 126, 113, 56, + 105, -70, -8,-126,-114, -55,-105, 71, 9, 126, 114, 54, 104, -72, -10,-126, + -114, -54,-104, 72, 11, 126, 115, 53, 103, -73, -11,-126,-115, -52,-103, 74, + 12, 126, 115, 51, 102, -74, -13,-126,-116, -51,-102, 75, 14, 126, 116, 50, + 101, -75, -15,-126,-116, -49,-101, 76, 15, 125, 117, 48, 100, -77, -16,-125, + -117, -48,-100, 77, 17, 125, 117, 47, 99, -78, -18,-125,-118, -46, -99, 79, + 19, 125, 118, 46, 98, -79, -19,-125,-118, -45, -98, 80, 20, 125, 118, 44, + 97, -80, -21,-125,-119, -43, -97, 81, 22, 125, 119, 43, 96, -82, -23,-124, + -119, -42, -96, 82, 23, 124, 120, 41, 95, -83, -24,-124,-120, -40, -95, 83, + 25, 124, 120, 40, 94, -84, -26,-124,-120, -39, -94, 85, 26, 124, 121, 38, + 93, -85, -27,-123,-121, -37, -93, 86, 28, 123, 121, 36, 92, -86, -29,-123, + -121, -36, -92, 87, 30, 123, 121, 35, 91, -88, -30,-123,-122, -34, -90, 88, + 31, 123, 122, 33, 90, -89, -32,-122,-122, -33, -89, 89, 33, 122, 122, 32, + 89, -90, -33,-122,-123, -31, -88, 90, 34, 122, 123, 30, 88, -91, -35,-121, + -123, -30, -87, 92, 36, 121, 123, 29, 86, -92, -36,-121,-123, -28, -86, 93, + 37, 121, 123, 27, 85, -93, -38,-121,-124, -26, -85, 94, 39, 120, 124, 26, + 84, -94, -40,-120,-124, -25, -83, 95, 40, 120, 124, 24, 83, -95, -41,-120, + -124, -23, -82, 96, 42, 119, 124, 23, 82, -96, -43,-119,-125, -22, -81, 97, + 43, 119, 125, 21, 80, -97, -44,-118,-125, -20, -80, 98, 45, 118, 125, 19, + 79, -98, -46,-118,-125, -19, -79, 99, 46, 118, 125, 18, 78, -99, -47,-117, + -125, -17, -77, 100, 48, 117, 125, 16, 77,-100, -48,-117,-125, -15, -76, 101, + 49, 116, 126, 15, 75,-101, -50,-116,-126, -14, -75, 102, 51, 116, 126, 13, + 74,-102, -51,-115,-126, -12, -74, 103, 52, 115, 126, 11, 73,-103, -53,-115, + -126, -11, -72, 104, 54, 114, 126, 10, 72,-104, -54,-114,-126, -9, -71, 105, + 55, 114, 126, 8, 70,-105, -56,-113,-126, -7, -70, 105, 56, 113, 126, 7, + 69,-106, -57,-113,-126, -6, -68, 106, 58, 112, 126, 5, 68,-107, -59,-112, + -126, -4, -67, 107, 59, 112, 126, 3, 66,-108, -60,-111,-126, -3, -66, 108, + 61, 111, 126, 2, 65,-108, -61,-110,-126, -1, -64, 109, 62, 110, 126, 0, + 63,-109, -63,-110,-127, 0, -63, 110, 63, 109, 126, 0, 62,-110, -64,-109, + -126, 1, -61, 110, 65, 108, 126, -2, 61,-111, -66,-108,-126, 3, -60, 111, + 66, 108, 126, -3, 59,-112, -67,-107,-126, 4, -59, 112, 68, 107, 126, -5, + 58,-112, -68,-106,-126, 6, -57, 113, 69, 106, 126, -7, 56,-113, -70,-105, + -126, 7, -56, 113, 70, 105, 126, -8, 55,-114, -71,-105,-126, 9, -54, 114, + 72, 104, 126, -10, 54,-114, -72,-104,-126, 11, -53, 115, 73, 103, 126, -11, + 52,-115, -74,-103,-126, 12, -51, 115, 74, 102, 126, -13, 51,-116, -75,-102, + -126, 14, -50, 116, 75, 101, 126, -15, 49,-116, -76,-101,-125, 15, -48, 117, + 77, 100, 125, -16, 48,-117, -77,-100,-125, 17, -47, 117, 78, 99, 125, -18, + 46,-118, -79, -99,-125, 19, -46, 118, 79, 98, 125, -19, 45,-118, -80, -98, + -125, 20, -44, 118, 80, 97, 125, -21, 43,-119, -81, -97,-125, 22, -43, 119, + 82, 96, 124, -23, 42,-119, -82, -96,-124, 23, -41, 120, 83, 95, 124, -24, + 40,-120, -83, -95,-124, 25, -40, 120, 84, 94, 124, -26, 39,-120, -85, -94, + -124, 26, -38, 121, 85, 93, 123, -27, 37,-121, -86, -93,-123, 28, -36, 121, + 86, 92, 123, -29, 36,-121, -87, -92,-123, 30, -35, 121, 88, 91, 123, -30, + 34,-122, -88, -90,-123, 31, -33, 122, 89, 90, 122, -32, 33,-122, -89, -89, + -122, 33, -32, 122, 90, 89, 122, -33, 31,-123, -90, -88,-122, 34, -30, 123, + 91, 88, 121, -35, 30,-123, -92, -87,-121, 36, -29, 123, 92, 86, 121, -36, + 28,-123, -93, -86,-121, 37, -27, 123, 93, 85, 121, -38, 26,-124, -94, -85, + -120, 39, -26, 124, 94, 84, 120, -40, 25,-124, -95, -83,-120, 40, -24, 124, + 95, 83, 120, -41, 23,-124, -96, -82,-119, 42, -23, 124, 96, 82, 119, -43, + 22,-125, -97, -81,-119, 43, -21, 125, 97, 80, 118, -44, 20,-125, -98, -80, + -118, 45, -19, 125, 98, 79, 118, -46, 19,-125, -99, -79,-118, 46, -18, 125, + 99, 78, 117, -47, 17,-125,-100, -77,-117, 48, -16, 125, 100, 77, 117, -48, + 15,-125,-101, -76,-116, 49, -15, 126, 101, 75, 116, -50, 14,-126,-102, -75, + -116, 51, -13, 126, 102, 74, 115, -51, 12,-126,-103, -74,-115, 52, -11, 126, + 103, 73, 115, -53, 11,-126,-104, -72,-114, 54, -10, 126, 104, 72, 114, -54, + 9,-126,-105, -71,-114, 55, -8, 126, 105, 70, 113, -56, 7,-126,-105, -70, + -113, 56, -7, 126, 106, 69, 113, -57, 6,-126,-106, -68,-112, 58, -5, 126, + 107, 68, 112, -59, 4,-126,-107, -67,-112, 59, -3, 126, 108, 66, 111, -60, + 3,-126,-108, -66,-111, 61, -2, 126, 108, 65, 110, -61, 1,-126,-109, -64, + -110, 62, 0, 126, 109, 63, 110, -63, 0,-127,-110, -63,-109, 63, 0, 126, + 110, 62, 109, -64, -1,-126,-110, -61,-108, 65, 2, 126, 111, 61, 108, -66, +} , { + 0, 127, 116, 50, 92, -86, -42,-119,-126, -9, -58, 112, 79, 98, 122, -33, + 18,-125,-107, -66,-104, 72, 24, 124, 124, 27, 74,-102, -64,-109,-126, 15, + -36, 121, 97, 81, 113, -56, -6,-126,-118, -44, -88, 90, 48, 117, 126, 2, + 53,-115, -84, -94,-120, 39, -12, 126, 111, 61, 100, -77, -30,-123,-125, -21, + -69, 106, 69, 106, 125, -21, 30,-123,-101, -76,-110, 61, 12, 126, 120, 38, + 83, -95, -53,-115,-126, 3, -47, 117, 88, 90, 118, -45, 5,-126,-114, -55, + -96, 82, 36, 121, 126, 14, 64,-109, -74,-102,-123, 27, -23, 124, 104, 71, + 107, -67, -18,-125,-122, -32, -79, 99, 59, 112, 126, -9, 41,-119, -93, -86, + -116, 51, 0, 126, 116, 50, 92, -86, -42,-119,-126, -8, -58, 112, 79, 98, + 122, -33, 17,-125,-108, -66,-104, 72, 24, 124, 124, 26, 74,-103, -64,-109, + -125, 15, -35, 121, 97, 81, 113, -56, -6,-126,-118, -44, -88, 91, 48, 117, + 126, 2, 52,-115, -84, -94,-120, 39, -11, 126, 111, 61, 100, -77, -31,-123, + -125, -20, -68, 106, 70, 105, 125, -22, 29,-123,-101, -76,-110, 62, 13, 126, + 121, 38, 83, -95, -54,-114,-126, 3, -47, 117, 89, 90, 118, -45, 5,-126, + -114, -55, -96, 82, 37, 121, 126, 14, 63,-109, -75,-102,-123, 28, -23, 124, + 105, 71, 107, -67, -19,-125,-122, -32, -78, 99, 59, 112, 126, -10, 41,-120, + -93, -85,-116, 51, 0, 126, 116, 49, 92, -87, -43,-119,-126, -8, -58, 112, + 80, 98, 122, -34, 17,-125,-108, -66,-103, 73, 25, 124, 124, 26, 73,-103, + -65,-108,-125, 16, -35, 122, 97, 81, 113, -57, -7,-126,-119, -43, -87, 91, + 48, 117, 126, 1, 52,-115, -85, -94,-120, 40, -11, 126, 111, 60, 100, -78, + -31,-123,-125, -20, -68, 106, 70, 105, 124, -22, 29,-123,-101, -76,-110, 62, + 13, 126, 121, 38, 83, -95, -54,-114,-126, 4, -46, 118, 89, 89, 118, -46, + 4,-126,-114, -55, -96, 82, 37, 121, 126, 13, 63,-110, -75,-101,-123, 28, + -23, 124, 105, 70, 107, -68, -19,-125,-122, -31, -78, 99, 60, 111, 126, -10, + 40,-120, -94, -85,-115, 52, 1, 126, 117, 49, 91, -87, -43,-119,-126, -7, + -57, 113, 80, 98, 122, -34, 16,-125,-108, -65,-103, 73, 25, 124, 124, 25, + 73,-103, -65,-108,-125, 16, -34, 122, 98, 80, 113, -57, -7,-126,-119, -43, + -87, 92, 49, 116, 126, 1, 51,-115, -85, -93,-120, 40, -10, 126, 111, 60, + 99, -78, -32,-122,-125, -19, -68, 107, 71, 105, 124, -23, 28,-123,-101, -75, + -110, 63, 14, 126, 121, 37, 82, -96, -55,-114,-126, 4, -46, 118, 90, 89, + 118, -46, 4,-126,-114, -54, -95, 83, 38, 121, 126, 13, 62,-110, -76,-101, + -123, 29, -22, 124, 105, 70, 106, -68, -20,-125,-123, -31, -77, 100, 60, 111, + 126, -11, 40,-120, -94, -85,-115, 52, 1, 126, 117, 48, 91, -87, -44,-119, + -126, -7, -57, 113, 81, 97, 121, -35, 16,-125,-108, -65,-103, 73, 26, 124, + 124, 25, 72,-103, -66,-108,-125, 17, -34, 122, 98, 80, 112, -58, -8,-126, + -119, -43, -87, 92, 49, 116, 126, 0, 51,-116, -85, -93,-120, 41, -10, 126, + 112, 59, 99, -78, -32,-122,-125, -19, -67, 107, 71, 104, 124, -23, 28,-123, + -102, -75,-109, 63, 14, 126, 121, 37, 82, -96, -55,-114,-126, 5, -45, 118, + 90, 89, 117, -47, 3,-126,-114, -54, -95, 83, 38, 120, 126, 12, 62,-110, + -76,-101,-123, 29, -22, 125, 105, 70, 106, -69, -20,-125,-123, -31, -77, 100, + 61, 111, 126, -11, 39,-120, -94, -84,-115, 52, 2, 126, 117, 48, 91, -88, + -44,-118,-126, -6, -56, 113, 81, 97, 121, -35, 15,-126,-109, -64,-103, 74, + 26, 124, 124, 24, 72,-104, -66,-108,-125, 17, -33, 122, 98, 79, 112, -58, + -8,-126,-119, -42, -86, 92, 50, 116, 126, 0, 51,-116, -86, -93,-119, 41, + -9, 126, 112, 59, 99, -79, -33,-122,-125, -18, -67, 107, 71, 104, 124, -24, + 27,-123,-102, -74,-109, 64, 15, 126, 121, 36, 82, -96, -56,-113,-126, 5, + -45, 118, 90, 88, 117, -47, 3,-126,-115, -53, -95, 84, 39, 120, 126, 12, + 61,-110, -76,-101,-123, 30, -21, 125, 106, 69, 106, -69, -21,-125,-123, -30, + -77, 100, 61, 111, 126, -12, 39,-120, -94, -84,-115, 53, 2, 126, 117, 47, + 90, -88, -44,-118,-126, -6, -56, 113, 81, 97, 121, -36, 15,-126,-109, -64, + -102, 74, 27, 124, 124, 24, 72,-104, -67,-107,-125, 18, -33, 122, 99, 79, + 112, -59, -9,-126,-119, -42, -86, 93, 50, 116, 126, 0, 50,-116, -86, -92, + -119, 42, -9, 126, 112, 58, 98, -79, -33,-122,-125, -18, -66, 107, 72, 104, + 124, -24, 27,-124,-102, -74,-109, 64, 15, 126, 121, 36, 81, -97, -56,-113, + -126, 6, -44, 118, 91, 88, 117, -48, 2,-126,-115, -53, -94, 84, 39, 120, + 126, 11, 61,-111, -77,-100,-123, 30, -21, 125, 106, 69, 106, -69, -21,-125, + -123, -30, -76, 101, 62, 110, 126, -12, 38,-120, -95, -83,-114, 53, 3, 126, + 117, 47, 90, -89, -45,-118,-126, -5, -55, 114, 82, 96, 121, -36, 14,-126, + -109, -63,-102, 75, 27, 123, 124, 23, 71,-104, -67,-107,-125, 18, -32, 122, + 99, 79, 112, -59, -9,-126,-119, -41, -86, 93, 51, 116, 126, 0, 50,-116, + -86, -92,-119, 42, -8, 126, 112, 58, 98, -80, -33,-122,-125, -17, -66, 108, + 72, 104, 124, -25, 26,-124,-103, -74,-109, 64, 16, 125, 121, 35, 81, -97, + -56,-113,-126, 6, -44, 119, 91, 88, 117, -48, 2,-126,-115, -52, -94, 84, + 40, 120, 126, 11, 61,-111, -77,-100,-123, 31, -20, 125, 106, 68, 105, -70, +} , { + 0, 127, 66, 108, 112, 58, 126, -9, 103, -73, 49,-116, -18,-125, -80, -97, + -120, -41,-124, 27, -91, 87, -32, 122, 35, 121, 94, 85, 124, 23, 118, -44, + 78, -99, 15,-126, -52,-115,-105, -71,-126, -5,-111, 60, -63, 110, 3, 126, + 68, 106, 114, 55, 126, -12, 101, -76, 47,-117, -21,-125, -83, -95,-120, -38, + -123, 30, -89, 89, -29, 123, 38, 120, 96, 83, 125, 20, 117, -47, 76,-101, + 11,-126, -55,-114,-106, -68,-126, -2,-109, 63, -60, 111, 6, 126, 71, 105, + 115, 52, 126, -15, 99, -78, 44,-119, -24,-124, -85, -93,-121, -35,-122, 33, + -87, 92, -26, 124, 41, 119, 98, 80, 125, 17, 116, -50, 73,-103, 8,-126, + -58,-112,-108, -65,-126, 0,-108, 66, -58, 112, 9, 126, 73, 103, 116, 49, + 125, -18, 97, -81, 41,-120, -27,-124, -87, -91,-122, -32,-121, 36, -85, 94, + -23, 124, 44, 118, 99, 78, 126, 14, 115, -52, 70,-105, 5,-126, -61,-111, + -110, -63,-126, 3,-106, 68, -55, 114, 12, 126, 76, 101, 118, 46, 125, -21, + 95, -83, 38,-121, -30,-123, -90, -89,-123, -29,-120, 38, -82, 96, -20, 125, + 47, 117, 101, 75, 126, 11, 114, -55, 68,-107, 2,-126, -63,-109,-111, -60, + -126, 6,-104, 71, -52, 115, 15, 126, 78, 99, 119, 44, 124, -24, 93, -85, + 35,-121, -33,-122, -92, -87,-124, -26,-119, 41, -80, 98, -17, 125, 50, 116, + 103, 73, 126, 8, 112, -58, 65,-108, 0,-126, -66,-108,-113, -57,-126, 9, + -103, 74, -49, 116, 18, 125, 81, 97, 120, 41, 124, -27, 91, -87, 32,-122, + -36,-121, -94, -85,-124, -23,-118, 44, -78, 100, -14, 126, 53, 115, 105, 70, + 126, 5, 111, -61, 63,-110, -3,-126, -69,-106,-114, -55,-126, 12,-101, 76, + -46, 118, 21, 125, 83, 95, 121, 38, 123, -30, 89, -90, 29,-123, -39,-120, + -96, -82,-125, -20,-117, 47, -75, 101, -11, 126, 55, 114, 107, 68, 126, 2, + 109, -63, 60,-111, -6,-126, -71,-104,-115, -52,-126, 15, -99, 78, -43, 119, + 24, 124, 85, 93, 122, 35, 122, -33, 87, -92, 26,-124, -42,-119, -98, -80, + -125, -17,-116, 50, -73, 103, -8, 126, 58, 112, 108, 65, 126, 0, 108, -66, + 57,-113, -9,-126, -74,-103,-116, -49,-125, 18, -97, 81, -40, 120, 27, 123, + 88, 91, 122, 32, 121, -36, 84, -94, 23,-124, -44,-118,-100, -77,-126, -14, + -115, 53, -70, 105, -5, 126, 61, 111, 110, 62, 126, -3, 106, -69, 54,-114, + -12,-126, -76,-101,-118, -46,-125, 21, -95, 83, -38, 121, 30, 123, 90, 89, + 123, 29, 120, -39, 82, -96, 20,-125, -47,-117,-102, -75,-126, -11,-113, 56, + -68, 107, -2, 126, 64, 109, 111, 60, 126, -6, 104, -71, 52,-115, -15,-126, + -79, -99,-119, -43,-124, 24, -93, 85, -35, 122, 33, 122, 92, 87, 124, 26, + 119, -42, 80, -98, 17,-125, -50,-116,-103, -73,-126, -8,-112, 58, -65, 108, + 0, 126, 66, 108, 113, 57, 126, -9, 102, -74, 49,-117, -18,-125, -81, -97, + -120, -40,-123, 27, -91, 88, -32, 122, 36, 121, 94, 84, 124, 23, 118, -45, + 77,-100, 14,-126, -53,-115,-105, -70,-126, -5,-111, 61, -62, 110, 3, 126, + 69, 106, 114, 54, 126, -12, 101, -76, 46,-118, -21,-125, -83, -95,-121, -37, + -123, 30, -89, 90, -29, 123, 39, 120, 96, 82, 125, 20, 117, -48, 75,-102, + 11,-126, -56,-113,-107, -67,-126, -2,-109, 64, -60, 111, 6, 126, 71, 104, + 115, 51, 125, -16, 99, -79, 43,-119, -24,-124, -86, -93,-122, -34,-122, 33, + -86, 92, -26, 124, 42, 119, 98, 80, 125, 17, 116, -50, 72,-104, 8,-126, + -59,-112,-108, -65,-126, 0,-107, 66, -57, 113, 10, 126, 74, 102, 117, 49, + 125, -19, 97, -81, 40,-120, -27,-123, -88, -91,-122, -31,-121, 36, -84, 94, + -23, 124, 45, 118, 100, 77, 126, 14, 115, -53, 70,-105, 4,-126, -61,-110, + -110, -62,-126, 4,-106, 69, -54, 114, 13, 126, 76, 101, 118, 46, 125, -22, + 95, -83, 37,-121, -31,-123, -90, -89,-123, -28,-120, 39, -82, 96, -19, 125, + 48, 117, 102, 75, 126, 10, 113, -56, 67,-107, 1,-126, -64,-109,-112, -59, + -126, 7,-104, 72, -51, 115, 16, 125, 79, 99, 119, 43, 124, -25, 93, -86, + 34,-122, -33,-122, -92, -86,-124, -25,-119, 42, -79, 98, -16, 125, 51, 116, + 104, 72, 126, 7, 112, -59, 65,-109, -1,-126, -67,-107,-113, -57,-126, 10, + -102, 74, -48, 117, 19, 125, 81, 97, 120, 40, 123, -28, 91, -88, 31,-122, + -36,-121, -94, -84,-124, -22,-118, 45, -77, 100, -13, 126, 53, 114, 105, 70, + 126, 4, 110, -61, 62,-110, -4,-126, -69,-106,-114, -54,-126, 13,-100, 77, + -46, 118, 22, 125, 84, 95, 121, 37, 123, -31, 88, -90, 28,-123, -39,-120, + -96, -82,-125, -19,-117, 48, -75, 102, -10, 126, 56, 113, 107, 67, 126, 1, + 109, -64, 59,-112, -7,-126, -72,-104,-116, -51,-125, 16, -98, 79, -43, 119, + 25, 124, 86, 93, 122, 34, 122, -34, 86, -92, 25,-124, -42,-119, -98, -79, + -125, -16,-116, 51, -72, 104, -7, 126, 59, 112, 109, 64, 126, -1, 107, -67, + 56,-113, -10,-126, -74,-102,-117, -48,-125, 19, -97, 81, -40, 120, 28, 123, + 88, 90, 123, 31, 121, -37, 84, -94, 22,-124, -45,-118,-100, -77,-126, -13, + -114, 54, -69, 105, -4, 126, 62, 110, 110, 62, 126, -4, 106, -69, 54,-114, + -13,-126, -77,-100,-118, -45,-124, 22, -94, 84, -37, 121, 31, 123, 90, 88, + 123, 28, 120, -40, 82, -96, 19,-125, -48,-117,-102, -74,-126, -10,-113, 56, + -67, 107, -1, 126, 64, 109, 112, 59, 126, -7, 104, -72, 51,-116, -16,-125, +} , { + 0, 127, 72, 104, 118, 44, 123, -30, 83, -95, 14,-126, -59,-112,-112, -58, + -125, 15, -94, 84, -29, 123, 45, 118, 105, 71, 126, 0, 103, -73, 43,-119, + -31,-123, -95, -83,-126, -13,-111, 60, -57, 113, 16, 125, 85, 93, 123, 28, + 118, -46, 70,-105, -1,-126, -73,-103,-119, -43,-122, 32, -82, 96, -12, 126, + 61, 111, 113, 56, 125, -17, 93, -86, 27,-123, -47,-117,-106, -69,-126, 2, + -102, 74, -42, 119, 33, 122, 97, 81, 126, 11, 110, -62, 55,-114, -18,-125, + -86, -92,-124, -26,-117, 48, -68, 106, 3, 126, 75, 102, 120, 41, 122, -34, + 80, -97, 10,-126, -62,-110,-114, -54,-125, 19, -91, 87, -25, 124, 49, 116, + 107, 68, 126, -4, 101, -76, 40,-120, -35,-121, -98, -80,-126, -9,-109, 63, + -54, 114, 20, 125, 88, 91, 124, 24, 116, -50, 67,-107, -5,-126, -77,-100, + -120, -39,-121, 36, -79, 99, -8, 126, 64, 109, 115, 53, 125, -21, 90, -89, + 23,-124, -51,-116,-108, -66,-126, 6,-100, 77, -38, 121, 37, 121, 99, 78, + 126, 7, 108, -65, 52,-115, -22,-124, -89, -89,-124, -22,-115, 52, -65, 108, + 7, 126, 78, 99, 121, 37, 121, -38, 77,-100, 6,-126, -66,-108,-116, -51, + -124, 23, -89, 90, -21, 125, 53, 115, 109, 64, 126, -8, 99, -79, 36,-121, + -39,-120,-100, -77,-126, -5,-107, 67, -50, 116, 24, 124, 91, 88, 125, 20, + 114, -54, 63,-109, -9,-126, -80, -98,-121, -35,-120, 40, -76, 101, -4, 126, + 68, 107, 116, 49, 124, -25, 87, -91, 19,-125, -54,-114,-110, -62,-126, 10, + -97, 80, -34, 122, 41, 120, 102, 75, 126, 3, 106, -68, 48,-117, -26,-124, + -92, -86,-125, -18,-114, 55, -62, 110, 11, 126, 81, 97, 122, 33, 119, -42, + 74,-102, 2,-126, -69,-106,-117, -47,-123, 27, -86, 93, -17, 125, 56, 113, + 111, 61, 126, -12, 96, -82, 32,-122, -43,-119,-103, -73,-126, -1,-105, 70, + -46, 118, 28, 123, 93, 85, 125, 16, 113, -57, 60,-111, -13,-126, -83, -95, + -123, -31,-119, 43, -73, 103, 0, 126, 71, 105, 118, 45, 123, -29, 84, -94, + 15,-125, -58,-112,-112, -59,-126, 14, -95, 83, -30, 123, 44, 118, 104, 72, + 127, 0, 104, -72, 44,-118, -30,-123, -95, -83,-126, -14,-112, 59, -58, 112, + 15, 125, 84, 94, 123, 29, 118, -45, 71,-105, 0,-126, -73,-103,-119, -43, + -123, 31, -83, 95, -13, 126, 60, 111, 113, 57, 125, -16, 93, -85, 28,-123, + -46,-118,-105, -70,-126, 1,-103, 73, -43, 119, 32, 122, 96, 82, 126, 12, + 111, -61, 56,-113, -17,-125, -86, -93,-123, -27,-117, 47, -69, 106, 2, 126, + 74, 102, 119, 42, 122, -33, 81, -97, 11,-126, -62,-110,-114, -55,-125, 18, + -92, 86, -26, 124, 48, 117, 106, 68, 126, -3, 102, -75, 41,-120, -34,-122, + -97, -80,-126, -10,-110, 62, -54, 114, 19, 125, 87, 91, 124, 25, 116, -49, + 68,-107, -4,-126, -76,-101,-120, -40,-121, 35, -80, 98, -9, 126, 63, 109, + 114, 54, 125, -20, 91, -88, 24,-124, -50,-116,-107, -67,-126, 5,-100, 77, + -39, 120, 36, 121, 99, 79, 126, 8, 109, -64, 53,-115, -21,-125, -89, -90, + -124, -23,-116, 51, -66, 108, 6, 126, 77, 100, 121, 38, 121, -37, 78, -99, + 7,-126, -65,-108,-115, -52,-124, 22, -89, 89, -22, 124, 52, 115, 108, 65, + 126, -7, 99, -78, 37,-121, -38,-121,-100, -77,-126, -6,-108, 66, -51, 116, + 23, 124, 90, 89, 125, 21, 115, -53, 64,-109, -8,-126, -79, -99,-121, -36, + -120, 39, -77, 100, -5, 126, 67, 107, 116, 50, 124, -24, 88, -91, 20,-125, + -54,-114,-109, -63,-126, 9, -98, 80, -35, 121, 40, 120, 101, 76, 126, 4, + 107, -68, 49,-116, -25,-124, -91, -87,-125, -19,-114, 54, -62, 110, 10, 126, + 80, 97, 122, 34, 120, -41, 75,-102, 3,-126, -68,-106,-117, -48,-124, 26, + -86, 92, -18, 125, 55, 114, 110, 62, 126, -11, 97, -81, 33,-122, -42,-119, + -102, -74,-126, -2,-106, 69, -47, 117, 27, 123, 93, 86, 125, 17, 113, -56, + 61,-111, -12,-126, -82, -96,-122, -32,-119, 43, -73, 103, -1, 126, 70, 105, + 118, 46, 123, -28, 85, -93, 16,-125, -57,-113,-111, -60,-126, 13, -95, 83, + -31, 123, 43, 119, 103, 73, 126, 0, 105, -71, 45,-118, -29,-123, -94, -84, + -125, -15,-112, 58, -59, 112, 14, 126, 83, 95, 123, 30, 118, -44, 72,-104, + 0,-127, -72,-104,-118, -44,-123, 30, -83, 95, -14, 126, 59, 112, 112, 58, + 125, -15, 94, -84, 29,-123, -45,-118,-105, -71,-126, 0,-103, 73, -43, 119, + 31, 123, 95, 83, 126, 13, 111, -60, 57,-113, -16,-125, -85, -93,-123, -28, + -118, 46, -70, 105, 1, 126, 73, 103, 119, 43, 122, -32, 82, -96, 12,-126, + -61,-111,-113, -56,-125, 17, -93, 86, -27, 123, 47, 117, 106, 69, 126, -2, + 102, -74, 42,-119, -33,-122, -97, -81,-126, -11,-110, 62, -55, 114, 18, 125, + 86, 92, 124, 26, 117, -48, 68,-106, -3,-126, -75,-102,-120, -41,-122, 34, + -80, 97, -10, 126, 62, 110, 114, 54, 125, -19, 91, -87, 25,-124, -49,-116, + -107, -68,-126, 4,-101, 76, -40, 120, 35, 121, 98, 80, 126, 9, 109, -63, + 54,-114, -20,-125, -88, -91,-124, -24,-116, 50, -67, 107, 5, 126, 77, 100, + 120, 39, 121, -36, 79, -99, 8,-126, -64,-109,-115, -53,-125, 21, -90, 89, + -23, 124, 51, 116, 108, 66, 126, -6, 100, -77, 38,-121, -37,-121, -99, -78, + -126, -7,-108, 65, -52, 115, 22, 124, 89, 89, 124, 22, 115, -52, 65,-108, + -7,-126, -78, -99,-121, -37,-121, 38, -77, 100, -6, 126, 66, 108, 116, 51, +} , { + 0, 127, 78, 99, 123, 29, 115, -53, 56,-113, -25,-124, -97, -81,-126, -3, + -101, 75, -32, 122, 50, 116, 111, 60, 125, -22, 84, -94, 7,-126, -73,-103, + -121, -36,-117, 47, -63, 110, 18, 125, 92, 86, 126, 10, 105, -70, 39,-120, + -43,-119,-108, -66,-126, 15, -89, 90, -14, 126, 67, 107, 119, 43, 120, -40, + 69,-106, -11,-126, -87, -92,-125, -17,-109, 63, -46, 118, 36, 121, 104, 72, + 126, -7, 94, -84, 21,-125, -60,-111,-116, -49,-122, 33, -75, 102, 4, 126, + 82, 96, 124, 24, 113, -57, 52,-115, -30,-123,-100, -78,-126, 0, -99, 79, + -28, 123, 54, 114, 113, 56, 124, -26, 80, -97, 2,-126, -76,-101,-122, -31, + -116, 51, -59, 112, 23, 124, 95, 83, 126, 6, 103, -73, 35,-121, -47,-117, + -110, -62,-125, 19, -86, 93, -9, 126, 70, 105, 120, 38, 118, -44, 65,-108, + -15,-125, -90, -88,-126, -13,-107, 67, -42, 119, 41, 120, 106, 68, 126, -12, + 91, -88, 17,-125, -64,-109,-118, -45,-121, 37, -71, 104, 8, 126, 85, 93, + 125, 20, 111, -61, 48,-117, -34,-122,-102, -74,-126, 5, -96, 82, -24, 124, + 58, 112, 115, 52, 123, -30, 77,-100, -1,-126, -80, -98,-123, -27,-114, 55, + -55, 114, 27, 124, 98, 80, 126, 1, 100, -77, 31,-123, -51,-115,-112, -58, + -124, 23, -83, 96, -5, 126, 74, 102, 122, 34, 117, -48, 61,-110, -20,-125, + -93, -85,-126, -9,-105, 71, -38, 121, 45, 118, 109, 64, 125, -16, 88, -91, + 12,-126, -68,-107,-120, -41,-119, 41, -68, 107, 13, 126, 88, 90, 125, 16, + 108, -65, 44,-118, -38,-121,-105, -71,-126, 9, -93, 86, -19, 125, 62, 110, + 117, 48, 122, -35, 74,-103, -5,-126, -83, -95,-124, -23,-112, 59, -51, 116, + 31, 123, 101, 76, 126, -2, 98, -80, 26,-124, -55,-114,-114, -54,-123, 28, + -79, 98, -1, 126, 77, 100, 123, 30, 115, -52, 58,-112, -24,-124, -96, -82, + -126, -4,-102, 74, -33, 122, 49, 117, 111, 61, 125, -21, 85, -94, 8,-126, + -72,-104,-121, -37,-118, 46, -64, 109, 17, 125, 91, 87, 126, 11, 106, -69, + 40,-120, -42,-119,-107, -67,-126, 13, -90, 89, -15, 126, 66, 108, 119, 44, + 120, -39, 70,-105, -10,-126, -86, -92,-125, -19,-110, 62, -47, 117, 35, 121, + 103, 73, 126, -6, 95, -83, 22,-124, -59,-112,-116, -50,-122, 32, -76, 101, + 3, 126, 81, 97, 124, 26, 113, -56, 54,-114, -28,-123, -99, -79,-126, 0, + -99, 78, -29, 123, 53, 115, 113, 57, 124, -25, 81, -97, 3,-126, -75,-102, + -122, -33,-116, 50, -60, 111, 21, 125, 94, 84, 126, 7, 104, -72, 36,-121, + -46,-118,-109, -63,-125, 18, -87, 92, -11, 126, 69, 106, 120, 40, 119, -43, + 66,-108, -14,-126, -89, -89,-126, -14,-108, 66, -43, 119, 40, 120, 106, 69, + 126, -11, 92, -87, 18,-125, -63,-109,-118, -46,-121, 36, -72, 104, 7, 126, + 84, 94, 125, 21, 111, -60, 50,-116, -33,-122,-102, -75,-126, 3, -97, 81, + -25, 124, 57, 113, 115, 53, 123, -29, 78, -99, 0,-126, -79, -99,-123, -28, + -114, 54, -56, 113, 26, 124, 97, 81, 126, 3, 101, -76, 32,-122, -50,-116, + -112, -59,-124, 22, -83, 95, -6, 126, 73, 103, 121, 35, 117, -47, 62,-110, + -19,-125, -92, -86,-126, -10,-105, 70, -39, 120, 44, 119, 108, 66, 126, -15, + 89, -90, 13,-126, -67,-107,-119, -42,-120, 40, -69, 106, 11, 126, 87, 91, + 125, 17, 109, -64, 46,-118, -37,-121,-104, -72,-126, 8, -94, 85, -21, 125, + 61, 111, 117, 49, 122, -33, 74,-102, -4,-126, -82, -96,-124, -24,-112, 58, + -52, 115, 30, 123, 100, 77, 126, -1, 98, -79, 28,-123, -54,-114,-114, -55, + -124, 26, -80, 98, -2, 126, 76, 101, 123, 31, 116, -51, 59,-112, -23,-124, + -95, -83,-126, -5,-103, 74, -35, 122, 48, 117, 110, 62, 125, -19, 86, -93, + 9,-126, -71,-105,-121, -38,-118, 44, -65, 108, 16, 125, 90, 88, 126, 13, + 107, -68, 41,-119, -41,-120,-107, -68,-126, 12, -91, 88, -16, 125, 64, 109, + 118, 45, 121, -38, 71,-105, -9,-126, -85, -93,-125, -20,-110, 61, -48, 117, + 34, 122, 102, 74, 126, -5, 96, -83, 23,-124, -58,-112,-115, -51,-123, 31, + -77, 100, 1, 126, 80, 98, 124, 27, 114, -55, 55,-114, -27,-123, -98, -80, + -126, -1,-100, 77, -30, 123, 52, 115, 112, 58, 124, -24, 82, -96, 5,-126, + -74,-102,-122, -34,-117, 48, -61, 111, 20, 125, 93, 85, 126, 8, 104, -71, + 37,-121, -45,-118,-109, -64,-125, 17, -88, 91, -12, 126, 68, 106, 120, 41, + 119, -42, 67,-107, -13,-126, -88, -90,-125, -15,-108, 65, -44, 118, 38, 120, + 105, 70, 126, -9, 93, -86, 19,-125, -62,-110,-117, -47,-121, 35, -73, 103, + 6, 126, 83, 95, 124, 23, 112, -59, 51,-116, -31,-122,-101, -76,-126, 2, + -97, 80, -26, 124, 56, 113, 114, 54, 123, -28, 79, -99, 0,-126, -78,-100, + -123, -30,-115, 52, -57, 113, 24, 124, 96, 82, 126, 4, 102, -75, 33,-122, + -49,-116,-111, -60,-125, 21, -84, 94, -7, 126, 72, 104, 121, 36, 118, -46, + 63,-109, -17,-125, -92, -87,-126, -11,-106, 69, -40, 120, 43, 119, 107, 67, + 126, -14, 90, -89, 15,-126, -66,-108,-119, -43,-120, 39, -70, 105, 10, 126, + 86, 92, 125, 18, 110, -63, 47,-117, -36,-121,-103, -73,-126, 7, -94, 84, + -22, 125, 60, 111, 116, 50, 122, -32, 75,-101, -3,-126, -81, -97,-124, -25, + -113, 56, -53, 115, 29, 123, 99, 78, 127, 0, 99, -78, 29,-123, -53,-115, + -113, -56,-124, 25, -81, 97, -3, 126, 75, 101, 122, 32, 116, -50, 60,-111, +} , { + 0, 127, 85, 93, 126, 11, 101, -76, 23,-124, -66,-108,-122, -34,-113, 56, + -46, 118, 45, 118, 113, 56, 122, -34, 67,-107, -23,-124,-101, -76,-126, 11, + -85, 93, 0, 126, 85, 94, 126, 12, 101, -76, 23,-124, -66,-108,-122, -35, + -113, 56, -46, 118, 45, 118, 113, 57, 122, -34, 67,-107, -22,-124,-101, -76, + -126, 11, -85, 93, 0, 126, 85, 94, 126, 12, 101, -76, 23,-124, -66,-108, + -121, -35,-114, 55, -46, 118, 45, 118, 113, 57, 122, -33, 67,-107, -22,-124, + -100, -77,-126, 10, -86, 93, 0, 126, 84, 94, 126, 12, 101, -75, 24,-124, + -66,-108,-121, -35,-114, 55, -46, 118, 44, 118, 113, 57, 122, -33, 67,-107, + -22,-125,-100, -77,-126, 10, -86, 93, -1, 126, 84, 94, 126, 12, 102, -75, + 24,-124, -65,-108,-121, -36,-114, 55, -47, 117, 44, 118, 113, 57, 122, -33, + 68,-107, -21,-125,-100, -77,-126, 10, -86, 92, -1, 126, 84, 94, 126, 13, + 102, -75, 24,-124, -65,-108,-121, -36,-114, 55, -47, 117, 44, 119, 112, 58, + 122, -33, 68,-107, -21,-125,-100, -77,-126, 9, -86, 92, -1, 126, 84, 95, + 126, 13, 102, -75, 25,-124, -65,-108,-121, -36,-114, 54, -47, 117, 44, 119, + 112, 58, 122, -32, 68,-106, -21,-125,-100, -78,-126, 9, -87, 92, -2, 126, + 83, 95, 126, 13, 102, -74, 25,-124, -64,-109,-121, -36,-114, 54, -47, 117, + 43, 119, 112, 58, 122, -32, 68,-106, -21,-125, -99, -78,-126, 9, -87, 92, + -2, 126, 83, 95, 126, 14, 102, -74, 25,-124, -64,-109,-121, -37,-114, 54, + -48, 117, 43, 119, 112, 58, 122, -32, 69,-106, -20,-125, -99, -78,-126, 9, + -87, 92, -2, 126, 83, 95, 126, 14, 102, -74, 26,-124, -64,-109,-121, -37, + -114, 54, -48, 117, 43, 119, 112, 59, 122, -31, 69,-106, -20,-125, -99, -78, + -126, 8, -87, 91, -2, 126, 83, 95, 126, 14, 103, -74, 26,-124, -64,-109, + -121, -37,-115, 53, -48, 117, 42, 119, 112, 59, 122, -31, 69,-106, -20,-125, + -99, -79,-126, 8, -87, 91, -3, 126, 83, 96, 126, 15, 103, -73, 26,-124, + -63,-109,-121, -38,-115, 53, -49, 117, 42, 119, 112, 59, 123, -31, 69,-106, + -19,-125, -99, -79,-126, 8, -88, 91, -3, 126, 82, 96, 126, 15, 103, -73, + 26,-124, -63,-109,-121, -38,-115, 53, -49, 117, 42, 119, 111, 59, 123, -31, + 70,-105, -19,-125, -98, -79,-126, 7, -88, 91, -3, 126, 82, 96, 126, 15, + 103, -73, 27,-124, -63,-110,-120, -38,-115, 52, -49, 116, 42, 119, 111, 60, + 123, -30, 70,-105, -19,-125, -98, -79,-126, 7, -88, 90, -4, 126, 82, 96, + 125, 15, 103, -73, 27,-123, -63,-110,-120, -38,-115, 52, -49, 116, 41, 119, + 111, 60, 123, -30, 70,-105, -18,-125, -98, -80,-126, 7, -88, 90, -4, 126, + 82, 96, 125, 16, 104, -72, 27,-123, -62,-110,-120, -39,-115, 52, -50, 116, + 41, 120, 111, 60, 123, -30, 70,-105, -18,-125, -98, -80,-126, 6, -89, 90, + -4, 126, 81, 97, 125, 16, 104, -72, 28,-123, -62,-110,-120, -39,-115, 52, + -50, 116, 41, 120, 111, 61, 123, -29, 71,-105, -18,-125, -98, -80,-126, 6, + -89, 90, -5, 126, 81, 97, 125, 16, 104, -72, 28,-123, -62,-110,-120, -39, + -115, 51, -50, 116, 40, 120, 111, 61, 123, -29, 71,-105, -18,-125, -98, -80, + -126, 6, -89, 90, -5, 126, 81, 97, 125, 17, 104, -72, 28,-123, -62,-110, + -120, -40,-116, 51, -50, 116, 40, 120, 111, 61, 123, -29, 71,-104, -17,-125, + -97, -80,-126, 6, -89, 89, -5, 126, 81, 97, 125, 17, 104, -71, 28,-123, + -61,-110,-120, -40,-116, 51, -51, 116, 40, 120, 110, 61, 123, -29, 71,-104, + -17,-125, -97, -81,-126, 5, -89, 89, -5, 126, 81, 97, 125, 17, 104, -71, + 29,-123, -61,-111,-120, -40,-116, 51, -51, 116, 40, 120, 110, 62, 123, -28, + 72,-104, -17,-125, -97, -81,-126, 5, -90, 89, -6, 126, 80, 97, 125, 17, + 105, -71, 29,-123, -61,-111,-120, -40,-116, 50, -51, 115, 39, 120, 110, 62, + 123, -28, 72,-104, -16,-125, -97, -81,-126, 5, -90, 89, -6, 126, 80, 98, + 125, 18, 105, -71, 29,-123, -61,-111,-120, -41,-116, 50, -52, 115, 39, 120, + 110, 62, 123, -28, 72,-104, -16,-125, -97, -81,-126, 4, -90, 89, -6, 126, + 80, 98, 125, 18, 105, -70, 30,-123, -60,-111,-120, -41,-116, 50, -52, 115, + 39, 120, 110, 62, 123, -27, 72,-104, -16,-125, -96, -82,-126, 4, -90, 88, + -7, 126, 80, 98, 125, 18, 105, -70, 30,-123, -60,-111,-119, -41,-116, 49, + -52, 115, 38, 120, 110, 63, 123, -27, 73,-103, -16,-125, -96, -82,-126, 4, + -90, 88, -7, 126, 79, 98, 125, 19, 105, -70, 30,-123, -60,-111,-119, -41, + -116, 49, -52, 115, 38, 120, 110, 63, 124, -27, 73,-103, -15,-126, -96, -82, + -126, 3, -91, 88, -7, 126, 79, 98, 125, 19, 105, -70, 31,-123, -60,-111, + -119, -42,-116, 49, -53, 115, 38, 121, 109, 63, 124, -27, 73,-103, -15,-126, + -96, -82,-126, 3, -91, 88, -8, 126, 79, 99, 125, 19, 106, -69, 31,-123, + -59,-112,-119, -42,-117, 49, -53, 115, 38, 121, 109, 63, 124, -26, 73,-103, + -15,-126, -96, -83,-126, 3, -91, 88, -8, 126, 79, 99, 125, 20, 106, -69, + 31,-123, -59,-112,-119, -42,-117, 48, -53, 115, 37, 121, 109, 64, 124, -26, + 74,-103, -14,-126, -95, -83,-126, 3, -91, 87, -8, 126, 78, 99, 125, 20, + 106, -69, 31,-122, -59,-112,-119, -43,-117, 48, -53, 114, 37, 121, 109, 64, + 124, -26, 74,-103, -14,-126, -95, -83,-126, 2, -91, 87, -8, 126, 78, 99, + } +}; diff --git a/alaw/toalaw.pl b/alaw/toalaw.pl deleted file mode 100644 index 558a05f..0000000 --- a/alaw/toalaw.pl +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/local/bin/perl - -$shift = shift; -$val[255] = 0; -for $i(0..8) { $mx[$i] = 1 << ($i+4); } -$mx[0] = 0; - -$l = 0; -for $i(0..127) { - $z = $i<<$shift; - $l++ if $z >= $mx[$l+1] && $l < 7; - - $val = ($z-$mx[$l])>>($l==0 ?1:$l); - $val = 15 if($val > 15); - $val += $l<<4; - - $val[128+$i] = $val; - $val[127-$i] = - $val; - print STDERR "$i:$val "; -} -print STDERR "\n"; - -while(<>) { - for $i (0..length ($_)-1) { - substr($_,$i,1) = sprintf("%c",$val[ord(substr($_,$i,1))]); - } - print; -} diff --git a/alaw/tools/Makefile b/alaw/tools/Makefile new file mode 100644 index 0000000..bd52cbb --- /dev/null +++ b/alaw/tools/Makefile @@ -0,0 +1,5 @@ +PROGRAMS = toalaw tosnd + +TOPDIR=../.. +include $(TOPDIR)/Make.rules + diff --git a/alaw/toalaw.c b/alaw/tools/toalaw.c similarity index 100% rename from alaw/toalaw.c rename to alaw/tools/toalaw.c diff --git a/alaw/tosnd.c b/alaw/tools/tosnd.c similarity index 100% rename from alaw/tosnd.c rename to alaw/tools/tosnd.c diff --git a/alaw/tosnd.pl b/alaw/tosnd.pl deleted file mode 100644 index 2d4136b..0000000 --- a/alaw/tosnd.pl +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/local/bin/perl - -@mult = (2,2,4,8,16,32,64,128); -@base = (1,33,66,132,264,528,1056,2112,4032); -$shift = shift; -$val[255] = 0; - -for$i(0..7) { - for $j (0..15) { - $k = ($i<<4)+$j; - $val = (($base[$i] + ($mult[$i] * $j)) >> $shift); - $val = 127 if($val > 127); - $val[$k] = 128 + $val; - $val[255-$k] = 127 - $val; - } -} - -print STDERR "\n"; - -while(<>) { - $old = $_; - s/\000-\377/pack("C",$val[ord($&)])/eg; - for $i (0..length ($_)-1) { - substr($_,$i,1) = sprintf("%c",$val[ord(substr($_,$i,1))]); - } - print; -} diff --git a/bin/Makefile b/bin/Makefile deleted file mode 100644 index 60afa76..0000000 --- a/bin/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -all prog: - rm -f master; ln -s ../isdn_4/master . - rm -f monitor; ln -s ../ip_mon/monitor . - rm -f slipto; ln -s ../str_if/slipto . - rm -f toalaw; ln -s ../alaw/toalaw . - rm -f tosnd; ln -s ../alaw/tosnd . - rm -f cardname; ln -s ../tools/cardname . - -clean: - rm -f master - rm -f monitor - rm -f slipto - rm -f toalaw - rm -f tosnd - rm -f cardname - -install update depend indent load: - @echo "Nothing to be done." - diff --git a/cards/Makefile b/cards/Makefile index 61a64b7..199af8d 100644 --- a/cards/Makefile +++ b/cards/Makefile @@ -1,5 +1,12 @@ -## =()@>()= -CARDS = dumb +TOPDIR=.. +include $(TOPDIR)/Make.config + +KERNEL=1 +REALSOURCE=loader.c +OBJS=$(addsuffix .o,$(CARDS)) +EXTRA_CFLAGS= -DCARDTYPE=$(basename $@ .o) + +SUBDIRS=capi dumb + +include $(TOPDIR)/Make.rules -all lib clean depend install update indent load: - @set -e; for i in $(CARDS) ; do $(MAKE) $(MAKEFLAGS) -C $$i $@ ; done diff --git a/cards/arnet/Makefile b/cards/arnet/Makefile index 22dbb58..ab6ab00 100644 --- a/cards/arnet/Makefile +++ b/cards/arnet/Makefile @@ -1,43 +1,7 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +all:: -## =()@>()= -CC = gcc -## =()@ @@ -I../../include >()= -DEFS = -I../../streams -I../../compat -fomit-frame-pointer -funroll-loops -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@>()= -RANLIB = ranlib +DOCARDS=1 -## =()@>()= -SYS = linux - -SOURCES = arnet.c - -OBJ = arnet.o - -all: $(OBJ) - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -clean: - rm -f $(OBJ) $(ALL) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - insmod arnet.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=../.. +include $(TOPDIR)/Make.rules diff --git a/cards/arnet/README b/cards/arnet/README deleted file mode 100644 index c98633f..0000000 --- a/cards/arnet/README +++ /dev/null @@ -1,2 +0,0 @@ -Diese "arnet"-Karten sind keine ISDN-Karten, sondern Karten mit synchronen -seriellen Ports und einem Haufen RAM, um on-board-DMA zu machen. diff --git a/cards/capi/Makefile b/cards/capi/Makefile new file mode 100644 index 0000000..ab6ab00 --- /dev/null +++ b/cards/capi/Makefile @@ -0,0 +1,7 @@ +all:: + +DOCARDS=1 + +TOPDIR=../.. +include $(TOPDIR)/Make.rules + diff --git a/cards/capi/bintec.c b/cards/capi/bintec.c new file mode 100644 index 0000000..aae525c --- /dev/null +++ b/cards/capi/bintec.c @@ -0,0 +1,1490 @@ +/* Teile dieses Codes: */ +/****************************************************************************** +* +* (C)opyright 1993 BinTec Computersysteme GmbH +* All Rights Reserved +* +******************************************************************************/ + +/* Der Rest: */ +/* + * + * ISDN CAPI driver. + * + * Copyright (c) 1993-1995 Matthias Urlichs . + */ + +#ifdef linux +#define SLOW_IO_BY_JUMPING +#endif + +#include "f_module.h" +#include "primitives.h" +#include "streams.h" +#include "isdn_12.h" +#include "isdn_34.h" /* CMD_CARDPROT */ +#include "isdn_proto.h" +#include "smallq.h" +#include "isdn_limits.h" +#include +#include "streamlib.h" +#include +#include +#include +#include "loader.h" + +#ifdef linux +#include /* htons and friends */ +#include +#endif + +#include "bri.h" +#include "bintec.h" +#include "capi.h" + +#ifdef linux +#define SetSPL(x) spl5() +#else +#define SetSPL(x) spl((x)) +#endif + +/* This is ANSI... */ +#define xxappxx(a,b) a##b +#define NAME(a,b) xxappxx(a,b) /* isn't C wonderful */ +#define xxstrxx(a) #a +#define STRING(a) xxstrxx(a) /* ditto */ + + +extern void log_printmsg (void *log, const char *text, mblk_t * mp, const char*); +static void reset_card(struct _bintec *bp); +static void toss_unknown (struct _bintec *bp); +static void process_unknown (struct _bintec *bp); + +#ifdef linux +void NAME(REALNAME,poll)(struct _bintec *bp); +#else +void NAME(REALNAME,poll)(void *); +#endif + +#define MAXSEND 0x0D00 /* 3000 bytes. Split bigger blocks according to CAPI. */ + + +static struct _bintec *bintecmap[16] = { NULL, }; + + +/**** START of Bintec-provided code ******/ + + +/********************************************************************* + bd_memchk + + checks shared memory, for correct byte, word, dword access +**********************************************************************/ +static int +bd_memchk(volatile void far *base, unsigned size) +{ + unsigned i; + + size /= sizeof(long); + +printf("u"); + { + volatile unchar far *p; + + p = (volatile unchar far *) base; + for (i=0; i<256; ++i) { + p[i] = (unchar) i; + if (p[i] != i) { + printf("board not present\n"); + return -EIO; + } + } + } + { + volatile unchar far *p; + + p = (volatile unchar far *) base; + for (i=0; i<8; ++i) + p[i] = (1 << i); + for (i=0; i<8; ++i) { + if (p[i] != (1 << i)) { + printf("byte access failed\n"); + return -EIO; + } + } + } +printf("v"); + { + volatile ushort far *p; + + p = (volatile ushort far *) base; + for (i=0; i<16; ++i) + p[i] = (1 << i); + for (i=0; i<16; ++i) { + if (p[i] != (1 << i)) { + printf("word access failed\n"); + return -EIO; + } + } + } + { + volatile ulong far *p; + + p = (volatile ulong far *) base; + for (i=0; i<32; ++i) + p[i] = (1 << i); + for (i=0; i<32; ++i) { + if (p[i] != (1 << i)) { + printf("long access failed\n"); + return -EIO; + } + } + } + { + volatile unchar far *b; + volatile ushort far *s; + + b = (volatile unchar far *) base; + s = (volatile ushort far *) base; + + b[0] = 0x12; + b[1] = 0x34; + if (s[0] != htons(0x1234)) { + printf("word order mismatch\n"); + return -ENXIO; + } + } + { + ulong val; + volatile ulong far *ptr; + + val = 0x31415926; /* set initial value */ + ptr = base; /* get memory pointer */ + for (i=0; i < size; ++i) { /* loop thru memory */ + *ptr++ = val; /* store value */ + val += 0x12345678; /* adjust value */ + } + val = 0x31415926; /* set initial value */ + ptr = base; /* get memory pointer */ + for (i=0; iinfo.memaddr) { /* board not present */ + printf("BINTEC: board not present\n"); + return -EINVAL; + } + + bp->base = (unchar far *) bp->info.memaddr; + + bp->ctrl = (unchar far *) (bp->base + 0x3ffe); + *bp->ctrl = 0xff; +printf("j"); + if ((*(bp->ctrl) >> 5) != BOARD_ID_PMX) { + bp->type = *(bp->ctrl) >> 5; + bp->ctrl = (unchar far *) (bp->base + 0x3ffe); + bp->state = (unchar far *) (bp->base + 0x3ffc); + bp->debugtext = (unchar far *) (bp->base + 0x3ffd); + bp->rcv.p = (unchar far *) (bp->base + 0x0008); + bp->snd.p = (unchar far *) (bp->base + 0x2000); + bp->rcv.d = (icinfo_t far *) (bp->base + 0x3ff0); + bp->snd.d = (icinfo_t far *) (bp->base + 0x3ff6); + size = 16 * 1024 - 4; + } else { + bp->type = BOARD_ID_PMX; + bp->ctrl = (unchar far *) (bp->base + 0xfffe); + bp->state = (unchar far *) (bp->base + 0x3ffc); + bp->debugtext = (unchar far *) (bp->base + 0x3ffd); + bp->rcv.p = (unchar far *) (bp->base + 0x0008); + bp->snd.p = (unchar far *) (bp->base + 0x2000); + bp->rcv.d = (icinfo_t far *) (bp->base + 0x3ff0); + bp->snd.d = (icinfo_t far *) (bp->base + 0x3ff6); + size = 64 * 1024 - 4; + } + +printf("i"); + if (BOARD_TYPE(bp) != BOARD_ID_BRI + && BOARD_TYPE(bp) != BOARD_ID_BRI4 + && BOARD_TYPE(bp) != BOARD_ID_PMX + && BOARD_TYPE(bp) != BOARD_ID_X21 + ) { + printf( "BINTEC: no board at HwMemAddr 0x%04lx detected\n", bp->info.memaddr); + return -ENXIO; + } +printf("h"); + CTRL_RESET(bp); /* reset board */ + +printf("g"); + err = bd_memchk((void *)bp->base, size); /* memory check */ + if (err < 0) { + printf("BINTEC: at mem 0x%lx: failure: %d\n", bp->info.memaddr, err); + return err; + } +printf("f"); + return 0; +} + + + +/********************************************************************* + bd_msgout + + prints output from boards debug register +**********************************************************************/ +static int +bd_msgout( struct _bintec *bp ) +{ + unsigned char c; + static char newline = 1; + + while ((c = *bp->debugtext) != 0) { + *bp->debugtext = 0; /* clear byte */ + if(!newline || (c != '\n')) { /* do not print empty lines */ + if (newline) printf("BINTEC: debug: "); + newline = (c == '\n'); + printf("%c", c); /* display byte */ + } + } + + if (*bp->state & 0x80) { /* board failed */ + CTRL_RESET(bp); /* reset board */ + printf("BINTEC: msgout: board failed???\n"); + isdn2_new_state(&bp->card,2); + return -EIO; + } + return 0; +} + + +/********************************************************************* + bd_init + + initialize structures to point to boards memory +**********************************************************************/ +static int +bd_init( struct _bintec *bp ) +{ + if (!bp->info.memaddr) { + printf("bd_init: board addr not present\n"); + return -EFAULT; + } +printf("c"); + bp->base = (unchar far *) bp->info.memaddr; + bp->ctrl = (unchar far *) (bp->base + 0x3ffe); + *bp->ctrl = 0xff; + if ((*(bp->ctrl) >> 5) != BOARD_ID_PMX) { + bp->type = *(bp->ctrl) >> 5; + bp->ctrl = (unchar far *) (bp->base + 0x3ffe); + bp->state = (unchar far *) (bp->base + 0x3ffc); + bp->debugtext = (unchar far *) (bp->base + 0x3ffd); + bp->ctrl = (unchar far *) (bp->base + 0x3ffe); + bp->rcv.p = (unchar far *) (bp->base + 0x0008); + bp->snd.p = (unchar far *) (bp->base + 0x2000); + bp->rcv.d = (icinfo_t far *) (bp->base + 0x3ff0); + bp->snd.d = (icinfo_t far *) (bp->base + 0x3ff6); +printf("d"); + } else { + bp->type = BOARD_ID_PMX; + bp->ctrl = (unchar far *) (bp->base + 0xfffe); + bp->state = (unchar far *) (bp->base + 0x3ffc); + bp->debugtext = (unchar far *) (bp->base + 0x3ffd); + bp->rcv.p = (unchar far *) (bp->base + 0x0008); + bp->snd.p = (unchar far *) (bp->base + 0x2000); + bp->rcv.d = (icinfo_t far *) (bp->base + 0x3ff0); + bp->snd.d = (icinfo_t far *) (bp->base + 0x3ff6); + } + switch(bp->type) { + case BOARD_ID_PMX: + bp->card.nr_chans = 30; + break; + case BOARD_ID_BRI: + bp->card.nr_chans = 2; + break; + case BOARD_ID_BRI4: + bp->card.nr_chans = 8; + break; + default: + printf("BINTEC: unknown board ID %d\n",bp->type); + return -EIO; + } +printf("e"); + return 0; +} + + + +/**** END of Bintec-provided code *****/ + +static void +reset_card(struct _bintec *bp) +{ + int i = 0; + long s = splstr(); + + *bp->state = 0; /* turn off interrupt generation */ + *bp->ctrl = 0; /* halt and reset CPU */ + + for(i=0; i <= MAX_B; i++) { + S_flush(&bp->chan[i].q_in); + S_flush(&bp->chan[i].q_out); + bp->chan[i].mode = M_OFF; + } + S_flush(&bp->q_unknown); + if(bp->unknown_timer) { + bp->unknown_timer = 0; +#ifdef NEW_TIMEOUT + untimeout(bp->timer_toss_unknown); +#else + untimeout(toss_unknown, bp); +#endif + } + bp->sndoffset = -1; + bp->rcvoffset = -1; + bp->msgnr = 0; + bp->waitmsg = 999; + splx(s); +} + +inline static void +setctl(struct _bintec *bp, int bit) +{ + bp->cflag |= (1<ctrl = bp->cflag; +} + +inline static void +clrctl(struct _bintec *bp, int bit) +{ + bp->cflag &= ~(1<ctrl = bp->cflag; +} + +inline static void +put8(struct _bintec *bp, u8 byt) +{ + bp->snd.p[bp->sndoffset] = byt; + bp->sndoffset++; + if(bp->sndoffset == bp->sndbufsize) + bp->sndoffset = 0; +} + +inline static void +put16(struct _bintec *bp, u16 byt) +{ + put8(bp, byt & 0xFF); + put8(bp, byt >> 8); +} + +inline static void +put32(struct _bintec *bp, u32 byt) +{ + put8(bp, byt & 0xFF); + put8(bp, byt >> 8); + put8(bp, byt >> 16); + put8(bp, byt >> 24); +} + +inline static void +putmb(struct _bintec *bp, mblk_t *mb, int len) +{ + while(mb != NULL && len > 0) { + streamchar *pos = mb->b_rptr; + while(pos < mb->b_wptr) { + put8(bp,*pos++); + if(--len == 0) + break; + } + mb = mb->b_cont; + } +} + +static int +putstart(struct _bintec *bp, int len) +{ + int wi = ntohs(bp->snd.d->wi); /* get write index */ + int ri = ntohs(bp->snd.d->ri); /* get read index */ + int sz = ntohs(bp->snd.d->sz); /* get buffer size */ + int space = (ri - wi + sz - 1) % sz; /* calc size */ + int err; + unsigned long ms = SetSPL(bp->ipl); + + if((err = bd_msgout(bp)) < 0) { + splx(ms); + return err; + } + if ((sz < 2) || (wi >= sz) || (ri >= sz)) { + printf( "BINTEC error: write: ri %d, wi %d, sz %d\n",ri,wi,sz); + bp->sndoffset = sz; + splx(ms); + return -EIO; + } + if(len > sz-3) { + printf("BINTEC error: write len %d > sz-3 %d\n",len,sz-3); + bp->sndoffset = sz; + splx(ms); + return -ENXIO; + } + if(bp->sndoffset != -1) { + if(bp->sndoffset != bp->sndbufsize) + DEBUG(info) printf("BINTEC: busy sending\n"); + splx(ms); + return -EAGAIN; /* busy */ + } + if(len > space-2) { + DEBUG(info) printf("BINTEC: buffer full, %d < %d\n",len,space-2); + splx(ms); + return -EAGAIN; + } + DEBUG(capiout) printf("BINTEC write %d bytes at %d, free %d\n",len,wi,space); + bp->sndoffset = wi; + bp->sndbufsize = sz; + bp->sndend = (wi+len+2) % sz; + splx(ms); + put16(bp, htons(len)); + return 0; +} + +static int +putend(struct _bintec *bp) +{ + int ms = SetSPL(bp->ipl); + int err; + + if((err = bd_msgout(bp)) < 0) { + splx(ms); + return err; + } + if(bp->sndoffset != bp->sndend) { + DEBUG(info) printf("BINTEC error: send end %d, should be %d\n",bp->sndoffset,bp->sndend); + bp->sndoffset = bp->sndbufsize; + return -EIO; + } + bp->snd.d->wi = htons(bp->sndoffset); + if(bp->type != BOARD_ID_PMX) { + setctl(bp,4); + clrctl(bp,4); + } + bp->sndoffset = -1; + splx(ms); + return 0; +} + + +inline static u8 +get8(struct _bintec *bp) +{ + u8 byt; + byt = bp->rcv.p[bp->rcvoffset]; + bp->rcvoffset++; + if(bp->rcvoffset == bp->rcvbufsize) + bp->rcvoffset = 0; + return byt; +} + +inline static void +getflush(struct _bintec *bp, int len) +{ + if(len > 0) { + bp->rcvoffset += len; + if (bp->rcvoffset >= bp->rcvbufsize) + bp->rcvoffset -= bp->rcvbufsize; + } else { + bp->rcvoffset = bp->rcvend; + } +} + +inline static u16 +get16(struct _bintec *bp) +{ + u16 byt; + byt = get8(bp); + byt |= get8(bp) << 8; + return byt; +} + +inline static u32 +get32(struct _bintec *bp) +{ + u32 byt; + byt = get8(bp); + byt |= get8(bp) << 8; + byt |= get8(bp) << 16; + byt |= get8(bp) << 24; + return byt; +} + +inline static void +getmb(struct _bintec *bp, mblk_t *mb, int len) +{ + while(len--) + *mb->b_wptr++ = get8(bp); +} + +static int +getstart(struct _bintec *bp) +{ + int wi = ntohs(bp->rcv.d->wi); /* get write index */ + int ri = ntohs(bp->rcv.d->ri); /* get read index */ + int sz = ntohs(bp->rcv.d->sz); /* get buffer size */ + int space = (wi - ri + sz) % sz; /* calc size */ + int err, len; + unsigned long ms = SetSPL(bp->ipl); + + if((err = bd_msgout(bp)) < 0) { + splx(ms); + return err; + } + if(bp->rcvoffset != -1) { + if(bp->rcvoffset != sz) + DEBUG(info) printf("BINTEC: read: receiver busy\n"); + return -EAGAIN; /* busy */ + } + + if (sz < 2) { /* invalid buffer size */ + printf( "BINTEC error: read: invalid buffer size %d\n", sz); + bp->rcvoffset = sz; + splx(ms); + return -EIO; + } + if(space == 0) { + splx(ms); + /* no message to read */ + return -ENODATA; + } + if (space > sz || space < 2) { /* we have a problem */ + printf("BINTEC error: read: invalid space %d\n", space); + bp->rcvoffset = sz; + splx(ms); + return -EFAULT; + } + + bp->rcvoffset = ri; + bp->rcvbufsize = sz; + splx(ms); + + len = ntohs(get16(bp)); + if(len > space-2) { + printf("BINTEC error: read: len %d > space-2 %d\n",len,space-2); + bp->rcv.d->ri = bp->rcv.d->wi; + bp->rcvoffset = sz; + return -EFAULT; + } + DEBUG(capi) printf("BINTEC: reading %d bytes at %d\n",len,ri); + bp->rcvend = (ri + len + 2) % sz; + return len; +} + +static int +getend(struct _bintec *bp) +{ + if(bp->rcvoffset != bp->rcvend) { + printf("BINTEC error: read: now at %d instead of %d!\n",bp->rcvoffset,bp->rcvend); + bp->rcvoffset = bp->rcvbufsize; + return -EIO; + } + bp->rcv.d->ri = htons(bp->rcvoffset); /* update read index */ + bp->rcvoffset = -1; + if(bp->type != BOARD_ID_PMX) { + setctl(bp,4); + clrctl(bp,4); + } + return 0; +} + + + +static int +init1 (struct _bintec *bp) +{ + int err; +printf("a"); + err = bd_init(bp); + if(err < 0) + return err; +printf("b"); + err = bd_check(bp); + if(err < 0) + return err; +printf("c"); + bp->waitmsg = 999; + return 0; +} + +static int +boot(struct _isdn1_card * card, int step, int offset, mblk_t *data) +{ + struct _bintec * bp = (struct _bintec *) card; + int err, i; + mblk_t *origdata = data; + + if ((err = bd_msgout(bp)) < 0) { + return err; + } + DEBUG(info) if(offset == 0 || msgdsize(data) < 100) printf("BINTEC boot: step %d offset %d bytes %d for type %d\n",step,offset,msgdsize(data),bp->type); + switch(step) { + case 1: + if(offset == 0) { + volatile uchar_t *ptr; + { + mblk_t *mp; + + if(msgdsize(data) < 2) { + err = -ENXIO; + break; + } + mp = pullupm(data,2); + if(mp == NULL) + return -ENOMEM; + data = mp; + } + + reset_card(bp); + + err = bd_check(bp); + if(err < 0) + return err; + + bzero((void *)bp->base, 0x3ffe); /* clear shared memory */ + bp->rcv.d->sz = htons(0x1ff8); /* set size */ + bp->snd.d->sz = htons(0x1ff0); /* set size */ + ptr = bp->base; /* get pointer to reset vector */ + *((u32 *)ptr)++ = htonl(0x2000); /* SP */ + *((u32 *)ptr)++ = htonl(0x0200); /* PC */ + for (i=0; i<504; ++i) { /* clear vector table */ + *ptr++ = 0xff; + } + + data->b_rptr[0] = 0x70; + data->b_rptr[1] = bp->type; + } + if(msgdsize(data) != 0) { + if(0)DEBUG(capiout) { + printf("BINTEC: write %d bytes to card at %x",msgdsize(data),0x200+offset); + log_printmsg(NULL,": ",data,">>"); + } + while(data != NULL) { + bcopy(data->b_rptr,(char *)(bp->info.memaddr) +0x200 + offset,data->b_wptr-data->b_rptr); + offset += data->b_wptr-data->b_rptr; + + data = data->b_cont; + } + } else { + if (BOARD_TYPE(bp) != BOARD_ID_PMX) { + CTRL_SET(bp, 0x0e); + } else { + CTRL_SET(bp, 0x03); + } + DEBUG(info) printf("BINTEC: Boot phase 1 complete; card started\n"); + err = bd_msgout(bp); + } + break; + case 2: + if(offset == 0) { + { + mblk_t *mp; + + if(msgdsize(data) < 2) { + err = -ENXIO; + break; + } + mp = pullupm(data,2); + if(mp == NULL) + return -ENOMEM; + data = mp; + } + + data->b_rptr[0] = 0x70; + data->b_rptr[1] = bp->type; + } + { + int len = msgdsize(data); + int err = putstart(bp,len); + + if(0)DEBUG(capiout) { + printf("BINTEC: write %d bytes to card",len); + log_printmsg(NULL,": ",data,">>"); + } + + if(err < 0) + return err; + putmb(bp,data,len); + err = putend(bp); + if(err < 0) + return err; + } + break; + case 3: + if(msgdsize(data) != 0) { + err = -EIO; + break; + } + bp->waitmsg = 2; + if(bp->info.irq != 0) { + setctl(bp,0); /* enable interrupts */ + *bp->state = 3; /* ... send and receive */ + } + break; /* boot is finished */ + default: + return -EFAULT; + } + if(err == 0) + freemsg(origdata); + return err; +} + +static int +bintec_mode (struct _isdn1_card * card, short channel, char mode, char listen) +{ + struct _bintec * bp = (struct _bintec *) card; + unsigned long ms = SetSPL(bp->ipl); + int err = 0; + + switch(channel) { + case 0: + if(mode == M_OFF) { + reset_card(bp); + splx(ms); + return 0; + } + splx(ms); + return -ENXIO; + default: + if(channel > 0 && channel <= bp->card.nr_chans) { + DEBUG(info) printf("%sBINTEC: Chan%d %s<%d>%s\n",KERN_INFO ,channel,mode?"up":"down",mode,listen?" listen":""); + bp->chan[channel].mode = mode; + splx(ms); + return 0; + } else { + printf("%sBintec badChan %d\n",KERN_WARNING ,channel); + splx(ms); + return -EINVAL; + } + } + NAME(REALNAME,poll)(bp); + splx(ms); + return err; +} + +static int +bintec_prot (struct _isdn1_card * card, short channel, mblk_t * mp, int flags) +{ + struct _bintec * bp = (struct _bintec *)card; + streamchar *origmp = mp->b_rptr; + ushort_t id; + int err = 0; + hdlc_buf chan = &bp->chan[channel]; + + DEBUG(info)printf("Prot chan %d flags 0%o\n",channel,flags); + + if(!(flags & ~CHP_FROMSTACK)) { /* Nothing else set? */ + if ((err = m_getid (mp, &id)) != 0) + goto err; + if(!(flags & CHP_FROMSTACK)) { + switch (id) { + default: + break; + case CMD_CARDPROT: + { + while((err = m_getsx(mp,&id)) == 0) { + switch(id) { + case ARG_ASSOC: + { /* appID plci ncci */ + long a,n,p; + if((err = m_geti(mp,&a)) < 0) + break; + if((err = m_geti(mp,&p)) < 0) + break; + if((err = m_geti(mp,&n)) < 0) + break; + chan->appID = a; + chan->PLCI = p; + chan->NCCI = n; + DEBUG(capi) printf("BINTEC: chan %d: assoc %04lx %04lx %04lx\n",channel,a,p,n); + process_unknown(bp); + } + } + } + } + if(err == 0) { + mblk_t *mz = make_reply(err); + if(mz != NULL) { + linkb(mz,mp); + if((err = isdn2_chprot(card,channel,mz,flags|CHP_FROMSTACK)) < 0) + freeb(mz); + } + } + return err; + case PROTO_OFFSET: + { + long z; + if ((err = m_geti (mp, &z)) != 0) + goto err; + if (z < 0 || z >= 1024) { + err = -EINVAL; + goto err; + } + if(flags & CHP_FROMSTACK) { /* down */ + if(bp->maxoffset < z) + bp->maxoffset = z; + bp->chan[channel].offset = z; + } + } + break; + } + } + } + err: + if(mp != NULL) { + if (origmp != NULL) + mp->b_rptr = origmp; + } + return (err ? err : isdn2_chprot(card,channel,mp,flags)); +} + +/* + * Check if buffer space is available + */ +static int +bintec_candata (struct _isdn1_card * card, short channel) +{ + struct _bintec * bp = (struct _bintec *)card; + if(bp->waitmsg) + return 0; + return (bp->chan[channel].q_out.nblocks < 4); +} + +/* + * Enqueue the data. + */ +static int +bintec_data (struct _isdn1_card * card, short channel, mblk_t * data) +{ + struct _bintec * bp = (struct _bintec *)card; + if(bp->waitmsg) + return -ENXIO; + S_enqueue(&bp->chan[channel].q_out, data); + NAME(REALNAME,poll)((struct _bintec *) card); + return 0; +} + +/* + * Flush the send queue. + */ +static int +bintec_flush (struct _isdn1_card * card, short channel) +{ + struct _bintec * bp = (struct _bintec *)card; + if(channel > 0) + S_flush(&bp->chan[channel].q_out); + return 0; +} + + +static int +sendone(struct _bintec *bp, int thechan) +{ + int len, err; + struct _hdlc_buf *chan = &bp->chan[thechan]; + mblk_t *mb; + + if(thechan != 0 && chan->waitflow > 5) + return 0; /* XXX -EAGAIN ? */ + mb = S_dequeue(&chan->q_out); + if(mb == NULL) + return 0; + + len = msgdsize(mb); + + err = bd_msgout(bp); + if(err < 0) { + freemsg(mb); + return err; + } + if(thechan != 0) + len += 15; + else + len += 2; + DEBUG(capiout) { + printf("BINTEC: Send %d bytes on chan %d",len,thechan); + if(thechan == 0) + log_printmsg(NULL,": ",mb,">>"); + else + printf("\n"); + } + err = putstart(bp,len > MAXSEND ? MAXSEND : len ); /* auto-puts the length */ + if(err >= 0) { + put16(bp, htons(1)); + if(thechan != 0) { /* data */ + put16(bp, 13); /* msg len, including header */ + put16(bp, chan->appID); /* AppID */ + put16(bp, CAPI_DATAB3_REQ); + put16(bp, bp->msgnr++ & 0x3FFF); + put16(bp, chan->NCCI); + put8 (bp, ++chan->dblock); + put16(bp, len > MAXSEND ? CAPI_MORE : 0); /* flags */ + } + putmb(bp,mb,MAXSEND); + err = putend(bp); + if(err < 0) + S_requeue(&chan->q_out,mb); + else { + if(len > MAXSEND) { + adjmsg(mb,len-MAXSEND); + mb = pullupm(mb,0); + S_requeue(&chan->q_out,mb); + } else + freemsg(mb); + if(thechan != 0) + chan->waitflow++; + } + } else if(err == -EAGAIN) { + S_requeue(&chan->q_out,mb); + } else { + freemsg(mb); + } + return err; +} + + +static int +pushone(struct _bintec *bp, int thechan) +{ + int err; + struct _hdlc_buf *chan = &bp->chan[thechan]; + mblk_t *mb; + + if(!isdn2_canrecv(&bp->card,thechan)) { + return -EAGAIN; + } + mb = S_dequeue(&chan->q_in); + if(mb->b_cont == NULL) { + freeb(mb); + return -EINVAL; + } + { + struct CAPI_every_header *capi, *capi2; + struct CAPI_datab3_ind *ci; + struct CAPI_datab3_resp *cr; + mblk_t *mr = allocb(sizeof(*capi)+sizeof(*cr),BPRI_HI); + if(mr != NULL) { + capi = ((typeof(capi ))mr->b_rptr); + capi2 = ((typeof(capi2))mr->b_wptr)++; + cr = ((typeof(cr))mr->b_wptr)++; + ci = (typeof(ci))(capi+1); + *capi2 = *capi; + capi2->PRIM_type = CAPI_DATAB3_RESP; + cr->ncci = ci->ncci; + cr->blknum = ci->blknum; + + err = isdn2_recv(&bp->card,0,mb->b_cont); + if(err == 0) { + freeb(mb); + S_enqueue(&bp->chan[0].q_out,mr); + if(bp->chan[0].q_out.nblocks == 1) + sendone(bp,0); + } else if(err == -EAGAIN) { + S_requeue(&chan->q_in, mb); + freemsg(mr); + } else { + freemsg(mb); + freemsg(mr); + } + } else { + S_requeue(&chan->q_in, mb); + freemsg(mb); + err = -ENOMEM; + } + } + return err; +} + +static int +postproc(struct _bintec *bp, mblk_t *mb, int ch) +/* ch: pre-found channel; -1: not found; 0: unknown */ +{ + int err; + struct CAPI_every_header *capi; + + DEBUG(capi) log_printmsg(NULL,"BINTEC read packet:",mb,"> "); + + capi = (typeof(capi))mb->b_rptr; + switch(capi->PRIM_type) { + case CAPI_ALIVE_IND: + err = 0; + capi->PRIM_type = CAPI_ALIVE_RESP; + S_enqueue(&bp->chan[0].q_out,mb); + if(bp->chan[0].q_out.nblocks == 1) + sendone(bp,0); + break; + case CAPI_DATAB3_IND: + { + struct _hdlc_buf *chan = &bp->chan[1]; + if(ch == 0) { + struct CAPI_datab3_ind *c2; + int i; + + ch = -1; + c2 = (typeof(c2))(capi+1); + for(i=1;icard.nr_chans;i++) { + if(chan->appID == capi->appl && chan->NCCI == c2->ncci) { + ch = i; + break; + } + chan++; + } + if(ch == -1) + return -ERESTART; + } else if(ch > 0) + chan = &bp->chan[ch]; + else + return -ERESTART; + S_enqueue(&chan->q_in,mb); + if(chan->q_out.nblocks == 1) + pushone(bp,ch); + } + break; + case CAPI_DATAB3_CONF: + { + struct _hdlc_buf *chan = &bp->chan[1]; + if(ch == 0) { + struct CAPI_datab3_ind *c2; + int i; + + ch = -1; + c2 = (typeof(c2))(capi+1); + for(i=1;icard.nr_chans;i++) { + if(chan->appID == capi->appl && chan->NCCI == c2->ncci) { + ch = i; + break; + } + chan++; + } + if(ch == -1) + return -ERESTART; + } else if(ch > 0) + chan = &bp->chan[ch]; + else + return -ERESTART; + if(chan->waitflow) + chan->waitflow--; + sendone(bp,ch); + } + break; + default: + if(!isdn2_canrecv(&bp->card,0)) { + printf("BINTEC read: cannot accept packet\n"); + S_enqueue(&bp->chan[0].q_in,mb); + return 0; + } else if((err = isdn2_recv(&bp->card,0,mb)) != 0) { + printf("BINTEC read error: err %d\n",err); + return err; + } + break; + } + + return 0; +} + +static void +toss_unknown (struct _bintec *bp) +{ + mblk_t *mb; + while((mb = S_dequeue(&bp->q_unknown)) != NULL) + freemsg(mb); +} + +static void +process_unknown (struct _bintec *bp) +{ + if(bp->q_unknown.nblocks == 0) + return; + + if(bp->unknown_timer) { + bp->unknown_timer = 0; +#ifdef NEW_TIMEOUT + untimeout(bp->timer_toss_unknown); +#else + untimeout(toss_unknown, bp); +#endif + } + { + struct _smallq sq = bp->q_unknown; + mblk_t *mb; + + bzero(&bp->q_unknown,sizeof(bp->q_unknown)); + while((mb = S_dequeue(&sq)) != NULL) { + switch(postproc(bp,mb,0)) { + case 0: + break; + default: + { + struct CAPI_every_header *capi, *capi2; + struct CAPI_datab3_ind *ci; + struct CAPI_datab3_resp *cr; + mblk_t *mr = allocb(sizeof(*capi)+sizeof(*cr),BPRI_HI); + if(mr != NULL) { + capi = ((typeof(capi ))mr->b_rptr); + capi2 = ((typeof(capi2))mr->b_wptr)++; + cr = ((typeof(cr))mr->b_wptr)++; + ci = (typeof(ci))(capi+1); + *capi2 = *capi; + capi2->PRIM_type = CAPI_DATAB3_RESP; + cr->ncci = ci->ncci; + cr->blknum = ci->blknum; + S_enqueue(&bp->chan[0].q_out,mr); + if(bp->chan[0].q_out.nblocks == 1) + sendone(bp,0); + } + freemsg(mb); + } + case -EAGAIN: + case -ERESTART: + S_enqueue(&bp->q_unknown,mb); + bp->unknown_timer = 1; + break; + } + } + + } + if(bp->unknown_timer) { +#ifdef NEW_TIMEOUT + bp->timer_toss_unknown = +#endif + timeout((void *)toss_unknown,bp,10*HZ); + } +} + +static void +DoIRQ(struct _bintec *bp) +{ + int lastpos; + int err = bd_msgout(bp); + if(err < 0) + return; /* HW fail */ + if(bp->waitmsg > 9) + return; /* not yet */ + + while(err >= 0) { + err = getstart(bp); + if(err >= 0) { + int len = err; + if(err < 4) { + if(bp->waitmsg > 0) { + if(!--bp->waitmsg) { + DEBUG(info) printf("BINTEC: card is online\n"); + isdn2_new_state(&bp->card,1); + } + } + getflush(bp,len); + err = getend(bp); + continue; + } + /* XXX figure out the channel, use a smaller offset */ + err = get16(bp); + len -= 2; + if(err == htons(1)) { + int ch = 0; + int capilen = get16(bp); + mblk_t *mb = allocb(capilen,BPRI_HI); + struct CAPI_every_header *capi; + if(mb == NULL) { + DEBUG(info)printf("BINTEC:read: no mem for %d bytes\n",err), + getflush(bp,len); + getend(bp); + err = -ENOMEM; + break; + } + *((ushort_t *)mb->b_wptr)++ = capilen; + getmb(bp,mb,capilen-2); + capi = (typeof(capi))mb->b_wptr; + + if(len > capilen) { /* Data msg? */ + int offset = -1; + switch(capi->PRIM_type) { + case CAPI_DATAB3_IND: + { + struct CAPI_datab3_ind *c2; + int i; + struct _hdlc_buf *chan = &bp->chan[1]; + + c2 = (typeof(c2))(capi+1); + for(i=1;icard.nr_chans;i++) { + if(chan->appID == capi->appl && chan->NCCI == c2->ncci) { + offset = chan->offset; + ch = i; + break; + } + chan++; + } + if(offset < 0) { + ch = -1; + offset = bp->maxoffset; /* Not yet */ + } + } + break; + default: + offset = 0; + break; + } + { + mblk_t *m2 = allocb(len-capilen+offset,BPRI_HI); + if(m2 == NULL) + getflush(bp,len-capilen); + else { + m2->b_rptr += offset; + m2->b_wptr += offset; + getmb(bp,m2,len-capilen); + linkb(mb,m2); + } + } + } + switch(capi->PRIM_type) { + case CAPI_DATAB3_CONF: + break; + } + if(err < 0) + getend(bp); + else + err = getend(bp); + if(err >= 0) { + err = postproc(bp,mb,ch); + if(err == -ERESTART) { + S_enqueue(&bp->q_unknown,mb); + err = 0; + } + } + if (err < 0) + freemsg(mb); + } else { + printf("BINTEC error: msg type %04x\n",ntohs(err)); + getflush(bp,len); + err = getend(bp); + } + } + } + + lastpos = bp->lastout; + do { + err = sendone(bp,0); + if(err < 0) + break; + + err = sendone(bp,bp->lastout); + + if(bp->lastout == bp->card.nr_chans) + bp->lastout = 1; + else + bp->lastout++; + } while((err >= 0) && (bp->lastout != lastpos)); +} + +#ifdef linux +static void +bintecintr(int irq, struct pt_regs *regs) +{ + struct _bintec *bp; + + for(bp=bintecmap[irq];bp != NULL; bp = bp->next) { + if(bp->info.irq == irq) { + bp->polled --; + DoIRQ(bp); + bp->polled ++; + } + } +} + + +#else +void NAME(REALNAME,intr)(int x) +{ + struct _bintec *bp; + + for(bp=bintecmap[x];bp != NULL; bp = bp->next) { + if(bp->info.irq == x) { + bp->polled --; + DoIRQ(bp); + bp->polled ++; + } + } +} +#endif + +#ifdef linux +void NAME(REALNAME,poll)(struct _bintec *bp) +#else +void NAME(REALNAME,poll)(void *nix) +#endif +{ +#ifndef linux + struct _bintec *bp; + for(i=bintec_num-1;i>=0;--i) +#endif + { + unsigned long ms; +#ifndef linux + bp = &bintecdata[i]; +#endif + ms = SetSPL(bp->ipl); + DoIRQ(bp); + splx(ms); +#if 0 /* def linux */ + if(bp->info.irq != 0) + unblock_irq(bp->info.irq); +#endif + } +} + + +#ifdef linux +static void +bintectimer(struct _bintec *bp) +{ + NAME(REALNAME,poll)(bp); +#ifdef NEW_TIMEOUT + bp->timer = +#endif + timeout((void *)bintectimer,bp,(bp->info.irq == 0) ? ((bp->type == BOARD_ID_PMX) ? HZ/100+1 : HZ/20+1) : HZ/2); +} +#endif + +int NAME(REALNAME,init)(struct cardinfo *inf) +{ + struct _bintec *bp; + int err; + + bp = kmalloc(sizeof(*bp),GFP_KERNEL); + if(bp == NULL) { + printf("BINTEC: no memory!\n"); + return -ENOMEM; + } + bzero(bp,sizeof(*bp)); +printf("A %p %p ",bp,inf); + bp->info = *inf; +printf("1"); + bp->infoptr = inf; +printf("2"); + bp->card.ctl = bp; +printf("3"); + bp->card.modes = CHM_INTELLIGENT; + bp->card.ch_mode = bintec_mode; + bp->card.ch_prot = bintec_prot; + bp->card.send = bintec_data; + bp->card.flush = bintec_flush; + bp->card.cansend = bintec_candata; + bp->card.poll = NULL; + bp->card.boot = boot; + bp->polled = -1; + bp->lastout = 1; +printf("B"); + printf("ISDN: " STRING(REALNAME) " at mem 0x%lx irq %d: ",bp->info.memaddr,bp->info.irq); +printf("C"); + if((err = init1(bp)) < 0) { + printf("Card not initializable.\n"); + kfree(bp); + return err; + } +printf("D"); +#ifdef linux + if((bp->info.irq != 0) && (bintecmap[bp->info.irq] == NULL) && request_irq(bp->info.irq,bintecintr,SA_INTERRUPT,"Bintec")) { + printf("IRQ not available.\n"); + kfree(bp); + return -EIO; + } +#endif +printf("E"); + NAME(REALNAME,poll)(bp); + if((err = isdn2_register(&bp->card, bp->info.ID)) != 0) { + printf("not installed (ISDN_2), err %d\n",err); + kfree(bp); + return err; + } + +printf("F"); + bp->polled = 1; +#ifdef linux + if(bp->info.irq == 0) { + printf("polling; "); + } + bintectimer(bp); +#endif + bp->next = bintecmap[bp->info.irq]; + bintecmap[bp->info.irq] = bp; + printf("installed at "); + if(bp->info.memaddr != 0) + printf("mem 0x%lx ",bp->info.memaddr); + if(bp->info.irq != 0) + printf("irq %d.\n",bp->info.irq); + else + printf("polled.\n"); + MORE_USE; + return 0; +} + + +void NAME(REALNAME,exit)(struct cardinfo *inf) +{ + unsigned long ms = SetSPL(inf->ipl); + struct _bintec *bp = NULL, **nbp; + + nbp = &bintecmap[(int)inf->irq]; /* grumble, GCC */ + while(*nbp != NULL) { + + if((*nbp)->infoptr == inf) { + bp = *nbp; + *nbp = bp->next; + break; + } + nbp = &((*nbp)->next); + } + + if(bp == NULL) { + printf("BINTEC error: exit: info record not found!\n"); + return; + } +#ifdef NEW_TIMEOUT + untimeout(bp->timer); +#else + untimeout(bintectimer,bp); +#endif + reset_card(bp); + + isdn2_unregister(&bp->card); + if((bp->info.irq != 0) && (bintecmap[bp->info.irq] == NULL)) + free_irq(bp->info.irq); + splx(ms); + kfree(bp); + LESS_USE; +} + + +#ifdef MODULE +static int do_init_module(void) +{ + return 0; +} + +static int do_exit_module(void) +{ + return 0; +} +#endif diff --git a/cards/capi/bintec.h b/cards/capi/bintec.h new file mode 100644 index 0000000..e74d991 --- /dev/null +++ b/cards/capi/bintec.h @@ -0,0 +1,73 @@ +#ifndef BINTEC_H +#define BINTEC_H + +#include "isdn_limits.h" +#include "isdn_12.h" +#include "smallq.h" +#include +#include "loader.h" + +#include "bri.h" + +#define DEBUG(_x) if((DEBUG_##_x) & bp->info.debug) +#define DEBUG_memory 0x01 +#define DEBUG_uart 0x00 +/* #define DEBUG_isac 0x04 */ +#define DEBUG_capi 0x08 +#define DEBUG_capiout 0x02 +#define DEBUG_cpu 0x00 +#define DEBUG_check 0x20 +#define DEBUG_info 0x40 +#define DEBUG_main 0x80 + +typedef unsigned char Byte; +typedef struct _hdlc_buf { + struct _smallq q_in, q_out; + ushort_t offset; + ushort_t appID, PLCI, NCCI; + uchar_t dblock; /* sent data block number, incremented, mostly ignored */ + uchar_t mode; + uchar_t waitflow; +} *hdlc_buf; + +typedef struct _bintec { + struct _isdn1_card card; /* must be first */ + struct cardinfo info,*infoptr; + + struct _hdlc_buf chan[MAX_B+1]; + +#ifdef NEW_TIMEOUT + long timer, timer_toss_unknown; +#endif + unsigned unknown_timer:1; + struct _smallq q_unknown; + + signed char polled; char lastout; int maxoffset; + + int sndoffset; /* buffer position where we send */ + int sndbufsize; /* size of send buffer */ + int sndend; /* last byte of block, for count */ + int rcvoffset; /* buffer position at which to receive */ + int rcvbufsize; /* size of receive buffer */ + int rcvend; /* last byte of block, for flushing / count */ + + int msgnr; /* 0x0000-3FFF: Treiber; 4000-7FFF: CAPI; + 0x8000-FFFF: Board */ + int waitmsg; /* messages to skip before coming online */ + + volatile uchar_t *base; /* base address of shared memory */ + volatile uchar_t *state; /* state flag */ + volatile uchar_t *debugtext; /* debug output */ + volatile uchar_t *ctrl; /* address of control register */ + + intercom_t rcv; /* incoming buffer */ + intercom_t snd; /* outgoing buffer */ + int cflag; /* control flag */ + + unsigned long ctrlmask; /* controller bitmask */ + unsigned char type; /* board type */ + + struct _bintec *next; +} *__bintec; + +#endif /* BINTEC_H */ diff --git a/cards/capi/bri.h b/cards/capi/bri.h new file mode 100644 index 0000000..31e624d --- /dev/null +++ b/cards/capi/bri.h @@ -0,0 +1,252 @@ +/************************************************************************/ +/* */ +/* (C) 1993 BinTec Computersysteme */ +/* All Rights Reserved */ +/* */ +/************************************************************************/ + +#ifdef __linux__ +#define far +#endif + +/************************************************************************ + + + ================================================== + = BIANCA-BRI, BRI-4 ISDN adapter for AT-BUS = + ================================================== + + memory layout, + + all shorts are motorola format, and have to be swapped to intel format + + 16 KByte shared memory + + +---------------+ + | 0x0008 | 8 KByte rcv buffer + ~ ~ + |---------------| + | 0x2000 | 8 KByte snd buffer + ~ ~ + |---------------| + | 0x3ff0 | size of rcv buffer + | 0x3ff2 | write index rcv buffer + | 0x3ff4 | read index rcv buffer + |---------------| + | 0x3ff6 | size of snd buffer + | 0x3ff8 | write index snd buffer + | 0x3ffa | read index snd buffer + |---------------| + | 0x3ffc | state register + | 0x3ffd | debug register + | 0x3ffe | control register + +---------------+ + + + + state register (BRI, BRI-4) + +-------+--------------------+----------------------------------+ + | BIT | READ | WRITE | + +-------+--------------------+----------------------------------+ + | 0 | | 1 -> gen interrupt if 680x0 CPU | + | | | has filled rcv buffer with | + | | | data | + +-------+--------------------+----------------------------------+ + | 1 | | 1 -> gen interrupt if 680x0 CPU | + | | | has read data from snd | + | | | buffer | + +-------+--------------------+----------------------------------+ + | 7 | 1 -> hardware | | + | | failure | | + +-------+--------------------+----------------------------------+ + + control register (BRI, BRI-4) + +-------+--------------------+----------------------------------+ + | BIT | READ | WRITE | + +-------+--------------------+----------------------------------+ + | 0 | 1 -> interrupt to | 0 -> disable interrupts | + | | host pending | 1 -> enable interrupts | + +-------+--------------------+----------------------------------+ + | 1 | 0 -> CPU in reset | 0 -> reset CPU | + +-------+--------------------+----------------------------------+ + | 2 | 0 -> CPU in halt | 0 -> halt CPU | + | | 1 -> CPU run | 1 -> run CPU | + +-------+--------------------+----------------------------------+ + | 3 | | 1 -> enable cpu cache | + +-------+--------------------+----------------------------------+ + | 4 | | 1 -> interrupt to 680x0 to read | + | | | shared memory | + +-------+--------------------+----------------------------------+ + | 7-5 | 0 -> BRI-4 | | + | | 1 -> X21 | | + | | 2 -> BRI | | + +-------+-------------------------------------------------------+ + + + + + + ================================================== + = BIANCA-PMX S2M ISDN adapter for AT-BUS = + ================================================== + + memory layout, + + all shorts are motorola format, and have to be swapped to intel format + + 64 KByte shared memory + + +---------------+ + | 0x0008 | 8 KByte rcv buffer + ~ ~ + |---------------| + | 0x2000 | 8 KByte snd buffer + ~ ~ + |---------------| + | 0x3ff0 | size of rcv buffer + | 0x3ff2 | write index rcv buffer + | 0x3ff4 | read index rcv buffer + |---------------| + | 0x3ff6 | size of snd buffer + | 0x3ff8 | write index snd buffer + | 0x3ffa | read index snd buffer + |---------------| + | 0x3ffc | state register + | 0x3ffd | debug register + ~ ~ + ~ ~ + | 0xfffe | control register + +---------------+ + + + + state register + +-------+--------------------+----------------------------------+ + | BIT | READ | WRITE | + +-------+--------------------+----------------------------------+ + | 0 | | 1 -> gen interrupt if 68040 CPU | + | | | has filled rcv buffer with | + | | | data | + +-------+--------------------+----------------------------------+ + | 1 | | 1 -> gen interrupt if 68040 CPU | + | | | has read data from snd | + | | | buffer | + +-------+--------------------+----------------------------------+ + | 7 | 1 -> hardware | | + | | failure | | + +-------+--------------------+----------------------------------+ + + control register + +-------+--------------------+----------------------------------+ + | BIT | READ | WRITE | + +-------+--------------------+----------------------------------+ + | 0 | | | + | | | 1 -> run CPU | + +-------+--------------------+----------------------------------+ + | 1 | | | + | | | 1 -> run CPU | + +-------+--------------------+----------------------------------+ + +*************************************************************************/ + +#ifndef __BRI_H +#define __BRI_H +/* static char _sccsid_bri_h[] = "@(#)bri.h 1.20"; */ + +/*----------------------------------------------------------------------*/ +/* MACRO-DEFINES */ +/*----------------------------------------------------------------------*/ +#define CTRL_ENABLE(bp) if ((bp)->type != BOARD_ID_PMX) \ + (*(bp)->ctrl = (bp)->cflag = 0xf) +#define CTRL_DISABLE(bp) if ((bp)->type != BOARD_ID_PMX) \ + (*(bp)->ctrl = (bp)->cflag = 0xe) +#define CTRL_SET(bp,val) (*(bp)->ctrl = (bp)->cflag = (val)) +#define STATE_SET(bp,val) (*(bp)->state = (val)) +#define CTRL_RESET(bp) reset_card(bp) + + + +/* #define BOARD_TYPE(bp) (*(bp)->ctrl >> 5) */ +#define BOARD_TYPE(bp) ((bp)->type) + +#define BOARD_ID_BRI4 0 /* Quattro 4 S0 */ +#define BOARD_ID_X21 1 /* X21 adapter */ +#define BOARD_ID_BRI 2 /* BRI */ +#define BOARD_ID_PMX 7 /* S2M */ + +#define BOARD_BOOTLOADER "BOOT.68K" +#define BOARD_SYS_BRI4 "BRI_Q.68K" +#define BOARD_SYS_BRI "BRI.68K" +#define BOARD_SYS_X21 "X21.68K" +#define BOARD_SYS_PMX "PMX.68K" + + +/*----------------------------------------------------------------------*/ +/* GLOBAL DEFINES */ +/*----------------------------------------------------------------------*/ +#define IO_8259A_1 0x20 /* IO addr of first 8259A */ +#define IO_8259A_2 0xa0 /* IO addr of second 8259A */ +#define OCW2_8259_EOI 0x20 /* end of interrupt command */ + +#define APIINIT_IDENT "Here is what I'am searching for" +#define API_BOSSCOM_ID 1 + + +/*----------------------------------------------------------------------*/ +/* DATA STRUCTURES */ +/*----------------------------------------------------------------------*/ +typedef struct { + unsigned short sz; /* size of buffer */ + unsigned short wi; /* write index */ + unsigned short ri; /* read index */ +} icinfo_t; + +typedef struct { + volatile unsigned char far *p; /* pointer to buffer */ + volatile icinfo_t far *d; /* buffer information */ +} intercom_t; + +#if 0 + +typedef struct { + unsigned addr; /* address of shared memory */ + unsigned char hwInt; /* intr */ + + volatile unsigned char far *base; /* base address of shared memory */ + volatile unsigned char far *state; /* state flag */ + volatile unsigned char far *debug; /* debug output */ + volatile unsigned char far *ctrl; /* address of control register */ + + intercom_t rcv; /* incoming intercom buffer */ + intercom_t snd; /* outgoing intercom buffer */ + int cflag; /* control flag */ + + unsigned long ctrlmask; /* controller bitmask */ + unsigned char type; /* board type */ +} board_t; + +typedef struct { + char section[512]; + char drvpath[512]; + char ctrl; + char type; +} bd_t; + +typedef struct { + unsigned short board; /* board */ + unsigned short ctrl; /* controller number */ + + char profile[32]; /* profile to load */ + char bindaddr[32]; /* login ident */ + unsigned short tei; /* static TEI, or -1 if dynamic */ + unsigned short disc_d; /* time to hold d-channel layer 2 */ + unsigned short permlink; /* permanent hold d-channel lay 2 */ + unsigned long flags; + char spid1[20]; /* service point identifier (NI-1) */ + char spid2[20]; /* service point identifier (NI-1) */ + char telno1[32]; /* own telno */ + char telno2[32]; /* own telno */ +} bdcfg_t; +#endif + +#endif diff --git a/cards/capi/capi.h b/cards/capi/capi.h new file mode 100644 index 0000000..cc16366 --- /dev/null +++ b/cards/capi/capi.h @@ -0,0 +1,1055 @@ +/****************************************************************************** +* +* (C)opyright 1993 BinTec Computersysteme GmbH +* All Rights Reserved +* +******************************************************************************/ + +#ifndef _APIDEF_H_ +# define _APIDEF_H_ +/* static char _sccsid_apidef_h[] = "@(#)apidef.h 1.28"; */ + +#if defined __GNUC__ +# define PACK __attribute__ ((packed)) +# define _PACK +#else +# define PACK +# define _PACK +#endif + + +#ifndef WINDOWS +# ifdef __MSDOS__ +# define FAR far +# else +# define FAR +# endif +#endif + +#define CAPI_MAXMSGLEN 180 +#define CAPI_MINMSGLEN 8 + +/************************************************************************/ +/* */ +/* 1TR6 specific defines */ +/* */ +/************************************************************************/ +/*-----------------------------*/ +/* CONNECT_REQ bchannel */ +/*-----------------------------*/ +#define CAPI_ANYBCHANNEL 0x83 + +/*-----------------------------*/ +/* INFO_REQ infotypes */ +/*-----------------------------*/ +#define AI_CAUSE 0x0008 /* codeset 0 */ +#define AI_DISPLAY 0x0028 /* codeset 0 */ +#define AI_DAD 0x0070 /* codeset 0 */ +#define AI_UUINFO 0x007e /* codeset 0 */ +#define AI_CHARGE 0x0602 /* codeset 6 */ +#define AI_DATE 0x0603 /* codeset 6 */ +#define AI_CPS 0x0607 /* codeset 6 */ + +/*-----------------------------*/ +/* CONNECT_REQ, IND services */ +/*-----------------------------*/ +#define SI_PHONE 1 +#define SI_ABSERVICES 2 +#define SI_X21 3 +#define SI_FAXG4 4 +#define SI_BTX 5 +#define SI_DATA 7 +#define SI_X25 8 +#define SI_TELETEX 9 +#define SI_MIXEDMODE 10 +#define SI_REMOTECTRL 13 +#define SI_GRAPHTEL 14 +#define SI_VIDEOTEXT 15 +#define SI_VIDEOPHONE 16 + + + + + +/************************************************************************/ +/* */ +/* CAPI infomask bit settings */ +/* */ +/************************************************************************/ +#define CAPI_ICHARGE 0x01L /* BIT 0 */ +#define CAPI_IDATE 0x02L /* BIT 1 */ +#define CAPI_IDISPLAY 0x04L /* BIT 2 */ +#define CAPI_IUUINFO 0x08L /* BIT 3 */ +#define CAPI_ICAUSE 0x10L /* BIT 4 */ +#define CAPI_ISTATE 0x20L /* BIT 5 */ +#define CAPI_IDESTINATION 0x40L /* BIT 6 */ +#define CAPI_IDTMF 0x80L /* BIT 7 */ +#define CAPI_ISPV 0x40000000L /* BIT 30 */ +#define CAPI_ISUBADDR 0x80000000L /* BIT 31 */ + +#define CAPI_INFOMASK ( CAPI_ICHARGE | CAPI_IDATE | \ + CAPI_IDISPLAY | CAPI_IUUINFO | \ + CAPI_ICAUSE | CAPI_ISTATE | \ + CAPI_ISPV | CAPI_ISUBADDR ) + +#define CAPI_ALLINFOMASK ( CAPI_ICHARGE | CAPI_IDATE | \ + CAPI_IDISPLAY | CAPI_IUUINFO | \ + CAPI_ICAUSE | CAPI_ISTATE | \ + CAPI_ISPV | CAPI_ISUBADDR | \ + CAPI_IDTMF | CAPI_IDESTINATION) + +#define CAPI_SIMASK 0xe7bf +#define CAPI_EAZMASK 0x3ff + + +/************************************************************************/ +/* */ +/* CAPI error codes */ +/* */ +/************************************************************************/ +#define CAPI_E_REGISTER 0x1001 +#define CAPI_E_APPLICATION 0x1002 +#define CAPI_E_MSGLENGTH 0x1003 +#define CAPI_E_COMMAND 0x1004 +#define CAPI_E_QUEUEFULL 0x1005 +#define CAPI_E_NOMSG 0x1006 +#define CAPI_E_MSGOVERFLOW 0x1007 +#define CAPI_E_DEINSTALL 0x1008 +#define CAPI_E_CONTROLLER 0x2001 +#define CAPI_E_PLCI 0x2002 +#define CAPI_E_NCCI 0x2003 +#define CAPI_E_BCHANNEL 0x3101 +#define CAPI_E_INFOMASK 0x3102 +#define CAPI_E_EAZMASK 0x3103 +#define CAPI_E_SIMASK 0x3104 +#define CAPI_E_B2PROTO 0x3105 +#define CAPI_E_DLPD 0x3106 +#define CAPI_E_B3PROTO 0x3107 +#define CAPI_E_NCPD 0x3108 +#define CAPI_E_NCPI 0x3109 +#define CAPI_E_DATAB3FLAGS 0x310a +#define CAPI_E_CONTROLLERFAILED 0x3201 +#define CAPI_E_REGCONFLICT 0x3202 +#define CAPI_E_CMDNOTSUPPORTED 0x3203 +#define CAPI_E_PLCIACT 0x3204 +#define CAPI_E_NCCIACT 0x3205 +#define CAPI_E_B2NOTSUPPORT 0x3206 +#define CAPI_E_B2STATE 0x3207 +#define CAPI_E_B3NOTSUPPORT 0x3208 +#define CAPI_E_B3STATE 0x3209 +#define CAPI_E_B2DLPDPARA 0x320a +#define CAPI_E_B3NCPDPARA 0x320b +#define CAPI_E_DATALEN 0x320d +#define CAPI_E_DTMF 0x320e +#define CAPI_E_NOL1 0x3301 +#define CAPI_E_NOL2 0x3302 +#define CAPI_E_SETUPBCHANLAYER1 0x3303 +#define CAPI_E_SETUPBCHANLAYER2 0x3304 +#define CAPI_E_ABORTBCHANLAYER1 0x3308 +#define CAPI_E_ABORTBCHANLAYER2 0x3309 +#define CAPI_E_ABORTBCHANLAYER3 0x330a +#define CAPI_E_REBCHANLAYER3 0x330c + +#define CAPI_E_NOFAX 0x4001 +#define CAPI_E_BADLINE 0x4004 +#define CAPI_E_NOANSWER 0x4008 +#define CAPI_E_REMDISC 0x4009 +#define CAPI_E_NOCMD 0x400a +#define CAPI_E_INCOMPAT 0x400b +#define CAPI_E_BADDATA 0x400c +#define CAPI_E_PROTO 0x400d + + +/************************************************************************/ +/* */ +/* CAPI 1.1 primitives */ +/* */ +/************************************************************************/ +#define CAPI_CONNECT_REQ 0x0002 +#define CAPI_CONNECT_CONF 0x0102 +#define CAPI_CONNECT_IND 0x0202 +#define CAPI_CONNECT_RESP 0x0302 +#define CAPI_CONNECTINFO_REQ 0x0009 +#define CAPI_CONNECTINFO_CONF 0x0109 +#define CAPI_CONNECTACTIVE_IND 0x0203 +#define CAPI_CONNECTACTIVE_RESP 0x0303 +#define CAPI_DISCONNECT_REQ 0x0004 +#define CAPI_DISCONNECT_CONF 0x0104 +#define CAPI_DISCONNECT_IND 0x0204 +#define CAPI_DISCONNECT_RESP 0x0304 +#define CAPI_LISTEN_REQ 0x0005 +#define CAPI_LISTEN_CONF 0x0105 +#define CAPI_GETPARAMS_REQ 0x0006 +#define CAPI_GETPARAMS_CONF 0x0106 +#define CAPI_INFO_REQ 0x0007 +#define CAPI_INFO_CONF 0x0107 +#define CAPI_INFO_IND 0x0207 +#define CAPI_INFO_RESP 0x0307 +#define CAPI_DATA_REQ 0x0008 +#define CAPI_DATA_CONF 0x0108 +#define CAPI_DATA_IND 0x0208 +#define CAPI_DATA_RESP 0x0308 +#define CAPI_SELECTB2_REQ 0x0040 +#define CAPI_SELECTB2_CONF 0x0140 +#define CAPI_SELECTB3_REQ 0x0080 +#define CAPI_SELECTB3_CONF 0x0180 +#define CAPI_LISTENB3_REQ 0x0081 +#define CAPI_LISTENB3_CONF 0x0181 +#define CAPI_CONNECTB3_REQ 0x0082 +#define CAPI_CONNECTB3_CONF 0x0182 +#define CAPI_CONNECTB3_IND 0x0282 +#define CAPI_CONNECTB3_RESP 0x0382 +#define CAPI_CONNECTB3ACTIVE_IND 0x0283 +#define CAPI_CONNECTB3ACTIVE_RESP 0x0383 +#define CAPI_DISCONNECTB3_REQ 0x0084 +#define CAPI_DISCONNECTB3_CONF 0x0184 +#define CAPI_DISCONNECTB3_IND 0x0284 +#define CAPI_DISCONNECTB3_RESP 0x0384 +#define CAPI_GETB3PARAMS_REQ 0x0085 +#define CAPI_GETB3PARAMS_CONF 0x0185 +#define CAPI_DATAB3_REQ 0x0086 +#define CAPI_DATAB3_CONF 0x0186 +#define CAPI_DATAB3_IND 0x0286 +#define CAPI_DATAB3_RESP 0x0386 +#define CAPI_RESETB3_REQ 0x0001 +#define CAPI_RESETB3_CONF 0x0101 +#define CAPI_RESETB3_IND 0x0201 +#define CAPI_RESETB3_RESP 0x0301 +#define CAPI_HANDSET_IND 0x0287 +#define CAPI_HANDSET_RESP 0x0387 +#define CAPI_DTMF_REQ 0x000a +#define CAPI_DTMF_CONF 0x010a +#define CAPI_DTMF_IND 0x020a +#define CAPI_DTMF_RESP 0x030a + + +/************************************************************************/ +/* */ +/* BinTec specific CAPI primitives */ +/* */ +/************************************************************************/ +#define CAPI_CONTROL_REQ 0x00ff +#define CAPI_CONTROL_CONF 0x01ff +#define CAPI_CONTROL_IND 0x02ff +#define CAPI_CONTROL_RESP 0x03ff + + +#define CAPI_OPERATION_MSG 0xffe0 /* start of operation msg */ + +#define CAPI_ALIVE_IND 0xfff0 +#define CAPI_ALIVE_RESP 0xfff1 +#define CAPI_REGISTER_REQ 0xfff2 +#define CAPI_REGISTER_CONF 0xfff3 +#define CAPI_RELEASE_REQ 0xfff4 +#define CAPI_RELEASE_CONF 0xfff5 +#define CAPI_SETSIGNAL_REQ 0xfff6 +#define CAPI_SETSIGNAL_CONF 0xfff7 +#define CAPI_DEINSTALL_REQ 0xfff8 +#define CAPI_DEINSTALL_CONF 0xfff9 +#define CAPI_GETMANUFACT_REQ 0xfffa +#define CAPI_GETMANUFACT_CONF 0xfffb +#define CAPI_GETVERSION_REQ 0xfffc +#define CAPI_GETVERSION_CONF 0xfffd +#define CAPI_GETSERIAL_REQ 0xfffe +#define CAPI_GETSERIAL_CONF 0xffff + + +/************************************************************************/ +/* */ +/* CAPI function codes */ +/* */ +/************************************************************************/ +#define CAPI_REGISTER 0x01 +#define CAPI_RELEASE 0x02 +#define CAPI_PUTMESSAGE 0x03 +#define CAPI_GETMESSAGE 0x04 +#define CAPI_SETSIGNAL 0x05 +#define CAPI_DEINSTALL 0x06 +#define CAPI_GETMANUFACT 0xf0 +#define CAPI_GETVERSION 0xf1 +#define CAPI_GETSERIAL 0xf2 +#define CAPI_MANUFACTURER 0xff + + + + +/************************************************************************/ +/* */ +/* Flags for CAPI_DATAB3_REQ/IND */ +/* */ +/************************************************************************/ +#define CAPI_QUALIFIER 0x01 +#define CAPI_MORE 0x02 +#define CAPI_DELIVERY 0x04 +#define CAPI_ALLFLAGS (CAPI_QUALIFIER | CAPI_MORE | CAPI_DELIVERY) + + +/************************************************************************/ +/* */ +/* BinTec specific control type values */ +/* */ +/************************************************************************/ +#define CONTROL_APIREC_ON 0x01 +#define CONTROL_APIREC_OFF 0x02 +#define CONTROL_APIREC_PLAY 0x03 +#define CONTROL_TRACELEVEL 0x04 +#define CONTROL_API_OPEN 0x05 +#define CONTROL_API_CLOSE 0x06 +#define CONTROL_LOOPBACK 0x08 +#define CONTROL_APISTATE 0x09 +#define CONTROL_SHOWMSG 0x0a +#define CONTROL_SHOWMEM 0x0b +#define CONTROL_TRACEREC_ON 0x0c +#define CONTROL_TRACEREC_OFF 0x0d +#define CONTROL_TRACEREC_PLAY 0x0e +#define CONTROL_ACCOUNT_PLAY 0x0f +#define CONTROL_STATIST 0x10 +#define CONTROL_EAZMAPPING 0x11 + +/************************************************************************/ +/* */ +/* flags for apiopen.flags */ +/* CAPI behaviour flags */ +/* */ +/************************************************************************/ +#define COMPAT_NODLPDCHECK 0x0001 +#define COMPAT_FAXMAXSPEED 0x0002 +#define COMPAT_TRANSREVBIT 0x0004 +#define COMPAT_X25CALLNODBIT 0x0008 +#define COMPAT_MAPNOEAZTOZERO 0x0010 +#define COMPAT_NOQ931ON 0x0020 +#define COMPAT_NOIEDATE 0x0040 +#define COMPAT_NOALIVEIND 0x0080 +#define COMPAT_ALERTING 0x0100 + + +/************************************************************************/ +/* */ +/* CAPI protocol types */ +/* */ +/************************************************************************/ +enum CAPI_l2prots { L2X75 = 0x01, + L2HDLCCRC = 0x02, + L2TRANS = 0x03, + L2SDLC = 0x04, /* not yet implemented */ + L2X75BTX = 0x05, + L2FAX = 0x06, + L2LAPD = 0x07, + L2V110TRANS = 0x08, + L2V110SDLC = 0x09, /* not yet implemented */ + L2V110X75 = 0x0a, + L2TXONLY = 0x0b, + L2MODEM = 0xf0 +}; + +enum CAPI_l3prots { L3T70NL = 0x01, + L3ISO8208 = 0x02, + L3T90 = 0x03, + L3TRANS = 0x04, + L3T30 = 0x05, + L3T70ASS = 0xf0 /* assemble t70 packets */ +}; + + + + +/************************************************************************/ +/* */ +/* CAPI userdata structures */ +/* */ +/************************************************************************/ +struct userdata { + unsigned char data[ CAPI_MAXMSGLEN ] _PACK; +} PACK ; + +struct telno { + unsigned char info _PACK; + unsigned char no[32] _PACK; +} PACK ; + +struct dlpd { + unsigned short data_length _PACK; + unsigned char link_addr_a _PACK; + unsigned char link_addr_b _PACK; + unsigned char modulo_mode _PACK; + unsigned char window_size _PACK; + unsigned char xid _PACK; +} PACK ; + +struct dlpd_v110 { + unsigned short data_length _PACK; + unsigned char link_addr_a _PACK; + unsigned char link_addr_b _PACK; + unsigned char modulo_mode _PACK; + unsigned char window_size _PACK; + unsigned char user_rate _PACK; /* V110 */ + unsigned char xid _PACK; +} PACK ; + +struct ncpd_x25 { + unsigned short lic _PACK; + unsigned short hic _PACK; + unsigned short ltc _PACK; + unsigned short htc _PACK; + unsigned short loc _PACK; + unsigned short hoc _PACK; + unsigned char modulo_mode _PACK; +} PACK ; + +struct ncpd_t30 { + unsigned char resolution _PACK; + unsigned char max_speed _PACK; + unsigned char format _PACK; + unsigned char xmit_level _PACK; + unsigned char station_id_length _PACK; +} PACK ; + +struct ncpi { + unsigned char data[180] _PACK; +} PACK ; + +struct ncpi_t30 { + unsigned char resolution _PACK; + unsigned char speed _PACK; + unsigned char format _PACK; + unsigned char pages _PACK; + unsigned char receiver_id_length _PACK; +} PACK ; + +struct dtmfnum { + unsigned char numbers[32] _PACK; +} PACK ; + +struct sff_doc_header { + unsigned long sff_id _PACK; + unsigned char version _PACK; + unsigned char reserved _PACK; + unsigned short user_info _PACK; + unsigned short num_pages _PACK; + unsigned short first_page _PACK; + unsigned long last_page _PACK; + unsigned long file_size _PACK; +} PACK ; + +struct sff_page_header { + unsigned char vert_res _PACK; + unsigned char horiz_res _PACK; + unsigned char coding _PACK; + unsigned char specials _PACK; + unsigned short linelen _PACK; + unsigned short pagelen _PACK; + unsigned long prev_page _PACK; + unsigned long next_page _PACK; +} PACK ; + + + + +/************************************************************************/ +/* */ +/* BinTec specific CAPI data structures */ +/* */ +/************************************************************************/ + +/* this is not a real message, only an identifier for DOS CAPI.EXE */ +struct apiinitpara { + char identifier[64] _PACK; + unsigned short memaddr _PACK; + unsigned char intr _PACK; + unsigned char type _PACK; + unsigned char bdnum _PACK; + unsigned long ctrlmask _PACK; +} PACK ; + + + +struct apiopen { + char protocol[32] _PACK; + unsigned short teid _PACK; + unsigned short b3pl _PACK; + unsigned short t3id _PACK; + unsigned short contrl _PACK; + char bindaddr[32] _PACK; + unsigned long time _PACK; + unsigned long flags _PACK; + unsigned char spid1[20] _PACK; + unsigned char spid2[20] _PACK; +} PACK ; + +struct traceopen { + unsigned char contrl _PACK; + unsigned char channel _PACK; + unsigned char dummy _PACK; + short maxlen _PACK; /* -1 if not specified */ +} PACK ; + +struct tracedata { + unsigned char blknum _PACK; + unsigned long timer _PACK; + unsigned long ppa _PACK; + unsigned long event _PACK; + unsigned long inout _PACK; +#ifdef __MSDOS__ + char far *dataPtr; +#else + unsigned long dataPtr _PACK; +#endif + unsigned short datalen _PACK; +} PACK ; + +struct apiaccount { + unsigned short appl _PACK; + unsigned short plci _PACK; + unsigned short ncci _PACK; + unsigned long callref _PACK; + unsigned char l2prots _PACK; + unsigned char l3prots _PACK; + unsigned short cause _PACK; + unsigned short charge _PACK; + unsigned short time _PACK; + unsigned char date[20] _PACK; + unsigned char service _PACK; + unsigned char addinfo _PACK; + unsigned char eaz _PACK; + unsigned char channel _PACK; + struct telno telno _PACK; +} PACK ; + + +struct apistatist { + unsigned char contrl _PACK; /* capi controllernumber */ + unsigned char usedbchannels _PACK; + unsigned char l1stat _PACK; + unsigned long xpkts[3] _PACK; /* packets transmit */ + unsigned long rpkts[3] _PACK; /* packets received */ + unsigned long xerrs[3] _PACK; /* errors transmit */ + unsigned long rerrs[3] _PACK; /* errors received */ + + unsigned long xthr[2] _PACK; /* throughput send */ + unsigned long rthr[2] _PACK; /* throughput receive */ + unsigned short plci[2] _PACK; /* plci with used bchan */ + unsigned char pstate[2] _PACK; /* plci state */ + unsigned long incon[2] _PACK; /* number of incoming */ + unsigned long outcon[2] _PACK; /* number of outgoing */ +} PACK ; + +struct eazmapping { + unsigned char contrl _PACK; + unsigned char eaz _PACK; + unsigned char telnolen _PACK; +} PACK ; + +/************************************************************************/ +/* */ +/* BinTec specific CAPI message structures */ +/* */ +/************************************************************************/ +struct CAPI_every_header { + unsigned short len _PACK; + unsigned short appl _PACK; /* applid from the pc */ + unsigned short PRIM_type _PACK; + unsigned short messid _PACK; +} PACK; + +struct CAPI_register_req { + unsigned long buffer _PACK; + unsigned short nmess _PACK; + unsigned short nconn _PACK; + unsigned short ndblock _PACK; + unsigned short dblocksiz _PACK; +} PACK ; + +struct CAPI_register_conf { +} PACK ; + +struct CAPI_release_req { + unsigned short relappl _PACK; /* appl to release */ +} PACK ; + +struct CAPI_release_conf { + unsigned short info _PACK; /* for error reports */ +} PACK ; + +struct CAPI_deinstall_req { +} PACK ; + +struct CAPI_deinstall_conf { + unsigned short info _PACK; +} PACK ; + +struct CAPI_getmanufact_req { +} PACK ; + +struct CAPI_getmanufact_conf { + unsigned char datalen _PACK; +} PACK ; + +struct CAPI_getversion_req { +} PACK ; + +struct CAPI_getversion_conf { + unsigned char datalen _PACK; +} PACK ; + +struct CAPI_getserial_req { +} PACK ; + +struct CAPI_getserial_conf { + unsigned char datalen _PACK; +} PACK ; + + +struct CAPI_control_req { + unsigned short contrl PACK; + unsigned short type _PACK; + unsigned char datalen _PACK; +} PACK ; + +struct CAPI_control_conf { + unsigned short contrl _PACK; + unsigned short type _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_control_ind { + unsigned short contrl _PACK; + unsigned short type _PACK; + unsigned char datalen _PACK; +} PACK ; + +struct CAPI_control_resp { + unsigned short contrl _PACK; + unsigned short type _PACK; + unsigned char datalen _PACK; +} PACK ; + +struct CAPI_alive_ind { +} PACK ; + +struct CAPI_alive_resp { +} PACK ; + + + + +/************************************************************************/ +/* */ +/* CAPI message structures */ +/* */ +/************************************************************************/ +struct CAPI_connect_req { + unsigned char contrl _PACK; + unsigned char channel _PACK; + unsigned long infomask _PACK; + unsigned char DST_service _PACK; + unsigned char DST_addinfo _PACK; + unsigned char SRC_eaz _PACK; + + unsigned char telnolen _PACK; +} PACK ; + +struct CAPI_connect_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_connect_ind { + unsigned short plci _PACK; + unsigned char contrl _PACK; + unsigned char DST_service _PACK; + unsigned char DST_addinfo _PACK; + unsigned char DST_eaz _PACK; + + unsigned char telnolen _PACK; +} PACK ; + +struct CAPI_connect_resp { + unsigned short plci _PACK; + unsigned char reject _PACK; /* 0: accept, != 0: reject */ +} PACK ; + +struct CAPI_connectinfo_req { + unsigned short plci _PACK; + unsigned char telnolen _PACK; +} PACK ; + +struct CAPI_connectinfo_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_connectactive_ind { + unsigned short plci _PACK; + unsigned char telnolen _PACK; +} PACK ; + +struct CAPI_connectactive_resp { + unsigned short plci _PACK; +} PACK ; + +struct CAPI_disconnect_req { + unsigned short plci _PACK; + unsigned char cause _PACK; +} PACK ; + +struct CAPI_disconnect_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_disconnect_ind { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_disconnect_resp { + unsigned short plci _PACK; +} PACK ; + +struct CAPI_listen_req { + unsigned char contrl _PACK; + unsigned long info_mask _PACK; + unsigned short eaz_mask _PACK; + unsigned short service_mask _PACK; +} PACK ; + +struct CAPI_listen_conf { + unsigned char contrl _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_getparams_req { + unsigned short plci _PACK; +} PACK ; + +struct CAPI_getparams_conf { + unsigned short plci _PACK; + unsigned char contrl _PACK; + unsigned char chan _PACK; + unsigned short info _PACK; + unsigned char B3_linkcnt _PACK; + unsigned char service _PACK; + unsigned char addinfo _PACK; + unsigned char eaz _PACK; + unsigned char telnolen _PACK; +} PACK ; + +struct CAPI_info_req { + unsigned short plci _PACK; + unsigned long info_mask _PACK; +} PACK ; + +struct CAPI_info_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_info_ind { + unsigned short plci _PACK; + unsigned short info_number _PACK; + unsigned char infolen _PACK; +} PACK ; + +struct CAPI_info_resp { + unsigned short plci _PACK; +} PACK ; + +struct CAPI_data_req { + unsigned short plci _PACK; + unsigned char datalen _PACK; +} PACK ; + +struct CAPI_data_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_data_ind { + unsigned short plci _PACK; + unsigned char datalen _PACK; +} PACK ; + +struct CAPI_data_resp { + unsigned short plci _PACK; +} PACK ; + +struct CAPI_selectb2_req { + unsigned short plci _PACK; + unsigned char B2_proto _PACK; + unsigned char dlpdlen _PACK; +} PACK ; + +struct CAPI_selectb2_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_selectb3_req { + unsigned short plci _PACK; + unsigned char B3_proto _PACK; + unsigned char ncpdlen _PACK; +} PACK ; + +struct CAPI_selectb3_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_listenb3_req { + unsigned short plci _PACK; +} PACK ; + +struct CAPI_listenb3_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_connectb3_req { + unsigned short plci _PACK; + unsigned char ncpilen _PACK; +} PACK ; + +struct CAPI_connectb3_conf { + unsigned short plci _PACK; + unsigned short ncci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_connectb3_ind { + unsigned short ncci _PACK; + unsigned short plci _PACK; + unsigned char ncpilen _PACK; +} PACK ; + +struct CAPI_connectb3_resp { + unsigned short ncci _PACK; + unsigned char reject _PACK; + unsigned char ncpilen _PACK; +} PACK ; + +struct CAPI_connectb3active_ind { + unsigned short ncci _PACK; + unsigned char ncpilen _PACK; +} PACK ; + +struct CAPI_connectb3active_resp { + unsigned short ncci _PACK; +} PACK ; + +struct CAPI_disconnectb3_req { + unsigned short ncci _PACK; + unsigned char ncpilen _PACK; +} PACK ; + +struct CAPI_disconnectb3_conf { + unsigned short ncci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_disconnectb3_ind { + unsigned short ncci _PACK; + unsigned short info _PACK; + unsigned char ncpilen _PACK; +} PACK ; + +struct CAPI_disconnectb3_resp { + unsigned short ncci _PACK; +} PACK ; + +struct CAPI_getb3params_req { + unsigned short ncci _PACK; +} PACK ; + +struct CAPI_getb3params_conf { + unsigned short ncci _PACK; + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_datab3_req { + unsigned short ncci _PACK; + unsigned short datalen _PACK; +#ifdef __MSDOS__ + char far *data _PACK; +#else + unsigned long data _PACK; +#endif + unsigned char blknum _PACK; + unsigned short flags _PACK; /* MORE_flag ... */ + +} PACK ; + +struct CAPI_datab3_conf { + unsigned short ncci _PACK; + unsigned char blknum _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_datab3_ind { + unsigned short ncci _PACK; + unsigned short datalen _PACK; +#ifdef __MSDOS__ + char far *data _PACK; +#else + unsigned long data _PACK; +#endif + unsigned char blknum _PACK; + unsigned short flags _PACK; /* MORE_flag ... */ + +} PACK ; + +struct CAPI_datab3_resp { + unsigned short ncci _PACK; + unsigned char blknum _PACK; +} PACK ; + +struct CAPI_resetb3_req { + unsigned short ncci _PACK; +} PACK ; + +struct CAPI_resetb3_conf { + unsigned short ncci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_resetb3_ind { + unsigned short ncci _PACK; +} PACK ; + +struct CAPI_resetb3_resp { + unsigned short ncci _PACK; +} PACK ; + +struct CAPI_handset_ind { + unsigned short plci _PACK; + unsigned char contrl _PACK; + unsigned char state _PACK; +} PACK ; + +struct CAPI_handset_resp { + unsigned short plci _PACK; +} PACK ; + +struct CAPI_dtmf_req { + unsigned short plci _PACK; + unsigned short tonedurat _PACK; + unsigned short gapdurat _PACK; + unsigned char dtmflen _PACK; +} PACK ; + +struct CAPI_dtmf_conf { + unsigned short plci _PACK; + unsigned short info _PACK; +} PACK ; + +struct CAPI_dtmf_ind { + unsigned short plci _PACK; + unsigned char dtmflen _PACK; +} PACK ; + +struct CAPI_dtmf_resp { + unsigned short plci _PACK; +} PACK ; + + +struct CAPI_sheader { +} PACK ; + +struct CAPI_header { + unsigned short ident _PACK; /* either 'plci' or 'ncci' */ +} PACK ; + +struct CAPI_cheader { + unsigned char control _PACK; /* controller */ +} PACK ; + + +union CAPI_primitives { + char CAPI_msg[ CAPI_MAXMSGLEN ] _PACK; + struct CAPI_sheader sheader _PACK; + struct CAPI_cheader cheader _PACK; + struct CAPI_header header _PACK; + + struct CAPI_connect_req connect_req _PACK; + struct CAPI_connect_conf connect_conf _PACK; + struct CAPI_connect_ind connect_ind _PACK; + struct CAPI_connect_resp connect_resp _PACK; + struct CAPI_connectinfo_req connectinfo_req _PACK; + struct CAPI_connectinfo_conf connectinfo_conf _PACK; + struct CAPI_connectactive_ind connectactive_ind _PACK; + struct CAPI_connectactive_resp connectactive_resp _PACK; + struct CAPI_disconnect_req disconnect_req _PACK; + struct CAPI_disconnect_conf disconnect_conf _PACK; + struct CAPI_disconnect_ind disconnect_ind _PACK; + struct CAPI_disconnect_resp disconnect_resp _PACK; + struct CAPI_listen_req listen_req _PACK; + struct CAPI_listen_conf listen_conf _PACK; + struct CAPI_getparams_req getparams_req _PACK; + struct CAPI_getparams_conf getparams_conf _PACK; + struct CAPI_info_req info_req _PACK; + struct CAPI_info_conf info_conf _PACK; + struct CAPI_info_ind info_ind _PACK; + struct CAPI_info_resp info_resp _PACK; + struct CAPI_data_req data_req _PACK; + struct CAPI_data_conf data_conf _PACK; + struct CAPI_data_ind data_ind _PACK; + struct CAPI_data_resp data_resp _PACK; + struct CAPI_selectb2_req selectb2_req _PACK; + struct CAPI_selectb2_conf selectb2_conf _PACK; + struct CAPI_selectb3_req selectb3_req _PACK; + struct CAPI_selectb3_conf selectb3_conf _PACK; + struct CAPI_listenb3_req listenb3_req _PACK; + struct CAPI_listenb3_conf listenb3_conf _PACK; + struct CAPI_connectb3_req connectb3_req _PACK; + struct CAPI_connectb3_conf connectb3_conf _PACK; + struct CAPI_connectb3_ind connectb3_ind _PACK; + struct CAPI_connectb3_resp connectb3_resp _PACK; + struct CAPI_connectb3active_ind connectb3active_ind _PACK; + struct CAPI_connectb3active_resp connectb3active_resp _PACK; + struct CAPI_disconnectb3_req disconnectb3_req _PACK; + struct CAPI_disconnectb3_conf disconnectb3_conf _PACK; + struct CAPI_disconnectb3_ind disconnectb3_ind _PACK; + struct CAPI_disconnectb3_resp disconnectb3_resp _PACK; + struct CAPI_getb3params_req getb3params_req _PACK; + struct CAPI_getb3params_conf getb3params_conf _PACK; + struct CAPI_datab3_req datab3_req _PACK; + struct CAPI_datab3_conf datab3_conf _PACK; + struct CAPI_datab3_ind datab3_ind _PACK; + struct CAPI_datab3_resp datab3_resp _PACK; + struct CAPI_resetb3_req resetb3_req _PACK; + struct CAPI_resetb3_conf resetb3_conf _PACK; + struct CAPI_resetb3_ind resetb3_ind _PACK; + struct CAPI_resetb3_resp resetb3_resp _PACK; + struct CAPI_handset_ind handset_ind _PACK; + struct CAPI_handset_resp handset_resp _PACK; + struct CAPI_dtmf_req dtmf_req _PACK; + struct CAPI_dtmf_conf dtmf_conf _PACK; + struct CAPI_dtmf_ind dtmf_ind _PACK; + struct CAPI_dtmf_resp dtmf_resp _PACK; + + /* BinTec specific CAPI manufacturer messages */ + struct CAPI_control_req control_req _PACK; + struct CAPI_control_conf control_conf _PACK; + struct CAPI_control_ind control_ind _PACK; + struct CAPI_control_resp control_resp _PACK; + + struct CAPI_alive_ind alive_ind _PACK; + struct CAPI_alive_resp alive_resp _PACK; + + struct CAPI_register_req register_req _PACK; + struct CAPI_register_conf register_conf _PACK; + struct CAPI_release_req release_req _PACK; + struct CAPI_release_conf release_conf _PACK; + struct CAPI_deinstall_req deinstall_req _PACK; + struct CAPI_deinstall_conf deinstall_conf _PACK; + struct CAPI_getmanufact_req manufact_req _PACK; + struct CAPI_getmanufact_conf manufact_conf _PACK; + struct CAPI_getserial_req getserial_req _PACK; + struct CAPI_getserial_conf getserial_conf _PACK; + struct CAPI_getversion_req getversion_req _PACK; + struct CAPI_getversion_conf getversion_conf _PACK; +} PACK; + + + +#endif diff --git a/cards/capi/insert.c b/cards/capi/insert.c new file mode 100644 index 0000000..f1a479e --- /dev/null +++ b/cards/capi/insert.c @@ -0,0 +1,55 @@ +#include "f_module.h" +#include "isdn_limits.h" +#include + +#ifdef linux +#include +#endif + +#include "bintec.h" + +#ifndef REALNAME +#error "You have to define REALNAME for this to work." +#endif + +#define xxappxx(a,b) a##b +#define NAME(a,b) xxappxx(a,b) /* isn't C wonderful */ +#define xxstrxx(a) #a +#define STRING(a) xxstrxx(a) /* ditto */ + +extern int NAME(REALNAME,init)(struct _bintec *bp); +extern void NAME(REALNAME,exit)(struct _bintec *bp); + +struct _bintec bintec; + +int irq = 0; +int mem = 0; +int io = 0; +int name = 0; +int debug = 0; + +#ifdef MODULE +static int do_init_module(void) +{ + if(name == 0) { + printf("You must name this card: insmod xxx.o name=$(cardname Foo0)\n"); + return -EINVAL; + } + bintec.irq = irq; + bintec.ipl = 5; + bintec.ioaddr = io; + bintec.memaddr = mem; + bintec.ID = name; + bintec.debug = debug; + return NAME(REALNAME,init)(&bintec); +} + +static int do_exit_module(void) +{ + NAME(REALNAME,exit)(&bintec); + return 0; +} +#else +#error "This can only be used as a module!" +#endif + diff --git a/cards/dumb/Makefile b/cards/dumb/Makefile index d992949..d6ace2c 100644 --- a/cards/dumb/Makefile +++ b/cards/dumb/Makefile @@ -1,93 +1,9 @@ +all:: -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +DOCARDS=1 +REALSOURCE=shell.c +SOURCES=avm.c ncp.c teles.c ncp16.c bsc.c -## =()@>()= -CC = gcc -## =()@ @@ -I../../include >()= -DEFS = -I../../streams -I../../compat -fomit-frame-pointer -funroll-loops -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@>()= -LD = ld -## =()@>()= -DUMBCARDS = teles - -## =()@>()= -SYS = linux - -SOURCES = avm_io.c bsc_io.c teles_io.c ncp_io.c ncp16_io.c shell.c insert.c - -OBJ = -ALL = teles.o avm.o bsc.o ncp.o ncp16.o \ - d_teles.o d_avm.o d_bsc.o d_ncp.o d_ncp16.o - -all: $(foreach c,${DUMBCARDS},$c.o) $(foreach c,${DUMBCARDS},d_$c.o) - -load: $(foreach c,${DUMBCARDS},ins-$c) - - -avm.o: insert.c - $(CC) $(CFLAGS) -DCARDTYPE=avm -o avm.o -c insert.c -bsc.o: insert.c - $(CC) $(CFLAGS) -DCARDTYPE=bsc -o bsc.o -c insert.c -ncp16.o: insert.c - $(CC) $(CFLAGS) -DCARDTYPE=ncp16 -o ncp16.o -c insert.c -ncp.o: insert.c - $(CC) $(CFLAGS) -DCARDTYPE=ncp -o ncp.o -c insert.c -teles.o: insert.c - $(CC) $(CFLAGS) -DCARDTYPE=teles -o teles.o -c insert.c - -d_avm.o: shell.c avm_io.c - $(CC) $(CFLAGS) -D_avm_ -o d_avm.o -c shell.c -d_bsc.o: shell.c bsc_io.c - $(CC) $(CFLAGS) -D_bsc_ -o d_bsc.o -c shell.c -d_ncp16.o: shell.c ncp16_io.c - $(CC) $(CFLAGS) -D_ncp16_ -DWIDE -o d_ncp16.o -c shell.c -d_ncp.o: shell.c ncp_io.c - $(CC) $(CFLAGS) -D_ncp_ -o d_ncp.o -c shell.c -d_teles.o: shell.c teles_io.c - $(CC) $(CFLAGS) -D_teles_ -o d_teles.o -c shell.c - -ins-avm: - insmod d_avm.o - insmod avm.o -ins-bsc: - insmod d_bsc.o - insmod bsc.o -ins-teles: - insmod d_teles.o - insmod teles.o -ins-ncp: - insmod d_ncp.o - insmod ncp.o -ins-ncp16: - insmod d_ncp16.o - insmod ncp16.o - -lib: - -indent: - ../../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - cp /dev/null .depend - for i in avm ncp teles bsc ; do $(CC) -D_$${i}_ -M $(DEFS) shell.c |\ - sed -e "s/shell\.o/X$${i}.o/" >> .depend ; done - -clean: - rm -f $(OBJ) $(ALL) - -install: all - @sh ../../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=../.. +include $(TOPDIR)/Make.rules diff --git a/cards/dumb/avm_io.c b/cards/dumb/avm_io.c index 110893e..dd98762 100644 --- a/cards/dumb/avm_io.c +++ b/cards/dumb/avm_io.c @@ -1,41 +1,41 @@ inline static Byte InISAC(struct _dumb * dumb, char offset) { if(offset >= 0x20) - return ByteIn(dumb->ioaddr+0x1400-0x20+offset); + return ByteIn(dumb->info.ioaddr+0x1400-0x20+offset); else - return ByteIn(dumb->ioaddr+0x1000+offset); /* ?? */ + return ByteIn(dumb->info.ioaddr+0x1000+offset); /* ?? */ } inline static void OutISAC(struct _dumb * dumb, char offset, Byte data) { if(offset >= 0x20) - ByteOut(dumb->ioaddr+0x1400-0x20+offset,data); + ByteOut(dumb->info.ioaddr+0x1400-0x20+offset,data); else - ByteOut(dumb->ioaddr+0x1000+offset,data); /* ?? */ + ByteOut(dumb->info.ioaddr+0x1000+offset,data); /* ?? */ } inline static Byte InHSCX(struct _dumb * dumb, u_char hscx, char offset) { if(hscx&1) { if(offset >= 0x20) - return ByteIn(dumb->ioaddr+0x400-0x20+offset); + return ByteIn(dumb->info.ioaddr+0x400-0x20+offset); else - return ByteIn(dumb->ioaddr+0x000+offset); + return ByteIn(dumb->info.ioaddr+0x000+offset); } else { if(offset >= 0x20) - return ByteIn(dumb->ioaddr+0xC00-0x20+offset); + return ByteIn(dumb->info.ioaddr+0xC00-0x20+offset); else - return ByteIn(dumb->ioaddr+0x800+offset); + return ByteIn(dumb->info.ioaddr+0x800+offset); } } inline static void OutHSCX(struct _dumb * dumb, u_char hscx, char offset, Byte data) { if(hscx&1) { if(offset >= 0x20) - ByteOut(dumb->ioaddr+0x400-0x20+offset, data); + ByteOut(dumb->info.ioaddr+0x400-0x20+offset, data); else - ByteOut(dumb->ioaddr+0x000+offset, data); + ByteOut(dumb->info.ioaddr+0x000+offset, data); } else { if(offset >= 0x20) - ByteOut(dumb->ioaddr+0xC00-0x20+offset, data); + ByteOut(dumb->info.ioaddr+0xC00-0x20+offset, data); else - ByteOut(dumb->ioaddr+0x800+offset, data); + ByteOut(dumb->info.ioaddr+0x800+offset, data); } } @@ -50,25 +50,25 @@ static int Init(struct _dumb * dumb) { Byte foo; unsigned int step = 0; - if(dumb->ioaddr == 0) + if(dumb->info.ioaddr == 0) return -EINVAL; dumb->numHSCX = 2; save_flags(flags); sti(); timout = jiffies+1; - ByteOut(dumb->ioaddr+0x1800,0x00); while(jiffies <= timout) ; timout = jiffies; - ByteOut(dumb->ioaddr+0x1800,0x10); while(jiffies <= timout) ; timout = jiffies; - ByteOut(dumb->ioaddr+0x1800,0x00); while(jiffies <= timout) ; timout = jiffies; + ByteOut(dumb->info.ioaddr+0x1800,0x00); while(jiffies <= timout) ; timout = jiffies; + ByteOut(dumb->info.ioaddr+0x1800,0x10); while(jiffies <= timout) ; timout = jiffies; + ByteOut(dumb->info.ioaddr+0x1800,0x00); while(jiffies <= timout) ; timout = jiffies; - ByteOut(dumb->ioaddr+0x1800,0x00); while(jiffies <= timout) ; timout = jiffies; - ByteOut(dumb->ioaddr+0x1800,0x01); while(jiffies <= timout) ; timout = jiffies; - ByteOut(dumb->ioaddr+0x1800,0x00); while(jiffies <= timout) ; + ByteOut(dumb->info.ioaddr+0x1800,0x00); while(jiffies <= timout) ; timout = jiffies; + ByteOut(dumb->info.ioaddr+0x1800,0x01); while(jiffies <= timout) ; timout = jiffies; + ByteOut(dumb->info.ioaddr+0x1800,0x00); while(jiffies <= timout) ; timout = jiffies+(HZ/20); - ByteOut(dumb->ioaddr+0x1800,0x01); + ByteOut(dumb->info.ioaddr+0x1800,0x01); while(jiffies <= timout) ; - ByteOut(dumb->ioaddr+0x1800,0x00); + ByteOut(dumb->info.ioaddr+0x1800,0x00); timout = jiffies+(HZ/20); while(jiffies <= timout) ; restore_flags(flags); @@ -76,8 +76,8 @@ static int Init(struct _dumb * dumb) { /* 1 2 3 4 5 6 7 8 9 */ /* 17 07 13 03 17 07 13 03 */ while(++step) { - ByteOut(dumb->ioaddr+0x1800,(step&1)?0x10:0x00); - switch((foo = ByteIn(dumb->ioaddr+0x1800)) & 0xFE) { + ByteOut(dumb->info.ioaddr+0x1800,(step&1)?0x10:0x00); + switch((foo = ByteIn(dumb->info.ioaddr+0x1800)) & 0xFE) { case 0x06: if(step & 1) goto def; @@ -114,16 +114,16 @@ static int Init(struct _dumb * dumb) { save_flags(flags); timout = jiffies+(HZ/20)+1; - ByteOut(dumb->ioaddr+0x1800,0x01); + ByteOut(dumb->info.ioaddr+0x1800,0x01); sti(); while(jiffies <= timout) ; - ByteOut(dumb->ioaddr+0x1800,0x00); + ByteOut(dumb->info.ioaddr+0x1800,0x00); timout = jiffies+(HZ/20)+1; while(jiffies <= timout) ; restore_flags(flags); - ByteOut(dumb->ioaddr+0x1800,0x04); - ByteOut(dumb->ioaddr+0x1800,0x08); + ByteOut(dumb->info.ioaddr+0x1800,0x04); + ByteOut(dumb->info.ioaddr+0x1800,0x08); return 0; } @@ -166,7 +166,7 @@ static void InitHSCX_(struct _dumb * dumb, u_char hscx) static void ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[0].m_in != NULL) { freemsg(dumb->chan[0].m_in); @@ -180,7 +180,7 @@ static void ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) switch(mode) { case M_OFF: - printk(KERN_DEBUG "CIX0 0x3F\n"); + printk("%sCIX0 0x3F\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x3F); if(dumb->polled>0) isdn2_new_state(&dumb->card,0); dumb->chan[0].mode = mode; @@ -188,10 +188,10 @@ static void ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) case M_STANDBY: if(dumb->chan[0].mode != M_STANDBY) { ByteOutISAC(dumb,MODE,0xC9); - printk(KERN_DEBUG "CIX0 0x03\n"); + printk("%sCIX0 0x03\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x03); } -else printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); +else printk("%sNoCIX0 %d\n",KERN_DEBUG ,dumb->chan[0].mode); ByteOutISAC(dumb,MASK,0x00); dumb->chan[0].mode = mode; dumb->chan[0].listen = 1; @@ -200,10 +200,10 @@ else printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); ByteOutISAC(dumb,MODE,0xC9); ByteOutISAC(dumb,MASK,0x00); if(dumb->chan[0].mode != M_HDLC) { - printk(KERN_DEBUG "CIX0 0x27\n"); + printk("%sCIX0 0x27\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x27); } else { -printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); +printk("%sNoCIX0 %d\n",KERN_DEBUG ,dumb->chan[0].mode); if(dumb->polled>0) isdn2_new_state(&dumb->card,1); } #if 0 @@ -221,7 +221,7 @@ printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); static int HSCX_mode(struct _dumb * dumb, u_char hscx, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[hscx].m_in != NULL) { freemsg(dumb->chan[hscx].m_in); dumb->chan[hscx].m_in = dumb->chan[hscx].m_in_run = NULL; @@ -301,20 +301,20 @@ static int HSCX_mode(struct _dumb * dumb, u_char hscx, Byte mode, Byte listen) inline static void PostIRQ(struct _dumb * dumb) { - Byte foo = ByteIn(dumb->ioaddr+0x1800); + Byte foo = ByteIn(dumb->info.ioaddr+0x1800); unsigned int doagain=0; do { switch(foo) { case 0x07: return; case 0x03: if(doagain & 1) { - ByteOut(dumb->ioaddr+0x1800,0x00); - ByteOut(dumb->ioaddr+0x1800,0x10); - ByteOut(dumb->ioaddr+0x1800,0x00); + ByteOut(dumb->info.ioaddr+0x1800,0x00); + ByteOut(dumb->info.ioaddr+0x1800,0x10); + ByteOut(dumb->info.ioaddr+0x1800,0x00); } else { - ByteOut(dumb->ioaddr+0x1800,0x04); - ByteOut(dumb->ioaddr+0x1800,0x08); - ByteOut(dumb->ioaddr+0x1800,0x00); + ByteOut(dumb->info.ioaddr+0x1800,0x04); + ByteOut(dumb->info.ioaddr+0x1800,0x08); + ByteOut(dumb->info.ioaddr+0x1800,0x00); } printf("."); if(doagain < 10) diff --git a/cards/dumb/bsc_io.c b/cards/dumb/bsc_io.c index 1f1ec2e..816b30b 100644 --- a/cards/dumb/bsc_io.c +++ b/cards/dumb/bsc_io.c @@ -3,21 +3,21 @@ inline static void PostIRQ(struct _dumb * dumb) } inline static Byte InISAC(struct _dumb * dumb, char offset) { - ByteOut(dumb->ioaddr,offset); - return ByteIn(dumb->ioaddr+1); + ByteOut(dumb->info.ioaddr,offset); + return ByteIn(dumb->info.ioaddr+1); } inline static void OutISAC(struct _dumb * dumb, char offset, Byte data) { - ByteOut(dumb->ioaddr,offset); - ByteOut(dumb->ioaddr+1,data); + ByteOut(dumb->info.ioaddr,offset); + ByteOut(dumb->info.ioaddr+1,data); } inline static Byte InHSCX(struct _dumb * dumb, unsigned char hscx, char offset) { - ByteOut(dumb->ioaddr,offset+((hscx&1)?0:0x40)); - return ByteIn(dumb->ioaddr+2); + ByteOut(dumb->info.ioaddr,offset+((hscx&1)?0:0x40)); + return ByteIn(dumb->info.ioaddr+2); } inline static void OutHSCX(struct _dumb * dumb, unsigned char hscx, char offset, Byte what) { - ByteOut(dumb->ioaddr,offset+((hscx&1)?0:0x40)); - ByteOut(dumb->ioaddr+2,what); + ByteOut(dumb->info.ioaddr,offset+((hscx&1)?0:0x40)); + ByteOut(dumb->info.ioaddr+2,what); } inline static Byte Slot(struct _dumb * dumb, unsigned char hscx) { printf(" Slot %d: ",hscx); @@ -28,15 +28,15 @@ static int Init(struct _dumb * dumb) { int timout; long flags; - if(dumb->ioaddr == 0) + if(dumb->info.ioaddr == 0) return -EINVAL; dumb->numHSCX = 2; save_flags(flags); timout = jiffies+(HZ/20)+1; - ByteOut(dumb->ioaddr,0x80); + ByteOut(dumb->info.ioaddr,0x80); sti(); while(jiffies <= timout) ; - ByteOut(dumb->ioaddr,0x00); + ByteOut(dumb->info.ioaddr,0x00); timout = jiffies+(HZ/20)+1; while(jiffies <= timout) ; restore_flags(flags); @@ -81,7 +81,7 @@ static void InitHSCX_(struct _dumb * dumb, unsigned char hscx) static void ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[0].m_in != NULL) { freemsg(dumb->chan[0].m_in); @@ -95,7 +95,7 @@ static void ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) switch(mode) { case M_OFF: - printk(KERN_DEBUG "CIX0 0x3F\n"); + printk("%sCIX0 0x3F\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x3F); if(dumb->polled>0) isdn2_new_state(&dumb->card,0); dumb->chan[0].mode = mode; @@ -103,10 +103,10 @@ static void ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) case M_STANDBY: if(dumb->chan[0].mode != M_STANDBY) { ByteOutISAC(dumb,MODE,0xCA); - printk(KERN_DEBUG "CIX0 0x03\n"); + printk("%sCIX0 0x03\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x03); } -else printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); +else printk("%sNoCIX0 %d\n",KERN_DEBUG ,dumb->chan[0].mode); ByteOutISAC(dumb,MASK,0x00); dumb->chan[0].mode = mode; dumb->chan[0].listen = 1; @@ -115,10 +115,10 @@ else printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); ByteOutISAC(dumb,MODE,0xCA); ByteOutISAC(dumb,MASK,0x00); if(dumb->chan[0].mode != M_HDLC) { - printk(KERN_DEBUG "CIX0 0x27\n"); + printk("%sCIX0 0x27\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x27); } else { -printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); +printk("%sNoCIX0 %d\n",KERN_DEBUG ,dumb->chan[0].mode); if(dumb->polled>0) isdn2_new_state(&dumb->card,1); } #if 0 @@ -136,7 +136,7 @@ printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); static void HSCX_mode(struct _dumb * dumb, unsigned char hscx, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[hscx].m_in != NULL) { freemsg(dumb->chan[hscx].m_in); dumb->chan[hscx].m_in = dumb->chan[hscx].m_in_run = NULL; diff --git a/cards/dumb/ncp16_io.c b/cards/dumb/ncp16_io.c index 74d3ddd..3a159d8 100644 --- a/cards/dumb/ncp16_io.c +++ b/cards/dumb/ncp16_io.c @@ -3,22 +3,22 @@ inline static void PostIRQ(struct _dumb * dumb) } inline static Byte InISAC(struct _dumb * dumb, char offset) { - ByteOut(dumb->ioaddr+1,offset); - return ByteIn(dumb->ioaddr+2); + ByteOut(dumb->info.ioaddr+1,offset); + return ByteIn(dumb->info.ioaddr+2); } inline static void OutISAC(struct _dumb * dumb, char offset, Byte data) { - ByteOut(dumb->ioaddr+1,offset); - ByteOut(dumb->ioaddr+2,data); + ByteOut(dumb->info.ioaddr+1,offset); + ByteOut(dumb->info.ioaddr+2,data); } inline static Byte InHSCX(struct _dumb * dumb, unsigned char hscx, char offset) { - ByteOut(dumb->ioaddr+1,offset+((hscx&1)?0x80:0xC0)); - return ByteIn(dumb->ioaddr+2); + ByteOut(dumb->info.ioaddr+1,offset+((hscx&1)?0x80:0xC0)); + return ByteIn(dumb->info.ioaddr+2); } inline static void OutHSCX(struct _dumb * dumb, unsigned char hscx, char offset, Byte what) { - ByteOut(dumb->ioaddr+1,offset+((hscx&1)?0x80:0xC0)); - ByteOut(dumb->ioaddr+2,what); + ByteOut(dumb->info.ioaddr+1,offset+((hscx&1)?0x80:0xC0)); + ByteOut(dumb->info.ioaddr+2,what); } inline static Byte Slot(struct _dumb * dumb, unsigned char hscx) { printf(" Slot %d: ",hscx); @@ -30,25 +30,25 @@ static int Init(struct _dumb * dumb) { long flags; char iflag; - if(dumb->ioaddr == 0) + if(dumb->info.ioaddr == 0) return -EINVAL; dumb->numHSCX = 2; save_flags(flags); timout = jiffies+(HZ/20)+1; - ByteOut(dumb->ioaddr,0xF0); + ByteOut(dumb->info.ioaddr,0xF0); sti(); while(jiffies <= timout) ; - ByteOut(dumb->ioaddr,0xE0); + ByteOut(dumb->info.ioaddr,0xE0); timout = jiffies+(HZ/20)+1; while(jiffies <= timout) ; restore_flags(flags); - switch(ByteIn(dumb->ioaddr) & 0xE0) { + switch(ByteIn(dumb->info.ioaddr) & 0xE0) { case 0: break; default: - printf (" unknown card code %d ",ByteIn(dumb->ioaddr) >> 5); + printf (" unknown card code %d ",ByteIn(dumb->info.ioaddr) >> 5); return -ENXIO; } - switch(dumb->irq) { + switch(dumb->info.irq) { case 3: iflag = 0; break; case 5: iflag = 4; break; case 7: iflag = 2; break; @@ -59,10 +59,10 @@ static int Init(struct _dumb * dumb) { case 15:iflag = 3; break; case 0: iflag = 7; break; default: - printf (" impossible irq %d ",dumb->irq); + printf (" impossible irq %d ",dumb->info.irq); return -EINVAL; } - ByteOut(dumb->ioaddr,(iflag<<5)); + ByteOut(dumb->info.ioaddr,(iflag<<5)); return 0; } @@ -108,7 +108,7 @@ static void InitHSCX_(struct _dumb * dumb, unsigned char hscx) static int ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[0].m_in != NULL) { freemsg(dumb->chan[0].m_in); @@ -122,7 +122,7 @@ static int ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) switch(mode) { case M_OFF: - printk(KERN_DEBUG "CIX0 0x3F\n"); + printk("%sCIX0 0x3F\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x3F); if(dumb->polled>0) isdn2_new_state(&dumb->card,0); dumb->chan[0].mode = mode; @@ -130,10 +130,10 @@ static int ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) case M_STANDBY: if(dumb->chan[0].mode != M_STANDBY) { ByteOutISAC(dumb,MODE,0xCA); - printk(KERN_DEBUG "CIX0 0x03\n"); + printk("%sCIX0 0x03\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x03); } -else printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); +else printk("%sNoCIX0 %d\n",KERN_DEBUG ,dumb->chan[0].mode); ByteOutISAC(dumb,MASK,0x00); dumb->chan[0].mode = mode; dumb->chan[0].listen = 1; @@ -142,10 +142,10 @@ else printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); ByteOutISAC(dumb,MODE,0xCA); ByteOutISAC(dumb,MASK,0x00); if(dumb->chan[0].mode != M_HDLC) { - printk(KERN_DEBUG "CIX0 0x27\n"); + printk("%sCIX0 0x27\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x27); } else { -printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); +printk("%sNoCIX0 %d\n",KERN_DEBUG ,dumb->chan[0].mode); if(dumb->polled>0) isdn2_new_state(&dumb->card,1); } #if 0 @@ -166,7 +166,7 @@ printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); static int HSCX_mode(struct _dumb * dumb, unsigned char hscx, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[hscx].m_in != NULL) { freemsg(dumb->chan[hscx].m_in); dumb->chan[hscx].m_in = dumb->chan[hscx].m_in_run = NULL; diff --git a/cards/dumb/ncp_io.c b/cards/dumb/ncp_io.c index 017f051..2d17b86 100644 --- a/cards/dumb/ncp_io.c +++ b/cards/dumb/ncp_io.c @@ -3,21 +3,21 @@ inline static void PostIRQ(struct _dumb * dumb) } inline static Byte InISAC(struct _dumb * dumb, char offset) { - ByteOut(dumb->ioaddr+1,offset); - return ByteIn(dumb->ioaddr+2); + ByteOut(dumb->info.ioaddr+1,offset); + return ByteIn(dumb->info.ioaddr+2); } inline static void OutISAC(struct _dumb * dumb, char offset, Byte data) { - ByteOut(dumb->ioaddr+1,offset); - ByteOut(dumb->ioaddr+2,data); + ByteOut(dumb->info.ioaddr+1,offset); + ByteOut(dumb->info.ioaddr+2,data); } inline static Byte InHSCX(struct _dumb * dumb, unsigned char hscx, char offset) { - ByteOut(dumb->ioaddr+1,offset+((hscx&1)?0x80:0xC0)); - return ByteIn(dumb->ioaddr+2); + ByteOut(dumb->info.ioaddr+1,offset+((hscx&1)?0x80:0xC0)); + return ByteIn(dumb->info.ioaddr+2); } inline static void OutHSCX(struct _dumb * dumb, unsigned char hscx, char offset, Byte what) { - ByteOut(dumb->ioaddr+1,offset+((hscx&1)?0x80:0xC0)); - ByteOut(dumb->ioaddr+2,what); + ByteOut(dumb->info.ioaddr+1,offset+((hscx&1)?0x80:0xC0)); + ByteOut(dumb->info.ioaddr+2,what); } inline static Byte Slot(struct _dumb * dumb, unsigned char hscx) { printf(" Slot %d: ",hscx); @@ -29,25 +29,25 @@ static int Init(struct _dumb * dumb) { long flags; char iflag; - if(dumb->ioaddr == 0) + if(dumb->info.ioaddr == 0) return -EINVAL; dumb->numHSCX = 2; save_flags(flags); timout = jiffies+(HZ/20)+1; - ByteOut(dumb->ioaddr,0xF0); + ByteOut(dumb->info.ioaddr,0xF0); sti(); while(jiffies <= timout) ; - ByteOut(dumb->ioaddr,0xE0); + ByteOut(dumb->info.ioaddr,0xE0); timout = jiffies+(HZ/20)+1; while(jiffies <= timout) ; restore_flags(flags); - switch(ByteIn(dumb->ioaddr) & 0xE0) { + switch(ByteIn(dumb->info.ioaddr) & 0xE0) { case 0: break; default: - printf (" unknown card code %d ",ByteIn(dumb->ioaddr) >> 5); + printf (" unknown card code %d ",ByteIn(dumb->info.ioaddr) >> 5); return -EIO; } - switch(dumb->irq) { + switch(dumb->info.irq) { case 3: iflag = 0; break; case 5: iflag = 4; break; case 7: iflag = 2; break; @@ -57,10 +57,10 @@ static int Init(struct _dumb * dumb) { case 6: iflag = 5; break; case 0: iflag = 7; break; default: - printf (" impossible irq %d ",dumb->irq); + printf (" impossible irq %d ",dumb->info.irq); return -EINVAL; } - ByteOut(dumb->ioaddr,(iflag<<5)); + ByteOut(dumb->info.ioaddr,(iflag<<5)); return 0; } @@ -103,7 +103,7 @@ static void InitHSCX_(struct _dumb * dumb, unsigned char hscx) static int ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[0].m_in != NULL) { freemsg(dumb->chan[0].m_in); @@ -117,7 +117,7 @@ static int ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) switch(mode) { case M_OFF: - printk(KERN_DEBUG "CIX0 0x3F\n"); + printk("%sCIX0 0x3F\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x3F); if(dumb->polled>0) isdn2_new_state(&dumb->card,0); dumb->chan[0].mode = mode; @@ -125,10 +125,10 @@ static int ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) case M_STANDBY: if(dumb->chan[0].mode != M_STANDBY) { ByteOutISAC(dumb,MODE,0xCA); - printk(KERN_DEBUG "CIX0 0x03\n"); + printk("%sCIX0 0x03\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x03); } -else printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); +else printk("%sNoCIX0 %d\n",KERN_DEBUG ,dumb->chan[0].mode); ByteOutISAC(dumb,MASK,0x00); dumb->chan[0].mode = mode; dumb->chan[0].listen = 1; @@ -137,10 +137,10 @@ else printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); ByteOutISAC(dumb,MODE,0xCA); ByteOutISAC(dumb,MASK,0x00); if(dumb->chan[0].mode != M_HDLC) { - printk(KERN_DEBUG "CIX0 0x27\n"); + printk("%sCIX0 0x27\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x27); } else { -printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); +printk("%sNoCIX0 %d\n",KERN_DEBUG ,dumb->chan[0].mode); if(dumb->polled>0) isdn2_new_state(&dumb->card,1); } #if 0 @@ -161,7 +161,7 @@ printk(KERN_DEBUG "NoCIX0 %d\n",dumb->chan[0].mode); static int HSCX_mode(struct _dumb * dumb, unsigned char hscx, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[hscx].m_in != NULL) { freemsg(dumb->chan[hscx].m_in); dumb->chan[hscx].m_in = dumb->chan[hscx].m_in_run = NULL; diff --git a/cards/dumb/shell.c b/cards/dumb/shell.c index e0920c9..0c8d636 100644 --- a/cards/dumb/shell.c +++ b/cards/dumb/shell.c @@ -1,3 +1,7 @@ +#if defined(_ncp16_) +#define WIDE +#endif + /* BSC HSCX @@ -54,16 +58,14 @@ CMDR 41 #endif #include #include +#include "loader.h" -#ifdef M_UNIX -#define ByteOut(_where,_what) iooutb(_where,_what) -#define ByteIn(_where) ioinb(_where) -#endif #ifdef linux #include #include #include #include +#include #define ByteOut(_where,_what) outb_p(_what,_where) #define ByteIn(_where) inb_p(_where) #endif @@ -83,7 +85,7 @@ CMDR 41 #define HSCX_R_FIFO_SIZE 32 #define HSCX_W_FIFO_SIZE 32 -#define FIFO(x) fifo[(x,0)] /* keep side effects but address at offset zero */ +#define FIFO(x) fifo[0] /* forget the address -- WARNING: side effects of x get lost */ #include "shell.h" @@ -174,34 +176,27 @@ typedef struct _hscx { #endif #ifdef linux - #ifdef _avm_ -#define CARDTYPE avm #include "avm_io.c" #endif #ifdef _bsc_ -#define CARDTYPE bsc #include "bsc_io.c" #endif #ifdef _ncp16_ -#define CARDTYPE ncp16 #include "ncp16_io.c" #endif #ifdef _ncp_ -#define CARDTYPE ncp #include "ncp_io.c" #endif #ifdef _teles_ -#define CARDTYPE teles #include "teles_io.c" #endif - #define DUMBTIME 300 /* poll: times per second */ #define xxappxx(a,b) a##b @@ -209,9 +204,9 @@ typedef struct _hscx { #define xxstrxx(a) #a #define STRING(a) xxstrxx(a) /* ditto */ -void NAME(CARDTYPE,poll)(struct _dumb *dumb); +void NAME(REALNAME,poll)(struct _dumb *dumb); #else -void NAME(CARDTYPE,poll)(void *); +void NAME(REALNAME,poll)(void *); #endif @@ -257,7 +252,7 @@ dumb_mode (struct _isdn1_card * card, short channel, char mode, char listen) switch(channel) { case 0: - DEBUG(info) printf(KERN_INFO "ISDN ISAC %s<%d>%s\n",mode?(mode==1?"standby":"up"):"down",mode,listen?" listen":""); + DEBUG(info) printf("%sISDN ISAC %s<%d>%s\n",KERN_INFO ,mode?(mode==1?"standby":"up"):"down",mode,listen?" listen":""); ISAC_mode(dumb,mode,listen); if(mode == M_OFF) { int j; @@ -267,10 +262,10 @@ dumb_mode (struct _isdn1_card * card, short channel, char mode, char listen) break; default: if(channel > 0 && channel <= dumb->numHSCX) { - DEBUG(info) printf(KERN_INFO "ISDN HSCX%d %s<%d>%s\n",channel,mode?"up":"down",mode,listen?" listen":""); + DEBUG(info) printf("%sISDN HSCX%d %s<%d>%s\n",KERN_INFO ,channel,mode?"up":"down",mode,listen?" listen":""); err = HSCX_mode(dumb,channel,mode,listen); if (err < 0) { - printf(KERN_WARNING "ISDN err %d %d\n",channel, err); + printf("%sISDN err %d %d\n",KERN_WARNING ,channel, err); splx(ms); return err; } @@ -279,12 +274,12 @@ dumb_mode (struct _isdn1_card * card, short channel, char mode, char listen) dumb->chan[channel].maxblk = 10; break; } else { - printf(KERN_WARNING "ISDN badChan %d\n",channel); + printf("%sISDN badChan %d\n",KERN_WARNING ,channel); splx(ms); return -EINVAL; } } - NAME(CARDTYPE,poll)(dumb); + NAME(REALNAME,poll)(dumb); splx(ms); return err; } @@ -297,7 +292,7 @@ dumb_prot (struct _isdn1_card * card, short channel, mblk_t * mp, int flags) ushort_t id; int error = 0; - DEBUG(info)printf("Prot chan %d flags 0%o\n",channel,flags); + DEBUG(info)printf("%sProt chan %d flags 0%o\n",KERN_DEBUG,channel,flags); if(!(flags & ~CHP_FROMSTACK)) { if ((error = m_getid (mp, &id)) != 0) @@ -346,7 +341,7 @@ dumb_data (struct _isdn1_card * card, short channel, mblk_t * data) { struct _dumb * dumb = (struct _dumb *)card; S_enqueue(&dumb->chan[channel].q_out, data); - NAME(CARDTYPE,poll)((struct _dumb *) card); + NAME(REALNAME,poll)((struct _dumb *) card); return 0; } @@ -410,7 +405,7 @@ static void ISAC_kick(struct _dumb * dumb) uchar_t *sendp = NULL; unsigned long ms = SetSPL(dumb->ipl); - DEBUG(isac) printf(KERN_DEBUG "K "); + DEBUG(isac) printf("%sK ",KERN_DEBUG ); if(dumb->chan[0].locked) { DEBUG(isac) printf("lck "); splx(ms); @@ -458,8 +453,10 @@ static void ISAC_kick(struct _dumb * dumb) do { short thisb = (uchar_t *)sendb->b_wptr-sendp; if(thisb > ISAC_W_FIFO_SIZE-numb) thisb = ISAC_W_FIFO_SIZE-numb; - for(;thisb > 0; thisb--) - ByteOutISAC(dumb,FIFO(numb++),*sendp++); + for(;thisb > 0; thisb--) { + ByteOutISAC(dumb,FIFO(numb),*sendp); + numb++; sendp++; + } while(sendp >= (uchar_t *)sendb->b_wptr) { sendb = sendb->b_cont; if(sendb != NULL) @@ -496,7 +493,7 @@ static void HSCX_kick(struct _dumb * dumb, u_char hscx) hdlc_buf bufp = &dumb->chan[hscx]; unsigned long ms = SetSPL(dumb->ipl); - DEBUG(hscxout) printf(KERN_DEBUG "K.%d ",hscx); + DEBUG(hscxout) printf("%sK.%d ",KERN_DEBUG ,hscx); if(bufp->locked) { DEBUG(hscxout) { printf("Lck\n"); } splx(ms); @@ -550,7 +547,7 @@ static void HSCX_kick(struct _dumb * dumb, u_char hscx) #ifdef CONFIG_DEBUG_ISDN if(sendp == NULL) { DEBUG(hscxout)printf("\n"); - printf(KERN_WARNING "PNull! %p %p %p %p %p %d\n",sendb,sendp,bufp->m_out,bufp->m_out_run,bufp->p_out,numb); + printf("%sPNull! %p %p %p %p %p %d\n",KERN_WARNING ,sendb,sendp,bufp->m_out,bufp->m_out_run,bufp->p_out,numb); goto exhopp; } #endif @@ -559,8 +556,10 @@ static void HSCX_kick(struct _dumb * dumb, u_char hscx) short thisb = (uchar_t *)sendb->b_wptr-sendp; if(thisb > HSCX_W_FIFO_SIZE-numb) thisb = HSCX_W_FIFO_SIZE-numb; DEBUG(hscxout) printf(">%d ",thisb); - for(;thisb > 0; thisb --) - ByteOutHSCX(dumb,hscx,FIFO(numb++),*sendp++); + for(;thisb > 0; thisb --) { + ByteOutHSCX(dumb,hscx,FIFO(numb),*sendp); + numb++; sendp++; + } while(sendp >= (uchar_t *)sendb->b_wptr) { sendb = sendb->b_cont; DEBUG(hscxout)printf("=%p ",sendb); @@ -578,7 +577,7 @@ static void HSCX_kick(struct _dumb * dumb, u_char hscx) ByteInHSCX(dumb,hscx,EXIR)&0x40 #endif ) { /* XDU */ - DEBUG(info) printf(KERN_DEBUG "Underrun HSCX.%d\n",hscx); + DEBUG(info) printf("%sUnderrun HSCX.%d\n",KERN_DEBUG ,hscx); ByteOutHSCX(dumb,hscx,CMDR,0x01); bufp->m_out_run = bufp->m_out; bufp->p_out = bufp->m_out->b_rptr; @@ -658,9 +657,9 @@ static void IRQ_HSCX_(struct _dumb * dumb, u_char hscx, hdlc_buf bufp = &dumb->chan[hscx]; #ifdef WIDE - DEBUG(hscx) { printf(KERN_DEBUG "%c.%d %02x:%02x\n",(dumb->polled<0)?'X':(dumb->polled>0)?'P':'I',hscx, isr0,isr1); } + DEBUG(hscx) { printf("%s%c.%d %02x:%02x\n",KERN_DEBUG ,(dumb->polled<0)?'X':(dumb->polled>0)?'P':'I',hscx, isr0,isr1); } #else - DEBUG(hscx) { printf(KERN_DEBUG "%c.%d %02x\n",(dumb->polled<0)?'X':(dumb->polled>0)?'P':'I',hscx, Reason); } + DEBUG(hscx) { printf("%s%c.%d %02x\n",KERN_DEBUG ,(dumb->polled<0)?'X':(dumb->polled>0)?'P':'I',hscx, Reason); } if (hasEX) #endif { @@ -675,7 +674,7 @@ static void IRQ_HSCX_(struct _dumb * dumb, u_char hscx, EXIR & 0x80 #endif ) { /* XMR */ - DEBUG(info) { printf(KERN_DEBUG "Msg Repeat HSCX.%d\n",hscx); } + DEBUG(info) { printf("%sMsg Repeat HSCX.%d\n",KERN_DEBUG ,hscx); } CEC(ByteInHSCX(dumb,hscx,STAR) & 0x04); if (ByteInHSCX(dumb,hscx,STAR) & 0x40) { /* XFW */ #ifdef WIDE @@ -700,7 +699,7 @@ static void IRQ_HSCX_(struct _dumb * dumb, u_char hscx, CEC(ByteInHSCX(dumb,hscx,STAR) & 0x04); if (bufp->mode >= M_HDLC) { DEBUG(info) { - printf(KERN_DEBUG "Xmit Underrun HSCX.%d\n",hscx); } + printf("%sXmit Underrun HSCX.%d\n",KERN_DEBUG ,hscx); } #if NEW_XMIT ByteOutHSCX(dumb,hscx,CMDR, 0x01); /* XRES */ #ifdef WIDE @@ -732,27 +731,27 @@ static void IRQ_HSCX_(struct _dumb * dumb, u_char hscx, } #ifdef WIDE DEBUG(hscx)if (isr0 & 0x08) { /* PLLA */ - DEBUG(info) { printf(KERN_WARNING "ISDN .PLLA\n"); } + DEBUG(info) { printf("%sISDN .PLLA\n",KERN_WARNING ); } } DEBUG(hscx)if (isr0 & 0x20) { /* RSC */ - DEBUG(info) { printf(KERN_WARNING "ISDN .RSC\n"); } + DEBUG(info) { printf("%sISDN .RSC\n",KERN_WARNING ); } } DEBUG(hscx)if (isr0 & 0x10) { /* PCE */ - DEBUG(info) { printf(KERN_WARNING "ISDN .PCE\n"); } + DEBUG(info) { printf("%sISDN .PCE\n",KERN_WARNING ); } } DEBUG(hscx)if (isr0 & 0x40) { /* RFS */ - DEBUG(info) { printf(KERN_WARNING "ISDN .RFS\n"); } + DEBUG(info) { printf("%sISDN .RFS\n",KERN_WARNING ); } } #else DEBUG(hscx)if (EXIR & 0x08) { /* CSC */ - DEBUG(info) { printf(KERN_WARNING "ISDN .CSC\n"); } + DEBUG(info) { printf("%sISDN .CSC\n",KERN_WARNING ); } } DEBUG(hscx)if (EXIR & 0x04) { /* RFS */ - DEBUG(info) { printf(KERN_WARNING "ISDN .RFS\n"); } + DEBUG(info) { printf("%sISDN .RFS\n",KERN_WARNING ); } } /* 0x02 and 0x01 are empty */ DEBUG(hscx)if (EXIR & 0x20) { /* PCE */ - DEBUG(info) { printf(KERN_WARNING "ISDN .PCE\n"); } + DEBUG(info) { printf("%sISDN .PCE\n",KERN_WARNING ); } } #endif if ( @@ -762,7 +761,7 @@ static void IRQ_HSCX_(struct _dumb * dumb, u_char hscx, EXIR & 0x10 #endif ) { /* RFO */ - DEBUG(info) { printf(KERN_DEBUG "Recv overflow HSCX.%d\n",hscx); } + DEBUG(info) { printf("%sRecv overflow HSCX.%d\n",KERN_DEBUG ,hscx); } CEC(ByteInHSCX(dumb,hscx,STAR) & 0x04); if( #ifdef WIDE @@ -853,7 +852,7 @@ static void IRQ_HSCX_(struct _dumb * dumb, u_char hscx, } } } else { - DEBUG(info) { printf(KERN_DEBUG "Recv abort (%02x) HSCX.%d\n", RSTA,hscx); } + DEBUG(info) { printf("%sRecv abort (%02x) HSCX.%d\n",KERN_DEBUG , RSTA,hscx); } if(bufp->m_in != NULL) { freemsg(bufp->m_in); bufp->m_in = bufp->m_in_run = NULL; @@ -931,17 +930,17 @@ static void IRQ_HSCX_(struct _dumb * dumb, u_char hscx, } #ifdef WIDE DEBUG(hscx)if (isr1 & 0x08) { /* TIN */ - DEBUG(info) { printf(KERN_WARNING "ISDN .TIN\n"); } + DEBUG(info) { printf("%sISDN .TIN\n",KERN_WARNING ); } } DEBUG(hscx)if (isr1 & 0x20) { /* AOLP */ - DEBUG(info) { printf(KERN_WARNING "ISDN .AOLP\n"); } + DEBUG(info) { printf("%sISDN .AOLP\n",KERN_WARNING ); } } #else DEBUG(hscx)if (Reason & 0x20) { /* RSC */ - DEBUG(info) { printf(KERN_WARNING "ISDN .RSC\n"); } + DEBUG(info) { printf("%sISDN .RSC\n",KERN_WARNING ); } } DEBUG(hscx)if (Reason & 0x08) { /* TIN */ - DEBUG(info) { printf(KERN_WARNING "ISDN .TIN\n"); } + DEBUG(info) { printf("%sISDN .TIN\n",KERN_WARNING ); } } #endif @@ -964,16 +963,16 @@ static void IRQ_ISAC(struct _dumb * dumb) Byte Reason; while((Reason = ByteInISAC(dumb,ISTA))) { - DEBUG(isac) { printf(KERN_DEBUG "%c %02x\n",(dumb->polled<0)?'X':(dumb->polled>0)?'P':'I',Reason); } + DEBUG(isac) { printf("%s%c %02x\n",KERN_DEBUG ,(dumb->polled<0)?'X':(dumb->polled>0)?'P':'I',Reason); } if (Reason & 0x04) { /* CISQ */ Byte CIR = ByteInISAC(dumb,CIR0); if (CIR & 0x80) { /* SQC */ - DEBUG(info) { printf(KERN_WARNING "ISDN .SQC %x\n",ByteInISAC(dumb,SQRR)); } + DEBUG(info) { printf("%sISDN .SQC %x\n",KERN_WARNING ,ByteInISAC(dumb,SQRR)); } } if (CIR & 0x03) { CIR = ((CIR >> 2) & 0x0F); - DEBUG(info) printf(KERN_DEBUG "ISDN CIR %01x",CIR); + DEBUG(info) printf("%sISDN CIR %01x",KERN_DEBUG ,CIR); if (dumb->polled >= 0) { if ((CIR == 0x0C) || (CIR == 0x0D)) { DEBUG(info) printf(" up"); @@ -994,7 +993,7 @@ static void IRQ_ISAC(struct _dumb * dumb) dumb->circ++; } } - DEBUG(info) printf(KERN_DEBUG "\n"); + DEBUG(info) printf("\n"); #if 0 ByteOutISAC(dumb,CMDR,0x41); Reason &=~ 0xC0; @@ -1005,7 +1004,7 @@ static void IRQ_ISAC(struct _dumb * dumb) Byte EXIR = ByteInISAC(dumb,EXIR); DEBUG(isac) { printf(". %x", EXIR); } if (EXIR & 0x80) { /* XMR */ - DEBUG(info) { printf(KERN_DEBUG "MsgRepeat ISAC\n"); } + DEBUG(info) { printf("%sMsgRepeat ISAC\n",KERN_DEBUG ); } CEC(ByteInISAC(dumb,STAR) & 0x04); if (ByteInISAC(dumb,STAR) & 0x40) { /* XFW */ Reason |= 0x10; /* also set XPR bit */ @@ -1019,7 +1018,7 @@ static void IRQ_ISAC(struct _dumb * dumb) if (EXIR & 0x40) { /* XDU */ CEC(ByteInISAC(dumb,STAR) & 0x04); if (dumb->chan[0].mode >= M_HDLC) { - DEBUG(info) { printf(KERN_DEBUG "Xmit Underrun ISAC\n"); } + DEBUG(info) { printf("%sXmit Underrun ISAC\n",KERN_DEBUG ); } #if NEW_XMIT ByteOutISAC(dumb,CMDR, 0x01); /* XRES */ Reason |= 0x10; @@ -1038,10 +1037,10 @@ static void IRQ_ISAC(struct _dumb * dumb) } } DEBUG(isac)if (EXIR & 0x20) { /* PCE */ - DEBUG(info) { printf(KERN_WARNING "ISDN .PCE\n"); } + DEBUG(info) { printf("%sISDN .PCE\n",KERN_WARNING ); } } if (EXIR & 0x10) { /* RFO */ - DEBUG(info) { printf(KERN_DEBUG "Recv overflow ISAC (%02x)\n", EXIR); } + DEBUG(info) { printf("%sRecv overflow ISAC (%02x)\n",KERN_DEBUG , EXIR); } CEC(ByteInISAC(dumb,STAR) & 0x04); if(Reason & 0xC0) { ByteOutISAC(dumb,CMDR, 0xC0); /* RMC|RHR */ @@ -1054,10 +1053,10 @@ static void IRQ_ISAC(struct _dumb * dumb) } } DEBUG(isac)if (EXIR & 0x08) { /* CSC */ - DEBUG(info) { printf(KERN_WARNING "ISDN .CSC\n"); } + DEBUG(info) { printf("%sISDN .CSC\n",KERN_WARNING ); } } DEBUG(isac)if (EXIR & 0x04) { /* RFS */ - DEBUG(info) { printf(KERN_WARNING "ISDN .RFS\n"); } + DEBUG(info) { printf("%sISDN .RFS\n",KERN_WARNING ); } } /* 0x02 and 0x01 are empty */ } @@ -1073,7 +1072,7 @@ static void IRQ_ISAC(struct _dumb * dumb) blen = (xblen & (ISAC_R_FIFO_SIZE-1)); xblen += (ByteInISAC(dumb,RBCH) & 0x0F) << 8; if(blen == 1) { - DEBUG(isac) printf(KERN_DEBUG ".R-%d\n",xblen); + DEBUG(isac) printf("%s.R-%d\n",KERN_DEBUG ,xblen); if((recvb = dumb->chan[0].m_in_run) != NULL) { mblk_t *msg = dumb->chan[0].m_in; dumb->chan[0].m_in = dumb->chan[0].m_in_run = NULL; @@ -1086,7 +1085,7 @@ static void IRQ_ISAC(struct _dumb * dumb) } else { if(blen == 0) blen = ISAC_R_FIFO_SIZE; - DEBUG(isac) printf(KERN_DEBUG ".R=%d\n",xblen); + DEBUG(isac) printf("%s.R=%d\n",KERN_DEBUG ,xblen); if ((recvb = dumb->chan[0].m_in_run) != NULL) { DEBUG(isac)printf("a%d ",dsize(dumb->chan[0].m_in)); if ((recvp = (uchar_t *)recvb->b_wptr) + blen > (uchar_t *)DATA_END(recvb)) @@ -1125,7 +1124,7 @@ static void IRQ_ISAC(struct _dumb * dumb) } } } else { - DEBUG(info) { printf(KERN_DEBUG "Recv abort (%x)\n",RSTA); } + DEBUG(info) { printf("%sRecv abort (%x)\n",KERN_DEBUG ,RSTA); } if(dumb->chan[0].m_in != NULL) { freemsg(dumb->chan[0].m_in); dumb->chan[0].m_in = dumb->chan[0].m_in_run = NULL; @@ -1174,10 +1173,10 @@ static void IRQ_ISAC(struct _dumb * dumb) } } if (Reason & 0x20) { /* RSC */ - DEBUG(info) { printf(KERN_WARNING "ISDN .RSC\n"); } + DEBUG(info) { printf("%sISDN .RSC\n",KERN_WARNING ); } } if (Reason & 0x08) { /* TIN */ - DEBUG(info) { printf(KERN_WARNING "ISDN .TIN\n"); } + DEBUG(info) { printf("%sISDN .TIN\n",KERN_WARNING ); } #if 0 ByteOutISAC(dumb,TIMR,0x11); ByteOutISAC(dumb,CMDR,0x10); /* start timer */ @@ -1227,7 +1226,7 @@ dumbintr(int irq, struct pt_regs *regs) { struct _dumb *dumb; for(dumb=dumbmap[irq];dumb != NULL;dumb = dumb->next) { - if(dumb->irq == irq) { + if(dumb->info.irq == irq) { dumb->polled --; IRQ_HSCX(dumb); IRQ_ISAC(dumb); @@ -1237,7 +1236,7 @@ dumbintr(int irq, struct pt_regs *regs) } } for(dumb=dumbmap[irq];dumb != NULL;dumb = dumb->next) { - if(dumb->irq == irq) { + if(dumb->info.irq == irq) { toggle_on(dumb); } } @@ -1245,9 +1244,9 @@ dumbintr(int irq, struct pt_regs *regs) #ifdef linux -void NAME(CARDTYPE,poll)(struct _dumb *dumb) +void NAME(REALNAME,poll)(struct _dumb *dumb) #else -void NAME(CARDTYPE,poll)(void *nix) +void NAME(REALNAME,poll)(void *nix) #endif { #ifndef linux @@ -1274,8 +1273,8 @@ void NAME(CARDTYPE,poll)(void *nix) toggle_on(dumb); splx(ms); #if 0 /* def linux */ - if(dumb->irq != 0) - unblock_irq(dumb->irq); + if(dumb->info.irq != 0) + unblock_irq(dumb->info.irq); #endif } } @@ -1284,24 +1283,34 @@ void NAME(CARDTYPE,poll)(void *nix) #ifdef linux static void dumbtimer(struct _dumb *dumb) { - NAME(CARDTYPE,poll)(dumb); + NAME(REALNAME,poll)(dumb); #if 0 if(dumb->countme++ < 10) { - printf(" -(%d):%02x %02x %02x- ",dumb->irq,ByteInISAC(dumb,STAR),ByteInISAC(dumb,ISTA),ByteInISAC(dumb,CIR0)); + printf(" -(%d):%02x %02x %02x- ",dumb->info.irq,ByteInISAC(dumb,STAR),ByteInISAC(dumb,ISTA),ByteInISAC(dumb,CIR0)); } #endif #ifdef NEW_TIMEOUT dumb->timer = #endif - timeout((void *)dumbtimer,dumb,(dumb->irq == 0) ? HZ/DUMBTIME+1 : HZ/2); + timeout((void *)dumbtimer,dumb,(dumb->info.irq == 0) ? HZ/DUMBTIME+1 : HZ/2); } #endif -int NAME(CARDTYPE,init)(struct _dumb *dumb) +int NAME(REALNAME,init)(struct cardinfo *inf) { - extern caddr_t sptalloc(); int err; + struct _dumb *dumb; + dumb = kmalloc(sizeof(*dumb),GFP_KERNEL); + if(dumb == NULL) { + printf("???: No Memory\n"); + return -ENOMEM; + } + bzero(dumb,sizeof(*dumb)); + + dumb->numHSCX = 1; + dumb->info = *inf; + dumb->infoptr = inf; dumb->card.ctl = dumb; dumb->card.modes = (1<card.ch_mode = dumb_mode; @@ -1312,12 +1321,13 @@ int NAME(CARDTYPE,init)(struct _dumb *dumb) dumb->card.poll = NULL; dumb->polled = -1; - printf("ISDN: " STRING(CARDTYPE) " at mem %lx io 0x%x irq %d: ",dumb->memaddr,dumb->ioaddr,dumb->irq); + printf("%sISDN: " STRING(REALNAME) " at mem 0x%lx io 0x%x irq %d: ",KERN_DEBUG, dumb->info.memaddr,dumb->info.ioaddr,dumb->info.irq); if((err = Init(dumb)) < 0) { printf("Card not initializable.\n"); if(err == 0) err = -EIO; + kfree(dumb); return err; } dumb->card.nr_chans = dumb->numHSCX; @@ -1328,60 +1338,67 @@ int NAME(CARDTYPE,init)(struct _dumb *dumb) if((err = ISACpresent(dumb)) < 0) { printf("Card not responding.\n"); + kfree(dumb); return err; } -#ifndef M_UNIX #ifdef linux - if((dumb->irq != 0) && request_irq(dumb->irq,dumbintr,SA_INTERRUPT,"ISDN")) { + if((dumb->info.irq != 0) && (dumbmap[dumb->info.irq] == NULL) && request_irq(dumb->info.irq,dumbintr,SA_INTERRUPT,"ISDN")) { printf("IRQ not available.\n"); + kfree(dumb); return -EEXIST; } #endif - NAME(CARDTYPE,poll)(dumb); - if((err = isdn2_register(&dumb->card, dumb->ID)) != 0) { + NAME(REALNAME,poll)(dumb); + if((err = isdn2_register(&dumb->card, dumb->info.ID)) != 0) { printf("not installed (ISDN_2), err %d\n",err); + kfree(dumb); return err; } dumb->polled = 1; #ifdef linux - if(dumb->irq == 0) { + if(dumb->info.irq == 0) { printf("polling; "); } #endif printf("installed at "); - if(dumb->memaddr != 0) - printf("mem 0x%lx ",dumb->memaddr); - if(dumb->ioaddr != 0) - printf("io 0x%x ",dumb->ioaddr); - if(dumb->irq != 0) - printf("irq %d.\n",dumb->irq); + if(dumb->info.memaddr != 0) + printf("mem 0x%lx ",dumb->info.memaddr); + if(dumb->info.ioaddr != 0) + printf("io 0x%x ",dumb->info.ioaddr); + if(dumb->info.irq != 0) + printf("irq %d.\n",dumb->info.irq); else printf("polled.\n"); - dumb->next = dumbmap[dumb->irq]; - dumbmap[dumb->irq] = dumb; + dumb->next = dumbmap[dumb->info.irq]; + dumbmap[dumb->info.irq] = dumb; #ifdef linux dumbtimer(dumb); #endif -#endif /* M_UNIX */ - MOD_INC_USE_COUNT; + MORE_USE; return 0; } void -NAME(CARDTYPE,exit)(struct _dumb *dumb) +NAME(REALNAME,exit)(struct cardinfo *inf) { int j; - unsigned long ms = SetSPL(dumb->ipl); - struct _dumb **ndumb = &dumbmap[dumb->irq]; + unsigned long ms = SetSPL(inf->ipl); + struct _dumb *dumb = NULL; + struct _dumb **ndumb = &dumbmap[inf->irq]; while(*ndumb != NULL) { - if(*ndumb == dumb) { + if((*ndumb)->infoptr == inf) { + dumb = *ndumb; *ndumb = dumb->next; break; } ndumb = &((*ndumb)->next); } + if(dumb == NULL) { + printf("%s??? No entry\n",KERN_DEBUG); + return; + } #ifdef NEW_TIMEOUT untimeout(dumb->timer); #else @@ -1396,11 +1413,12 @@ NAME(CARDTYPE,exit)(struct _dumb *dumb) ByteOutHSCX(dumb,j,MASK,0xFF); #endif } - if(dumb->irq > 0) - free_irq(dumb->irq); + if((dumb->info.irq > 0) && (dumbmap[dumb->info.irq] == NULL)) + free_irq(dumb->info.irq); isdn2_unregister(&dumb->card); splx(ms); - MOD_DEC_USE_COUNT; + kfree(dumb); + LESS_USE; } diff --git a/cards/dumb/shell.h b/cards/dumb/shell.h index 294aa8f..3cf9a48 100644 --- a/cards/dumb/shell.h +++ b/cards/dumb/shell.h @@ -4,10 +4,11 @@ #include "isdn_12.h" #include "smallq.h" #include +#include "loader.h" extern int dumb_num; -#define DEBUG(_x) if((DEBUG_##_x) & dumb->debug) +#define DEBUG(_x) if((DEBUG_##_x) & dumb->info.debug) #define DEBUG_memory 0x01 #define DEBUG_uart 0x00 #define DEBUG_isac 0x04 @@ -32,18 +33,14 @@ typedef struct _hdlc_buf { typedef struct _dumb { struct _isdn1_card card; /* must be first */ - - long memaddr; - short ioaddr; - unsigned char irq, ipl, numHSCX; - unsigned long ID; - unsigned int debug; + struct cardinfo info, *infoptr; struct _hdlc_buf chan[MAX_B+1]; #ifdef NEW_TIMEOUT long timer; #endif struct _dumb *next; + int numHSCX; long countme; signed char polled; char circ; } *__dumb; diff --git a/cards/dumb/teles_io.c b/cards/dumb/teles_io.c index 0c5b008..b41ab2d 100644 --- a/cards/dumb/teles_io.c +++ b/cards/dumb/teles_io.c @@ -3,17 +3,17 @@ inline static void PostIRQ(struct _dumb * dumb) } static inline Byte InISAC(struct _dumb * dumb, u_char offset) { - return *(Byte *)(dumb->memaddr+0x100+((offset&1)?0x1FF:0)+offset); + return *(Byte *)(dumb->info.memaddr+0x100+((offset&1)?0x1FF:0)+offset); } static inline void OutISAC(struct _dumb * dumb, u_char offset, Byte data) { - *(Byte *)(dumb->memaddr+0x100+((offset&1)?0x1FF:0)+offset) = data; + *(Byte *)(dumb->info.memaddr+0x100+((offset&1)?0x1FF:0)+offset) = data; } static inline Byte InHSCX(struct _dumb * dumb, u_char hscx, u_char offset) { - return *(Byte *)(dumb->memaddr+0x180+((offset&1)?0x1FF:0)+((hscx&1)?0:0x40)+offset); + return *(Byte *)(dumb->info.memaddr+0x180+((offset&1)?0x1FF:0)+((hscx&1)?0:0x40)+offset); } static inline void OutHSCX(struct _dumb * dumb, u_char hscx, u_char offset, Byte data) { - *(Byte *)(dumb->memaddr+0x180+((offset&1)?0x1FF:0)+((hscx&1)?0:0x40)+offset) = data; + *(Byte *)(dumb->info.memaddr+0x180+((offset&1)?0x1FF:0)+((hscx&1)?0:0x40)+offset) = data; } static inline Byte Slot(struct _dumb * dumb, u_char hscx) { return (hscx&1) ? 0x03 : 0x03; /* was 3 / 7 */ @@ -24,22 +24,22 @@ Init(struct _dumb * dumb) { int timout; long flags; - if(dumb->memaddr == 0) + if(dumb->info.memaddr == 0) return -EINVAL; dumb->numHSCX = 2; save_flags(flags); - if(dumb->ipl) { + if(dumb->info.ipl) { int ioaddr; Byte cfval; - switch(dumb->ipl) { - default: printk("ipl %d unknown: ",dumb->ipl); return 0; + switch(dumb->info.ipl) { + default: printk("ipl %d unknown: ",dumb->info.ipl); return 0; case 1: ioaddr = 0xd80; break; case 2: ioaddr = 0xe80; break; case 3: ioaddr = 0xf80; break; case 4: ioaddr = 0xc80; break; /* may cause conflicts (motherboard range) */ } - switch(dumb->irq) { - default: printk("irq %d not possible: ",dumb->irq); return -EINVAL; + switch(dumb->info.irq) { + default: printk("irq %d not possible: ",dumb->info.irq); return -EINVAL; case 2: cfval = 0x00; break; case 3: cfval = 0x02; break; case 4: cfval = 0x04; break; @@ -49,9 +49,9 @@ Init(struct _dumb * dumb) { case 12: cfval = 0x0C; break; case 15: cfval = 0x0E; break; } - if(dumb->memaddr & ~0xDE000) { printk("memaddr %lx not possible: ",dumb->memaddr); return 0; } - if(~dumb->memaddr & 0xC0000) { printk("memaddr %lx not possible: ",dumb->memaddr); return 0; } - cfval |= ((dumb->memaddr >> 9) & 0xF0); + if(dumb->info.memaddr & ~0xDE000) { printk("info.memaddr %lx not possible: ",dumb->info.memaddr); return 0; } + if(~dumb->info.memaddr & 0xC0000) { printk("info.memaddr %lx not possible: ",dumb->info.memaddr); return 0; } + cfval |= ((dumb->info.memaddr >> 9) & 0xF0); if(ByteIn(ioaddr+0) != 0x51) { return 0; } if(ByteIn(ioaddr+1) != 0x93) { return 0; } if(ByteIn(ioaddr+2) != 0x1E) { return 0; } @@ -66,10 +66,10 @@ Init(struct _dumb * dumb) { restore_flags(flags); } timout = jiffies+(HZ/5)+1; - *(Byte *)(dumb->memaddr + 0x80) = 0; + *(Byte *)(dumb->info.memaddr + 0x80) = 0; sti(); while(jiffies <= timout) ; - *(Byte *)(dumb->memaddr + 0x80) = 1; + *(Byte *)(dumb->info.memaddr + 0x80) = 1; timout = jiffies+(HZ/5)+1; while(jiffies <= timout) ; restore_flags(flags); @@ -79,7 +79,7 @@ Init(struct _dumb * dumb) { static void ISAC_mode(struct _dumb * dumb, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); static Byte xmode = 0xFF; if(dumb->chan[0].m_in != NULL) { @@ -94,7 +94,7 @@ static Byte xmode = 0xFF; switch(mode) { case M_OFF: - DEBUG(info) printk(KERN_DEBUG "ISDN CIX0 0x3Fn\n"); + DEBUG(info) printk("%sISDN CIX0 0x3Fn\n",KERN_DEBUG ); if(xmode != mode) ByteOutISAC(dumb,CIX0,0x3F &3); if(dumb->polled>0) isdn2_new_state(&dumb->card,0); @@ -103,7 +103,7 @@ static Byte xmode = 0xFF; case M_STANDBY: if(dumb->chan[0].mode != M_STANDBY) { ByteOutISAC(dumb,MODE,0xC9); - DEBUG(info) printk(KERN_DEBUG "ISDN CIX0 0x03\n"); + DEBUG(info) printk("%sISDN CIX0 0x03\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x03); } ByteOutISAC(dumb,MASK,0x00); @@ -114,11 +114,11 @@ static Byte xmode = 0xFF; ByteOutISAC(dumb,MODE,0xC9); ByteOutISAC(dumb,MASK,0x00); if(dumb->chan[0].mode != M_HDLC) { - DEBUG(info) printk(KERN_DEBUG "ISDN CIX0 0x27\n"); + DEBUG(info) printk("%sISDN CIX0 0x27\n",KERN_DEBUG ); ByteOutISAC(dumb,CIX0,0x27); } else { if(dumb->polled>0) isdn2_new_state(&dumb->card,1); - DEBUG(info) printk(KERN_DEBUG "ISDN noCIX0 0x27\n"); + DEBUG(info) printk("%sISDN noCIX0 0x27\n",KERN_DEBUG ); } #if 0 ByteOutISAC(dumb,TIMR,0x11); @@ -128,7 +128,7 @@ static Byte xmode = 0xFF; dumb->chan[0].listen = 0; break; default: - printf("ISAC unknown mode %x\n",mode); + printf("%sISAC unknown mode %x\n",KERN_DEBUG,mode); } splx(ms); xmode = mode; @@ -137,7 +137,7 @@ static Byte xmode = 0xFF; static int HSCX_mode(struct _dumb * dumb, u_char hscx, Byte mode, Byte listen) { - unsigned long ms = SetSPL(dumb->ipl); + unsigned long ms = SetSPL(dumb->info.ipl); if(dumb->chan[hscx].m_in != NULL) { freemsg(dumb->chan[hscx].m_in); dumb->chan[hscx].m_in = dumb->chan[hscx].m_in_run = NULL; @@ -209,7 +209,7 @@ HSCX_mode(struct _dumb * dumb, u_char hscx, Byte mode, Byte listen) dumb->chan[hscx].listen = listen; break; default: - printf("HSCX unknown mode %x\n",mode); + printf("%sHSCX unknown mode %x\n",KERN_DEBUG,mode); } splx(ms); diff --git a/cards/dumb/insert.c b/cards/loader.c similarity index 59% rename from cards/dumb/insert.c rename to cards/loader.c index c8358c9..ce96171 100644 --- a/cards/dumb/insert.c +++ b/cards/loader.c @@ -1,12 +1,8 @@ #include "f_module.h" #include "isdn_limits.h" #include - -#ifdef linux #include -#endif - -#include "shell.h" +#include "loader.h" #ifndef CARDTYPE #error "You have to define CARDTYPE for this to work." @@ -17,10 +13,10 @@ #define xxstrxx(a) #a #define STRING(a) xxstrxx(a) /* ditto */ -extern int NAME(CARDTYPE,init)(struct _dumb *dumb); -extern void NAME(CARDTYPE,exit)(struct _dumb *dumb); +extern int NAME(CARDTYPE,init)(struct cardinfo *inf); +extern void NAME(CARDTYPE,exit)(struct cardinfo *inf); -struct _dumb dumb; +struct cardinfo inf; int irq = 0; int mem = 0; @@ -33,21 +29,21 @@ int debug = 0; static int do_init_module(void) { if(name == 0) { - printf("You must name this card: insmod xxx.o name=$(name Foo0)\n"); + printf("You must name this card: insmod xxx.o name=$(cardname Foo0)\n"); return -EINVAL; } - dumb.irq = irq; - dumb.ipl = ipl; - dumb.ioaddr = io; - dumb.memaddr = mem; - dumb.ID = name; - dumb.debug = debug; - return NAME(CARDTYPE,init)(&dumb); + inf.irq = irq; + inf.ipl = ipl; + inf.ioaddr = io; + inf.memaddr = mem; + inf.ID = name; + inf.debug = debug; + return NAME(CARDTYPE,init)(&inf); } static int do_exit_module(void) { - NAME(CARDTYPE,exit)(&dumb); + NAME(CARDTYPE,exit)(&inf); return 0; } #else diff --git a/cards/test/Config.c b/cards/test/Config.c deleted file mode 100644 index 05f776f..0000000 --- a/cards/test/Config.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "Config.h" -#include "primitives.h" - -#if 0 -struct _dumb { - struct _isdn1_card card; - long memaddr; - short ioaddr; - char irq, ipl; - /* Linux: IRQ wird nicht automatisch erkannt bei ladbaren Treibern! */ - /* IPL ist 0 für Teles/8-Karten, 1..3 für Teles/16-Karten an der 1..3. - Adresse. */ - char numHCRX; - long ID; - int debug; - struct _hdlc_buf chan[MAX_B_CHAN+1]; -}; -#endif - -struct _dumb dumbdata[] = { -#ifdef _avm_ - { { }, 0,0x300, 3, 0,2, CHAR4('A','V','M','0'), - DEBUG_isac|DEBUG_hscx|DEBUG_hscxout|DEBUG_info, }, -#endif -#ifdef _ncp_ - { { }, 0,0x350, 5, 0,2, CHAR4('n','c','p','0'), - DEBUG_hscx|DEBUG_hscxout|DEBUG_info, }, - { { }, 0,0x250, 7, 0,2, CHAR4('n','c','p','1'), - DEBUG_hscx|DEBUG_hscxout|DEBUG_info, }, -#endif -#ifdef _bsc_ - { { }, 0,0x3E0, 5, 5,2, CHAR4('B','S','C','0'), - DEBUG_isac|DEBUG_hscx|DEBUG_hscxout|DEBUG_info, }, -#endif -#ifdef _teles_ - { { }, 0xD4000,0,12, 1,2, CHAR4('T','e','l','0'), - DEBUG_info| 0, }, - { { }, 0xD5000,0, 3, 0,2, CHAR4('T','e','l','1'), - DEBUG_info| 0, }, - { { }, 0xD6000,0, 5, 0,2, CHAR4('T','e','l','2'), - DEBUG_info| 0, }, - { { }, 0xD7000,0, 4, 0,2, CHAR4('T','e','l','3'), - DEBUG_info| 0, }, -#endif -}; - -int dumb_num = sizeof(dumbdata)/sizeof(dumbdata[0]); - diff --git a/cards/test/Config.h b/cards/test/Config.h deleted file mode 100644 index 0a9ed6a..0000000 --- a/cards/test/Config.h +++ /dev/null @@ -1,48 +0,0 @@ -#include "isdn_limits.h" -#include "isdn_12.h" -#include "smallq.h" -#include - -extern int dumb_num; - -#define DEBUG(_x) if((DEBUG_##_x) & dumb->debug) -#define DEBUG_memory 0x01 -#define DEBUG_uart 0x00 -#define DEBUG_isac 0x04 -#define DEBUG_hscx 0x08 -#define DEBUG_hscxout 0x02 -#define DEBUG_cpu 0x00 -#define DEBUG_check 0x20 -#define DEBUG_info 0x40 -#define DEBUG_main 0x80 - -typedef unsigned char Byte; -typedef struct _hdlc_buf { - mblk_t *m_in, *m_in_run; - unsigned short inlen; - struct _smallq q_out; - mblk_t *m_out, *m_out_run; - unsigned char *p_out; - Byte mode; - Byte locked,listen; - u_short nblk,maxblk; -} *hdlc_buf; - -typedef struct _dumb { - struct _isdn1_card card; - - long memaddr; - short ioaddr; - char irq, ipl, numHSCX; - long ID; - int debug; - - struct _hdlc_buf chan[MAX_B+1]; -#ifdef NEW_TIMEOUT - long timer; -#endif - long countme; signed char polled; char circ; -} *__dumb; - -extern struct _dumb dumbdata[]; - diff --git a/cards/test/Makefile b/cards/test/Makefile deleted file mode 100644 index 76e1b6a..0000000 --- a/cards/test/Makefile +++ /dev/null @@ -1,51 +0,0 @@ - -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = - -## =()@>()= -CC = gcc -## =()@ @@ -I../../include >()= -DEFS = -I../../streams -I../../compat -fomit-frame-pointer -funroll-loops -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux - -SOURCES = test.c - -OBJ = -ALL = test.o - -all: test.o - -load: - insmod test.o - -test.o: test.c - $(CC) $(CFLAGS) -o test.o -c test.c - -lib: - -indent: - ../../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) test.c > .depend ; done - -clean: - rm -f $(OBJ) $(ALL) - -install: all - @sh ../../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif - diff --git a/cards/test/test.c b/cards/test/test.c deleted file mode 100644 index dd16e70..0000000 --- a/cards/test/test.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Testing driver which registers a device for loopback, and so on. - * - */ - -#define UAREA - -#include "f_module.h" -#include "primitives.h" -#include -#include "f_signal.h" -#include "f_malloc.h" -#include -#include "streams.h" -#include -/* #ifdef DONT_ADDERROR */ -#include "f_user.h" -/* #endif */ -#include -#include -#include -#include -#include "streamlib.h" -#include "lap.h" -#include - -#include -#include -#include -#include -#include - -extern void log_printmsg (void *log, const char *text, mblk_t * mp, const char*); -extern void logh_printmsg (void *log, const char *text, mblk_t * mp); - -#define ddprintf(xx) printf(xx),({int x;for(x=0;x<1000;x++) udelay(1000);}) -#define ldprintf if(0)printf -#if 1 -#if 1 -#define dprintf printf -#else -#define dprintf ({int x;for(x=0;x<300;x++) udelay(1000);}),printf -#endif -#else -#define dprintf if(0)printf -#endif - -/* - * Standard Streams driver information. - */ -static struct module_info itest_minfo = -{ - 0, "itest", 0, INFPSZ, 8000, 3000 -}; - -static qf_open itest_open; -static qf_close itest_close; -static qf_srv itest_wsrv, itest_rsrv; -static qf_put itest_wput; - -static struct qinit itest_rinit = -{ - NULL, NULL, itest_open, itest_close, NULL, &itest_minfo, NULL -}; - -static struct qinit itest_winit = -{ - itest_wput, itest_wsrv, NULL, NULL, NULL, &itest_minfo, NULL -}; - -struct streamtab itest_info = -{&itest_rinit, &itest_winit, NULL, NULL}; - -#define NCARDS 2 -#define NBCHAN 3 - -struct testcard { - struct _isdn1_card *card; - struct testchannel { - struct testcard *card; - queue_t *q; - } port[NBCHAN+1]; -} test_card[NCARDS]; - - -static int test_poll (struct _isdn1_card * card, short channel) -{ - struct testcard *test_card = (struct testcad *)card; - struct testchannel *testport; - - if(channel < 0 || channel >= NBCHAN) - return -EIO; - testport = &testcard.port[channel]; - if(testport->q == NULL) - return -ENXIO; - if(WR(testport->q)->q_first == NULL) - return -EAGAIN; - qenable(WR(testport->q)); - return 0; -} - -static int test_candata (struct _isdn1_card * card, short channel) -{ - struct testcard *test_card = (struct testcad *)card; - struct testchannel *testport; - - if(channel < 0 || channel >= NBCHAN) - return 0; - testport = &testcard.port[channel]; - if(testport->q == NULL) - return 0; - return canput(testport->q->q_next); -} - -static int test_data (struct _isdn1_card * card, short channel, mblk_t * data) -{ - struct testcard *test_card = (struct testcad *)card; - struct testchannel *testport; - - if(channel < 0 || channel >= NBCHAN) - return -EIO; - testport = &testcard.port[channel]; - if(testport->q == NULL) - return -ENXIO; - if(!canput(testport->q->q_next)) - return -EAGAIN; - putnext(testport->q,data); -} - -data -candata - -static int test_flush (struct _isdn1_card * card, short channel) -{ - struct testcard *test_card = (struct testcad *)card; - struct testchannel *testport; - - if(channel < 0 || channel >= NBCHAN) - return -EIO; - testport = &testcard.port[channel]; - if(testport->q == NULL) - return -ENXIO; - putctlx1(testport->q,M_FLUSH,FLUSHR|FLUSHW); -} - -static int test_prot (struct _isdn1_card * card, short channel, mblk_t * proto) -{ - return EINVAL; -} - -static int test_mode (struct _isdn1_card * card, short channel, char mode, - char listen) -{ - struct testcard *test_card = (struct testcad *)card; - struct testchannel *testport; - - if(channel < 0 || channel >= NBCHAN) - return -EIO; - testport = &testcard.port[channel]; - if(testport->q == NULL) - return -ENXIO; - if(mode == MODE_OFF) - putctlx1(testport->q,M_HANGUP); -} - - -/* Streams code to open the driver. */ -static int -itest_open (queue_t * q, dev_t dev, int flag, int sflag -#ifdef DO_ADDERROR - ,int *err -#define U_ERROR *err -#else -#define U_ERROR u.u_error -#endif -) -{ - struct testcard *test_card; - struct testchannel *testport; - int mdev = 0; - int cdev; - int err; - - dev = minor (dev); - cdev = dev & 0x0F; - mdev = cdev / (NBCHAN+1); - cdev %= (NBCHAN+1); - - if(mdev >= NCARDS) { - U_ERROR = ENXIO; - return OPENFAIL; - } - testcard = test_card[mdev]; - testport = &testcard->port[cdev]; - if(testport->q != NULL) { - printf("itest dev 0x%x: already open, %p\n",dev,testport->q); - return 0; - } - - MORE_USE; - - if(cdev == 0) { - int theID = CHAR4('T','s','t','A'+mdev); - - testcard->card.nr_chans = NBCHAN; - testcard->card.ctl = testcard; - testcard->card.chan = NULL; - testcard->card.modes = (1<card.ch_mode = test_mode; - testcard->card.ch_prot = test_prot; - testcard->card.send = test_data; - testcard->card.flush = test_flush; - testcard->card.cansend = test_candata; - testcard->card.poll = test_poll; - - if((err = isdn2_register(&testcard->card, theID)) != 0) { - U_ERROR = err; - LESS_USE; - return OPENFAIL; - } - } - - testport->card = testcard; - testport->q = q; - - WR (q)->q_ptr = (caddr_t) testport; - q->q_ptr = (caddr_t) testport; - - return dev; -} - -/* Streams code to close the driver. */ -static void -itest_close (queue_t *q, int dummy) -{ - struct testchannel *testport = (struct testchannel *) q->q_ptr; - struct testcard *test_card = testport->card; - - if(testport->q == NULL) - return; - if(testport == &testcard->port[0]) - isdn2_unregister(&testcard->card); - - testport->q = NULL; - - LESS_USE; - return; -} - - -/* Streams code to write data. */ -static void -itest_wput (queue_t *q, mblk_t *mp) -{ - struct testchannel *testport = (struct testchannel *) q->q_ptr; - struct testcard *test_card = testport->card; -ldprintf(".%d.",__LINE__); - -#ifdef CONFIG_DEBUG_STREAMS - if(msgdsize(mp) < 0) - return; -#endif - if(testport->q == NULL) { - freemsg(mp); - return; - } - switch (DATA_TYPE(mp)) { - case M_IOCTL: - DATA_TYPE(mp) = M_IOCNAK; - ((struct iocblk *)mp->b_rptr)->ioc_error = EINVAL; - qreply (q, mp); - break; - CASE_DATA - putq (q, mp); - break; - case M_FLUSH: - if (*mp->b_rptr & FLUSHW) - flushq (q, 0); - - if (*mp->b_rptr & FLUSHR) { - flushq (RD (q), 0); - *mp->b_rptr &= ~FLUSHW; - qreply (q, mp); - } else - freemsg (mp); - break; - default: - log_printmsg (NULL, "Strange itest", mp, KERN_WARNING); - /* putctl1(RD(q)->b_next, M_ERROR, ENXIO); */ - freemsg (mp); - break; - } - return; -} - -/* Streams code to scan the write queue. */ -static void -itest_wsrv (queue_t *q) -{ - struct testchannel *testport = (struct testchannel *) q->q_ptr; - struct testcard *testcard; - mblk_t *mp; - int chan; - - if(testport == NULL || testport->q == NULL) { - flushq(q,FLUSHALL); - return; - } - testcard = testport->card; - chan = testport - testcard->port; - - while (q->q_first != NULL) { - int err = isdn2_canrecv(&testcard->card, chan); - if(err != 0) - break; - mp = getq (q)) != NULL); - if(mp != NULL) { - err = isdn2_recv(&testcard->card, chan,mp); - if(err != 0) - freemsg(mp); - } - } -} - - - -#ifdef MODULE -static int devmajor1 = 0; - -static int do_init_module(void) -{ - int err; - - bzero(test_card,sizeof(test_card)); - - err = register_strdev(0,&itest_info,0); - if(err < 0) { - return err; - } - devmajor1 = err; - return 0; -} - -static int do_exit_module(void) -{ - int err1; - int i; - - err1 = unregister_strdev(devmajor1,&itest_info,0); - return err1; -} -#endif - - - diff --git a/compat/Makefile b/compat/Makefile index 12ad52f..0fd5153 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -1,52 +1,14 @@ -## Makefile for compatibility stuff +all:: -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = - -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux - -SOURCES = compat.c -OBJ = compat.o -ALL = - -all: compat.o - -lib: - -install: all - # @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - # @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -clean: - rm -f linux - rm -f $(ALL) $(OBJ) - # @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -depend: Makefile $(SOURCES) +depend:: rm -f syscompat.h linux ln -s compat.h syscompat.h ln -s . linux - $(CC) -M $(DEFS) $(SOURCES) > .depend -load: - insmod compat.o +KERNEL=1 -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules +clean:: + rm -f linux diff --git a/compat/compat.c b/compat/compat.c index 4de38ef..41b6bd0 100644 --- a/compat/compat.c +++ b/compat/compat.c @@ -11,7 +11,7 @@ #include #endif -#include +#include "kernel.h" #include #include @@ -244,21 +244,21 @@ void sysdump(const char *msg, struct pt_regs *regs, unsigned long err) esp = (unsigned long) ®s->esp; ss = KERNEL_DS; - printk(KERN_DEBUG "\n"); + printk("%s\n",KERN_DEBUG); if(msg != NULL) - printk(KERN_EMERG "%s: %08lx\n", msg, err); + printk("%s%s: %08lx\n", KERN_DEBUG, msg, err); else nlim += 4; if(regs != NULL) { - printk(KERN_EMERG "EIP: %04x:%08lx EFLAGS: %08lx\n", 0xffff & regs->cs,regs->eip,regs->eflags); - printk(KERN_EMERG "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", + printk("%sEIP: %04x:%08lx EFLAGS: %08lx\n", KERN_EMERG, 0xffff & regs->cs,regs->eip,regs->eflags); + printk("%seax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", KERN_EMERG, regs->eax, regs->ebx, regs->ecx, regs->edx); - printk(KERN_EMERG "esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", + printk("%sesi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n",KERN_EMERG, regs->esi, regs->edi, regs->ebp, esp); - printk(KERN_EMERG "ds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n", + printk("%sds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n",KERN_EMERG, regs->ds, regs->es, regs->fs, regs->gs, ss); if (STACK_MAGIC != *(unsigned long *)current->kernel_stack_page) - printk(KERN_EMERG "Corrupted stack page\n"); + printk("%sCorrupted stack page\n",KERN_EMERG); else nlim += 1; @@ -266,24 +266,24 @@ void sysdump(const char *msg, struct pt_regs *regs, unsigned long err) nlim += 5; store_TR(i); if(current != NULL) { - printk(KERN_EMERG "Process %s (pid: %d, process nr: %d, stackpage=%08lx)\n", - current->comm, current->pid, 0xffff & i, current->kernel_stack_page); + printk("%sProcess %s (pid: %d, process nr: %d, stackpage=%08lx)\n", + KERN_EMERG,current->comm, current->pid, 0xffff & i, current->kernel_stack_page); } else { - printk(KERN_EMERG "No current process\n"); + printk("%sNo current process\n",KERN_EMERG); } { int nlines = 0, linepos = 0; - printk(KERN_EMERG ""); + printk("%s",KERN_EMERG); for (i=0; dodump && nlines < nlim; i++) { u_long xx = get_seg_long(ss,(i+(unsigned long *)esp)); if(dodump > 1 && (xx & 0xfff00000) == 0xbff00000) dodump = 4; - #define WRAP(n) do { if((linepos+=(n))>=80) { dodump--; nlines++; linepos=(n); printk("\n" KERN_EMERG); } } while(0) +#define WRAP(n) do { if((linepos+=(n))>=80) { dodump--; nlines++; linepos=(n); printk("\n%s", KERN_EMERG); } } while(0) if (xx & 0xFF000000UL) { WRAP(9); printk("%08lx ",xx); } else if(xx & 0x00FF0000UL) { WRAP(7); printk("%06lx ",xx); } else if(xx & 0x0000FF00UL) { WRAP(5); printk("%04lx ",xx); } else { WRAP(3); printk("%02lx ",xx); } - #undef WRAP +#undef WRAP } printk("\n"); } @@ -301,7 +301,7 @@ void sysdump(const char *msg, struct pt_regs *regs, unsigned long err) if(dodump < 10000) { int j; - printk(KERN_EMERG "Crash & Burn..."); + printk("%sCrash & Burn...",KERN_EMERG); for(j=dodump;j>0;j--) { int i; if((j%30 == 0) || (j%5 == 0 && j < 60) || j < 10) printk("%d...",j); @@ -309,7 +309,7 @@ void sysdump(const char *msg, struct pt_regs *regs, unsigned long err) } panic("now."); } else { - printk(KERN_EMERG "Kernel halted."); + printk("%sKernel halted.",KERN_EMERG); for(;;); } } @@ -317,6 +317,17 @@ void sysdump(const char *msg, struct pt_regs *regs, unsigned long err) } + +char *loghdr(char level) +{ + static char sbuf[30]; + static int tdiff = 0; + sprintf(sbuf,"<%d>%d:",level,jiffies-tdiff); + tdiff = jiffies; + return sbuf; +} + + void do_i_sleep_on(struct wait_queue **p) { long s = splx(~0); @@ -337,7 +348,8 @@ char kernel_version[] = UTS_RELEASE; int init_module(void) { -#if defined(__ELF__) || LINUX_VERSION_CODE >= 66304 /* 1.3.0. Is that right??? */ +/* This should work... */ +#if defined(__ELF__) #define U #else #define U "_" diff --git a/config/Makefile b/config/Makefile index 14eef31..3c29e56 100644 --- a/config/Makefile +++ b/config/Makefile @@ -1,8 +1,5 @@ -## $Revision: 1.20 $ SHELL = /bin/sh MAKE = make -## =()

@>()= -P = FILE = files.list LIST = `grep -v '^;' <$(FILE)` @@ -12,19 +9,24 @@ LIST = `grep -v '^;' <$(FILE)` #SED = -e /usr/gnu/bin/sed -all prog lib install update depend: substitutions +all prog lib install update depend:: substitutions indent load: quiet: @$(MAKE) 'FILE=$(FILE)' substitutions | grep -v unchanged -clobber clean: +clobber: clean + rm -f config.data + rm -f tags lint substitutions + +clean: rm -f subst.tmp config.new subst rm -f tags lint substitutions substitutions: subst files.list config.data - -@rm -f ../*/substtmp.new ../*/substtmp.old + -@find .. -name substtmp.new -o -name substtmp.old | xargs rm -f ../.not.there + @if test -f config.new ; then echo "*** Check config.new and rename it to config.data, then re-make!"; exit 1 ; fi @sh ./checkconf.sh cat config.data >subst.tmp #@awk 'NR==1 {printf "PATCHLEVEL\t%s\n", $$2;}' <../PATCHLOG >>subst.tmp @@ -33,44 +35,19 @@ substitutions: subst files.list config.data @rm subst.tmp -date > substitutions -backup: - @sh ../iftrue.sh '-d ORIG' 'echo ORIG exists! ; exit 1' - mkdir ORIG - @for I in $(LIST) ; do \ - echo cp $$I ORIG ; \ - cp $$I ORIG ; \ - done - -restore: - @sh ../iftrue.sh '! -d ORIG' 'echo No ORIG directory! ; exit 1' - @for I in $(LIST) ; do \ - echo cp ORIG/`basename $$I` $$I ; \ - cp ORIG/`basename $$I` $$I ; \ - done - -config.data: config.dist - @sh ../iftrue.sh '-f config.new' 'echo config.new exists! ; exit 1' - @sh ../iftrue.sh '-f config.old' 'echo config.old exists! ; exit 1' - @sh ../iftrue.sh '! -f config.data' '$(MAKE) CLOBBER=YES SCRATCH' - cat config.data config.dist >subst.tmp +config.data: subst config.dist + @if test -f config.new; then echo "*** Check config.new and rename it to config.data, then re-make!" ; exit 1 ; fi + -@rm -f subst.tmp + @if test -f config.data; then cat config.data config.dist ; else cat config.dist ; fi > subst.tmp cp config.dist config.new ./subst $(SED) -f subst.tmp config.new -@rm -f subst.tmp - @echo "Update config.old from config.new!" - @sh ../iftrue.sh '-f config.data' \ - 'echo "Renamed config file to config.old"; mv config.data config.old' - exit 1 ; -SCRATCH: - @sh ../iftrue.sh '-z $(CLOBBER)' 'echo No way! ; exit 1' - @echo 'You do not have a config.data file.' - @echo 'Setting one up using the default file.' - @echo 'You must edit this file, then remove config.new and config.old.' - @echo 'Then restart the make.' - cat config.dist >config.data + @echo "Check config.new, then rename it to config.data, and re-make!" + @false subst: subst.c subst.sh -make c || make sh || rm -f subst - @sh ../iftrue.sh '! -f subst' 'echo Cannot make subst ; exit 1' + @if test ! -f subst; then echo Cannot make subst ; exit 1; fi c: @rm -f subst $(CC) -o subst subst.c diff --git a/config/config.data b/config/config.data deleted file mode 100644 index 66ec906..0000000 --- a/config/config.data +++ /dev/null @@ -1,193 +0,0 @@ -## -## ISDN master configuration file for Linux. -## Note that if you leave a field blank, you must have the trailing tab! -## -## Set the STR_IN parameter to "in" if you're using BSD networking code. -## If not, use "none" and forget about TCP/IP. - - -## -## System type. Selects which Makefiles to use for installation. -#### =()@>()= -SYS linux -## -## -## Where to install everything. -#### =()@>()= -DESTDIR /usr/local/isdn -## -## What to name the lockfiles. -#### =()@>()= -LOCKNAME /var/lock/LCK..%s -## - -## Name of the "KERNEL" flag in system include files (KERNEL, _KERNEL, INKERNEL) -## Be aware that -DKERNEL is used by the ISDN libraries -- don't turn it off. -#### =()@>()= -KERNEL -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -## Byte order. Motorola 4321, Intel 1234. -#### =()@>()= -BYTEORDER 1234 -## -## Card drivers to install. Subdirectories of SRC/cards. -#### =()@>()= -CARDS dumb -#### =()@>()= -DUMBCARDS teles -### teles avm bsc ncp ncp16 -## Teles is good for Creatix cards, too. -## Also edit cards/dumb/Config.c. -## All drivers other than Teles don't work yet. -## -## Defines for master program (L2 test version) -#### =()@>()= -CARDDEFS -DDUMB -## -## Level to include in master program. -## Set to 3.(2 for semi-testing L2 in user mode. 4 is untested.) -#### =()@>()= -MLEVEL 3 - -## If you have a parallel make, set this to "&" -#### =()

@>()= -P -## C pre-processor flags for normal programs. -#### =()@>()= -DEFS -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -## C pre-processor flags for kernel code. -## Don't include any KERNEL flags. -#### =()@>()= -DEFKERNEL -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -## C pre-processor flags for ISDN card support -#### =()@>()= -DEFCARDS -I../../streams -I../../compat -fomit-frame-pointer -funroll-loops -### -## C compiler for the kernel -#### =()@>()= -CC gcc -### -## C compiler for the utilities -#### =()@>()= -CCU gcc -## -## common C compiler flags -#### =()@>()= -CFLAGS -O2 -Wall -#CFLAGS -x c++ -g -O2 -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS -g -W -Wreturn-type -Wshadow -Wcomment -D_BSD_SOURCE -D_SYSV_SOURCE -## Flags for the "cc -o" line -#### =()@>()= -LDFLAGS -v -## -## Calling ld directly? -#### =()@>()= -LD ld -## -## If you need to link in other libraries, add them here -#### =()@>()= -LIBS -lbsd -## -## Ranlib needed ? -#### =()@>()= -RANLIB ranlib -## -## Need strsave(3)? DO or DONT. -#### =()@>()= -NEED_STRDUP DONT -## -## Do you have setsid()? -#### =()@>()= -HAVE_SETSID DO -## -## How many arguments does your setpgrp() take? 0 or 2. -#### =()@>()= -HAVE_SETPGRP 0 - -## Does Streeams use signed or unsigned characters in its buffer? -#### =()@>()= -STREAMCHAR unsigned char -## -## Define only if building a kernel complains that there's no spl(). -#### =()@>()= -NEED_SPL DONT -## -## signal functions' return type? Usually void or int. -#### =()@>()= -SIGRET void -## -## Need writev(3)? DO or DONT. -#### =()@>()= -NEED_WRITEV DONT -## -## Signal blocking? SYSV or BSD or NONE. -#### =()@>()= -SIGTYPE SYSV -## -## Define only if building a kernel complains that there's no memcpy. -#### =()@>()= -NEED_MEMCPY DONT -## -## Name of sys/termio.h (or sys/termios.h) -#### =()@>()= -TERMIO termios -## -## Name of /usr/include/strings.h -#### =()@>()= -STRINGS string -## -## What a minor number is called. -#### =()@>()= -SUBDEV uchar_t -## -## Streams <-> INet interface? "in" or "in2" or "str" or "linux" or "none" -## "in" is old BSD, "in2" is BSD 4.4, "str" is Streams-based -#### =()@>()= -STR_IN linux -## -## kernel timeout() funtion. OLD: untimeout takes first two args of timeout(). -## NEW: untimeout takes return value of timeout(). -#### =()@>()= -TIMEOUT NEW -## -## Streams XXXopen() -- does it get an additional "pointer to int" argument -## which points to the appropriate errno value? -#### =()@>()= -ADDERROR DONT -## -## Debugging? DO or DONT -#### =()@>()= -DEBUGGING DO -#### =()@>()= -CONF_MOD2 0x00 -## 0x00, 0x33 -#### =()@>()= -CONF_DEBUG 0x0000 -## 0x5006, 0xf3df - - -### ISDN configuration options - -## One TEI per B channel? Seems to be required for US National-1. -## DO or DONT. DO is currently not supported by the L3 driver. -#### =()@>()= -MULTI_TEI DONT -## -### the other configuration stuff is now per-card, see DOKU. - -## -## What to call protocol stuff. M_EXPROTO or (M_PROTO+0x40) -#### =()@>()= -MSG_PROTO M_EXPROTO -## -## What to call hopefully-expedited data stuff. M_EXDATA or (M_DATA+0x40). -#### =()@>()= -MSG_EXDATA M_EXDATA -## -## What to call normal data stuff. M_DATA -#### =()@>()= -MSG_DATA M_DATA - -## -#### Path names -ROUTE_PATH /sbin/route - diff --git a/config/config.data.aux b/config/config.data.aux deleted file mode 100644 index 62edddc..0000000 --- a/config/config.data.aux +++ /dev/null @@ -1,182 +0,0 @@ -## -## ISDN master configuration file. -## Note that if you leave a field blank, you must have the trailing tab! -## - - -## -## System type. Selects which Makefiles to use for installation. -#### =()@>()= -SYS aux -## -## Name of the "KERNEL" flag in system include files (KERNEL, _KERNEL, INKERNEL) -## Be aware that -DKERNEL is used by the ISDN libraries. -#### =()@>()= -KERNEL -DKERNEL -## Byte order. Motorola 4321, Intel 1234. -#### =()@>()= -BYTEORDER 4321 -## -## Card drivers to install. Subdirectories of SRC/cards. -#### =()@>()= -CARDS leonardo -## -## Defines for master program (L2 test version) -#### =()@>()= -CARDDEFS -DLEONARDO -## -## Level to include in master program. -## Set to 3.(2 for semi-testing L2 in user mode. 4 is untested.) -#### =()@>()= -MLEVEL 3 - -## If you have a parallel make, set this to "&" -#### =()

@>()= -P -## C pre-processor flags; other flags specific for code location. -#### =()@>()= -DEFS -I../include -## C pre-processor flags when compiling kernel code. -## Don't include any KERNEL flags. -#### =()@>()= -DEFKERNEL -I../include -## C pre-processor flags, when compiling card support -#### =()@>()= -DEFCARDS -I../../include -## C compiler -#### =()@>()= -CC gcc.new -## -## common C compiler flags -#### =()@>()= -CFLAGS -g -O2 -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS -g -O2 -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS -g -W -Wreturn-type -Wshadow -Wcomment -D_BSD_SOURCE -D_SYSV_SOURCE -## Flags for the "cc -o" line; e.g., -Bstatic on SunOS4.x while debugging. -#### =()@>()= -LDFLAGS -## -## If you need to link in other libraries, add them here -#### =()@>()= -LIBS -lbsd -## -## Ranlib needed ? -#### =()@>()= -RANLIB : ranlib -## -## Need strsave(3)? DO or DONT. -#### =()@>()= -NEED_STRSAVE DO -## - -## Does Streeams use signed or unsigned characters in its buffer? -#### =()@>()= -STREAMCHAR uchar_t -## -## Define only if building a kernel complains that there's no spl(). -#### =()@>()= -NEED_SPL DO -## -## signal functions' return type? Usually void or int. -#### =()@>()= -SIGRET void -## -## Need writev(3)? DO or DONT. -#### =()@>()= -NEED_WRITEV DO -## -## Signal blocking? SYSV or BSD or NONE. -#### =()@>()= -SIGTYPE SYSV -## -## Define only if building a kernel complains that there's no memcpy. -#### =()@>()= -NEED_MEMCPY DO -## -## Name of sys/termio.h (or sys/termios.h) -#### =()@>()= -TERMIO termio -## -## Name of /usr/include/strings.h -#### =()@>()= -STRINGS strings -## -## What a minor number is called. -#### =()@>()= -SUBDEV uchar_t -## -## Streams <-> INet interface? "in" or "str" -#### =()@>()= -STR_IN str -## -## kernel timeout() funtion. OLD: untimeout takes first two args of timeout(). -## NEW: untimeout takes return value of timeout(). -#### =()@>()= -TIMEOUT OLD -## -## Streams XXXopen() -- does it have an additional "pointer to int" argument -## which points to the appropriate errno value? -#### =()@>()= -ADDERROR DONT -## -## Include some Streams debugging code? DO or DONT. -#### =()@>()= -STREAMDEBUG DONT -## -## Also hook into the Kernel Streams code? -#### =()@>()= -STREAMDEBUGK DONT -## -## Also allocate a few spare Streams blocks? -#### =()@>()= -STREAMALLOC DONT -## -## Also include tracing code? DO or DONT. -#### =()@>()= -STREAMTRACE DONT -## -## Also include free list and queue checking code? DO or DONT. -#### =()@>()= -STREAMCHECK DONT -## -## Cause a reboot if theres a fatal error somewhere? DO or DONT. -#### =()@>()= -BOOT DONT -## - -### ISDN configuration options - -## One TEI per B channel? Seems to be required for US National-1. -## DO or DONT. -#### =()@>()= -MULTI_TEI DONT -## -## Take down Level 2 if idle? (Some PBXes don't like this.) -#### =()@>()= -L2_DOWN DO -## -## Grab a TEI when starting up? -## Turn this on if the first incoming call is answered too late. -#### =()@>()= -TEI_IMMEDIATE DONT - -## -## Delay when establishing a connection. Range: 1..HZ*2. -## Use this when the ISDN switch has problems with accepting data -## immediately after establishing a connection. -#### =()@>()= -UP_DELAY ((HZ * 3) / 2) - -## -## What to call protocol stuff. M_EXPROTO or (M_PROTO+0x40) -#### =()@>()= -MSG_PROTO M_EXPROTO -## -## What to call hopefully-expedited data stuff. M_EXDATA or (M_DATA+0x40). -#### =()@>()= -MSG_DATA M_EXDATA - -## -#### Path names -ROUTE_PATH /usr/etc/route - diff --git a/config/config.data.linux b/config/config.data.linux deleted file mode 100644 index 1fc3bf6..0000000 --- a/config/config.data.linux +++ /dev/null @@ -1,191 +0,0 @@ -## -## ISDN master configuration file for Linux. -## Note that if you leave a field blank, you must have the trailing tab! -## -## Set the STR_IN parameter to "in" if you're using BSD networking code. -## If not, use "none" and forget about TCP/IP. - - -## -## System type. Selects which Makefiles to use for installation. -#### =()@>()= -SYS linux -## -## Name of the "KERNEL" flag in system include files (KERNEL, _KERNEL, INKERNEL) -## Be aware that -DKERNEL is used by the ISDN libraries. -#### =()@>()= -KERNEL -DKERNEL -D__KERNEL__ -## Byte order. Motorola 4321, Intel 1234. -#### =()@>()= -BYTEORDER 1234 -## -## Card drivers to install. Subdirectories of SRC/cards. -#### =()@>()= -CARDS bsc -## -## Defines for master program (L2 test version) -#### =()@>()= -CARDDEFS -DBSC -## -## Level to include in master program. -## Set to 3.(2 for semi-testing L2 in user mode. 4 is untested.) -#### =()@>()= -MLEVEL 3 - -## If you have a parallel make, set this to "&" -#### =()

@>()= -P -## C pre-processor flags; other flags specific for code location. -#### =()@>()= -DEFS -I../include -## C pre-processor flags when compiling kernel code. -## Don't include any KERNEL flags. -#### =()@>()= -DEFKERNEL -I../include -## C pre-processor flags, when compiling card support -#### =()@>()= -DEFCARDS -I../../include -## C compiler -#### =()@>()= -CC gcc -## -## common C compiler flags -#### =()@>()= -CFLAGS -x c++ -g -O2 -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS -g -O2 -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS -g -W -Wreturn-type -Wshadow -Wcomment -D_BSD_SOURCE -D_SYSV_SOURCE -## Flags for the "cc -o" line; e.g., -Bstatic on SunOS4.x while debugging. -#### =()@>()= -LDFLAGS -v -## -## If you need to link in other libraries, add them here -#### =()@>()= -LIBS -lbsd -## -## Ranlib needed ? -#### =()@>()= -RANLIB ranlib -## -## Need strsave(3)? DO or DONT. -#### =()@>()= -NEED_STRDUP DONT -## -## Do you have setsid()? -#### =()@>()= -HAVE_SETSID DO -## -## How many arguments does your setpgrp() take? 0 or 2. -#### =()@>()= -HAVE_SETPGRP 0 - -## Does Streeams use signed or unsigned characters in its buffer? -#### =()@>()= -STREAMCHAR unsigned char -## -## Define only if building a kernel complains that there's no spl(). -#### =()@>()= -NEED_SPL DONT -## -## signal functions' return type? Usually void or int. -#### =()@>()= -SIGRET void -## -## Need writev(3)? DO or DONT. -#### =()@>()= -NEED_WRITEV DONT -## -## Signal blocking? SYSV or BSD or NONE. -#### =()@>()= -SIGTYPE SYSV -## -## Define only if building a kernel complains that there's no memcpy. -#### =()@>()= -NEED_MEMCPY DONT -## -## Name of sys/termio.h (or sys/termios.h) -#### =()@>()= -TERMIO termios -## -## Name of /usr/include/strings.h -#### =()@>()= -STRINGS string -## -## What a minor number is called. -#### =()@>()= -SUBDEV uchar_t -## -## Streams <-> INet interface? "in" or "str" or "none" -#### =()@>()= -STR_IN in -## -## kernel timeout() funtion. OLD: untimeout takes first two args of timeout(). -## NEW: untimeout takes return value of timeout(). -#### =()@>()= -TIMEOUT NEW -## -## Streams XXXopen() -- does it have an additional "pointer to int" argument -## which points to the appropriate errno value? -#### =()@>()= -ADDERROR DONT -## -## Include some Streams debugging code? DO or DONT. -#### =()@>()= -STREAMDEBUG DONT -## -## Also hook into the Kernel Streams code? -#### =()@>()= -STREAMDEBUGK DONT -## -## Also allocate a few spare Streams blocks? -#### =()@>()= -STREAMALLOC DONT -## -## Also include tracing code? DO or DONT. -#### =()@>()= -STREAMTRACE DONT -## -## Also include free list and queue checking code? DO or DONT. -#### =()@>()= -STREAMCHECK DONT -## -## Cause a reboot if theres a fatal error somewhere? DO or DONT. -#### =()@>()= -BOOT DONT -## - -### ISDN configuration options - -## One TEI per B channel? Seems to be required for US National-1. -## DO or DONT. -#### =()@>()= -MULTI_TEI DONT -## -## Take down Level 2 if idle? (Some PBXes don't like this.) -#### =()@>()= -L2_DOWN DO -## -## Grab a TEI when starting up? -## Turn this on if the first incoming call is answered too late. -#### =()@>()= -TEI_IMMEDIATE DONT - -## -## Delay when establishing a connection. Range: 1..HZ*2. -## Use this when the ISDN switch has problems with accepting data -## immediately after establishing a connection. -#### =()@>()= -UP_DELAY (HZ / 2) - -## -## What to call protocol stuff. M_EXPROTO or (M_PROTO+0x40) -#### =()@>()= -MSG_PROTO M_EXPROTO -## -## What to call hopefully-expedited data stuff. M_EXDATA or (M_DATA+0x40). -#### =()@>()= -MSG_DATA M_EXDATA - -## -#### Path names -ROUTE_PATH /usr/etc/route - diff --git a/config/config.data.pc b/config/config.data.pc deleted file mode 100644 index facf268..0000000 --- a/config/config.data.pc +++ /dev/null @@ -1,182 +0,0 @@ -## -## ISDN master configuration file. -## Note that if you leave a field blank, you must have the trailing tab! -## - - -## -## System type. Selects which Makefiles to use for installation. -#### =()@>()= -SYS svr4 -## -## Name of the "KERNEL" flag in system include files (KERNEL, _KERNEL, INKERNEL) -## Be aware that -DKERNEL is used by the ISDN libraries. -#### =()@>()= -KERNEL -DKERNEL -DINKERNEL -D_INKERNEL -## Byte order. Motorola 4321, Intel 1234. -#### =()@>()= -BYTEORDER 1234 -## -## Card drivers to install. Subdirectories of SRC/cards. -#### =()@>()= -CARDS bsc -## -## Defines for master program (L2 test version) -#### =()@>()= -CARDDEFS -DBSC -## -## Level to include in master program. -## Set to 3.(2 for semi-testing L2 in user mode. 4 is untested.) -#### =()@>()= -MLEVEL 3 - -## If you have a parallel make, set this to "&" -#### =()

@>()= -P -## C pre-processor flags. SysV systems include -DSYSV here. -#### =()@>()= -DEFS -DSYSV -DSVR4 -## C pre-processor flags when compiling kernel code. -## Don't include any KERNEL flags. -#### =()@>()= -DEFKERNEL -## C pre-processor flags, when compiling card support -#### =()@>()= -DEFCARDS -## C compiler -#### =()@>()= -CC gcc -## -## common C compiler flags -#### =()@>()= -CFLAGS -g -O2 -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS -g -O2 -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS -g -W -Wreturn-type -Wshadow -Wcomment -D_BSD_SOURCE -D_SYSV_SOURCE -## Flags for the "cc -o" line; e.g., -Bstatic on SunOS4.x while debugging. -#### =()@>()= -LDFLAGS -g -static -## -## If you need to link in other libraries, add them here -#### =()@>()= -LIBS -lsocket -## -## Ranlib needed ? -#### =()@>()= -RANLIB : ranlib -## -## Signal blocking? SYSV or BSD or NONE. -#### =()@>()= -SIGTYPE SYSV -## -## signal functions' return type? Usually void or int. -#### =()@>()= -SIGRET void -## -## Need writev(3)? DO or DONT. -#### =()@>()= -NEED_WRITEV DO -## -## Need strsave(3)? DO or DONT. -#### =()@>()= -NEED_STRSAVE DO -## -## Define only if building a kernel complains that there's no spl(). -#### =()@>()= -NEED_SPL DO -## -## Define only if building a kernel complains that there's no memcpy(). -#### =()@>()= -NEED_MEMCPY DONT -## -## Name of sys/termio.h (or sys/termios.h) -#### =()@>()= -TERMIO termio -## -## Name of /usr/include/strings.h -#### =()@>()= -STRINGS string -## -## Does Streeams use signed or unsigned characters in its buffer? -#### =()@>()= -STREAMCHAR uchar_t -## -## What a minor number is called. -#### =()@>()= -SUBDEV uchar_t -## -## Streams <-> INet interface? "in" or "str" -#### =()@>()= -STR_IN str -## -## kernel timeout() funtion. OLD: untimeout takes first two args of timeout(). -## NEW: untimeout takes return value of timeout(). -#### =()@>()= -TIMEOUT NEW -## -## Streams XXXopen() -- does it have an additional "pointer to int" argument -## which points to the appropriate errno value? -#### =()@>()= -ADDERROR DONT -## -## Include some Streams debugging code? DO or DONT. -#### =()@>()= -STREAMDEBUG DO -## -## Also hook into the Kernel Streams code? -#### =()@>()= -STREAMDEBUGK DO -## -## Also allocate a few spare Streams blocks? -#### =()@>()= -STREAMALLOC DONT -## -## Also include tracing code? DO or DONT. -#### =()@>()= -STREAMTRACE DONT -## -## Also include free list and queue checking code? DO or DONT. -#### =()@>()= -STREAMCHECK DO -## -## Cause a reboot if theres a fatal error somewhere? DO or DONT. -#### =()@>()= -BOOT DONT -## - -### ISDN configuration options - -## One TEI per B channel? Seems to be required for US National-1. -## DO or DONT. -#### =()@>()= -MULTI_TEI DONT -## -## Take down Level 2 if idle? (Some PBXes don't like this.) -#### =()@>()= -L2_DOWN DO -## -## Grab a TEI when starting up? -## Turn this on if the first incoming call is answered too late. -#### =()@>()= -TEI_IMMEDIATE DONT - -## -## Delay when establishing a connection. Range: 1..HZ*2. -## Use this when the ISDN switch has problems with accepting data -## immediately after establishing a connection. -#### =()@>()= -UP_DELAY ((HZ * 3) / 2) - -## -## What to call protocol stuff. M_PROTO or M_EXPROTO or (M_PROTO+0x40) -#### =()@>()= -MSG_PROTO M_PROTO -## -## What to call hopefully-expedited data stuff. M_DATA or M_EXDATA or (M_DATA+0x40). -#### =()@>()= -MSG_DATA M_DATA - - - -## -#### Path names -ROUTE_PATH /usr/etc/route diff --git a/config/config.dist b/config/config.dist index c3f4b0c..645cdfc 100644 --- a/config/config.dist +++ b/config/config.dist @@ -1,79 +1,210 @@ ## -## ISDN master configuration file. +## ISDN master configuration file for Linux. ## Note that if you leave a field blank, you must have the trailing tab! -## - ## -## System type. Selects which Makefiles to use for installation. +## +## System type. +## #### =()@>()= -SYS aux +SYS linux ## -## Name of the "KERNEL" flag in system include files (KERNEL, _KERNEL, INKERNEL) -#### =()@>()= -KERNEL KERNEL -## Byte order. Motorola 4321, Intel 1234. -#### =()@>()= -BYTEORDER 4321 ## -## Card drivers to install. Subdirectories of SRC/cards. +## Where to install everything. The programs are in bin-KERNELVERSION. +## +#### =()@>()= +DESTDIR /usr/local/isdn +## +## +## What to name the lockfiles. Someting with %s (device name). +## Make sure "cu" and other UUCP utilities use the same convention! +## +#### =()@>()= +LOCKNAME /var/lock/LCK..%s +## +## +#### Path names +## +#### =()@>()= +ROUTE_PATH /sbin/route +## +## +## +## Card drivers to install. teles. +## #### =()@>()= -CARDS leonardo +CARDS teles ## -## Defines for master program (L2 test version) -#### =()@>()= -CARDDEFS -DLEONARDO ## -## Level to include in master program. -## Set to 3.(2 for semi-testing L2 in user mode. 4 is untested.) -#### =()@>()= -MLEVEL 3 - -## If you have a parallel make, set this to "&" -#### =()

@>()= -P -## C pre-processor flags -#### =()@>()= -DEFS -I../include -## C pre-processor flags, when compiling card support -#### =()@>()= -DEFS2 -I../../include -## C compiler +## Protocols to make. fixed phone tei. +## +#### =()@>()= +PROTOCOLS phone tei +## +## +## Subprotocols for "phone". euro german. +## +#### =()@>()= +SUBPROTOCOLS euro german +## +## +## +## Stuff to define +## +## Where's the Linux source? +## +#### =()@>()= +KERNELSRC /usr/src/linux +## +## +## C compiler for the kernel +## #### =()@>()= -CC gcc.new +CC gcc +## +## +## C compiler for the utilities +## +#### =()@>()= +HOSTCC gcc +## +## +## C flags for kernel modules. Needs -DMODULE -DKERNEL -D__KERNEL__. ## -## C compiler flags #### =()@>()= -CFLAGS $(DEFS) -g -O2 -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS $(DEFS) -g -O -W -Wreturn-type -Wshadow -Wcomment -#CFLAGS $(DEFS) -g -W -Wreturn-type -Wshadow -Wcomment -D_BSD_SOURCE -D_SYSV_SOURCE -## Flags for the "cc -o" line; e.g., -Bstatic on SunOS4.x while debugging. +CFLAGS -g -O2 -Wall -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE +## +## +## C flags for programs +## +#### =()@>()= +HOSTCFLAGS -g -O2 -Wall +#CFLAGS -x c++ -g -O2 -W -Wreturn-type -Wshadow -Wcomment +#CFLAGS -g -W -Wreturn-type -Wshadow -Wcomment -D_BSD_SOURCE -D_SYSV_SOURCE +## +## +## Calling ld directly? +## +#### =()@>()= +LD ld +#LD /usr/i486-linuxaout/bin/ld -m i386linux +## +## +## Flags for the "cc -o" command line +## #### =()@>()= LDFLAGS ## +## ## If you need to link in other libraries, add them here +## #### =()@>()= -LIBS -lbsd -lc_s +LIBS -lbsd ## -## RANLIB +## +## +## System dependent stuff below: don't change. +## +## +## Byte order. Motorola 4321, Intel 1234. +#### =()@>()= +BYTEORDER 1234 +## +## Ranlib needed ? "ranlib" or "echo" #### =()@>()= -RANLIB : ranlib +RANLIB echo ## +## Need strsave(3)? DO or DONT. +#### =()@>()= +NEED_STRDUP DONT +## +## Do you have setsid()? +#### =()@>()= +HAVE_SETSID DO +## +## How many arguments does your setpgrp() take? 0 or 2. +#### =()@>()= +HAVE_SETPGRP 0 +## Does Streeams use signed or unsigned characters in its buffer? +#### =()@>()= +STREAMCHAR unsigned char +## +## Define only if building a kernel complains that there's no spl(). +#### =()@>()= +NEED_SPL DONT +## +## signal functions' return type? Usually void or int. +#### =()@>()= +SIGRET void +## +## Need writev(3)? DO or DONT. +#### =()@>()= +NEED_WRITEV DONT +## +## Signal blocking? SYSV or BSD or NONE. +#### =()@>()= +SIGTYPE SYSV +## +## Define only if building a kernel complains that there's no memcpy. +#### =()@>()= +NEED_MEMCPY DONT ## ## Name of sys/termio.h (or sys/termios.h) #### =()@>()= -TERMIO termio +TERMIO termios ## ## Name of /usr/include/strings.h #### =()@>()= -STRINGS strings +STRINGS string +## +## What a minor number is called. +#### =()@>()= +SUBDEV uchar_t +## +## Streams <-> INet interface? "in" or "in2" or "str" or "linux" or "none" +## "in" is old BSD, "in2" is BSD 4.4, "str" is Streams-based +#### =()@>()= +STR_IF linux +## +## kernel timeout() funtion. OLD: untimeout takes first two args of timeout(). +## NEW: untimeout takes return value of timeout(). +#### =()@>()= +TIMEOUT NEW +## +## Streams XXXopen() -- does it get an additional "pointer to int" argument +## which points to the appropriate errno value? +#### =()@>()= +ADDERROR DONT +## +## Debugging? DO or DONT +#### =()@>()= +DEBUGGING DO +#### =()@>()= +CONF_MOD2 0x30 +## 0x00, 0x33 +#### =()@>()= +CONF_DEBUG 0x5016 +## 0x5006, 0xf3df + +### ISDN configuration options + +## One TEI per B channel? Seems to be required for US National-1. +## DO or DONT. +#### =()@>()= +MULTI_TEI DONT +## ## ## What to call protocol stuff. M_EXPROTO or (M_PROTO+0x40) #### =()@>()= MSG_PROTO M_EXPROTO ## -## What to call hopefully-expedited data stuff. +## What to call hopefully-expedited data stuff. M_EXDATA or (M_DATA+0x40). +#### =()@>()= +MSG_EXDATA M_EXDATA +## +## What to call normal data stuff. M_DATA #### =()@>()= -MSG_DATA M_EXDATA +MSG_DATA M_DATA + diff --git a/config/files.list b/config/files.list index 8506d6c..d54b6c7 100644 --- a/config/files.list +++ b/config/files.list @@ -1,38 +1,7 @@ ;; List of isdn files that are fed to subst. ;; Lines beginning with a semi-colon are comment lines. -../rate/Makefile -../alaw/Makefile -../compat/Makefile -../streams/Makefile -;; ../cards/leonardo/Makefile -;; ../ppp_if/Makefile -../cards/Makefile -../cards/arnet/Makefile -../cards/dumb/Makefile -;; ../cards/bintec/Makefile -../config/Makefile -../tools/Makefile ../include/config.h ../include/f_strings.h ../include/f_termio.h -../include/Makefile ../include/msgtype.h -../ip_mon/Makefile -../isdn_2/Makefile -../isdn_3/Makefile -../isdn_4/Makefile -../ksupport/Makefile -../reconnect/Makefile -;; ../portman/Makefile -../pr_on/Makefile -../str_if/Makefile -;; ../strppp/Makefile -../strslip/Makefile -../support/Makefile -../timer/Makefile -../t70/Makefile -../fakeh/Makefile -../van_j/Makefile -../v110/Makefile -../x75/Makefile -../final/Makefile +../Make.config diff --git a/config/subst.s b/config/subst.s deleted file mode 100644 index f609aa3..0000000 --- a/config/subst.s +++ /dev/null @@ -1,1294 +0,0 @@ - .file "subst.c" -gcc2_compiled.: -___gnu_compiled_c: -.lcomm _buff.2,32 -.text -LC0: - .ascii "Error code %d\12\0" - .align 4 -_xstrerror: - pushl %ebp - movl %esp,%ebp - cmpl $0,_errno - jl L2 - movl _errno,%eax - cmpl %eax,_sys_nerr - jle L2 - movl _sys_errlist(,%eax,4),%eax - movl %ebp,%esp - popl %ebp - ret - .align 4,0x90 -L2: - movl _errno,%edx - pushl %edx - pushl $LC0 - pushl $_buff.2 - call _sprintf - movl $_buff.2,%eax - movl %ebp,%esp - popl %ebp - ret - .align 4 -_xstrchr: - pushl %ebp - movl %esp,%ebp - movl 8(%ebp),%eax - movb 12(%ebp),%dl - cmpb $0,(%eax) - je L6 - .align 2,0x90 -L9: - cmpb %dl,(%eax) - je L10 - incl %eax - cmpb $0,(%eax) - jne L9 -L6: - xorl %eax,%eax -L10: - movl %ebp,%esp - popl %ebp - ret - .align 4 -_xstrrchr: - pushl %ebp - movl %esp,%ebp - movl 8(%ebp),%edx - movb 12(%ebp),%cl - xorl %eax,%eax - cmpb $0,(%edx) - je L13 - .align 2,0x90 -L16: - cmpb %cl,(%edx) - jne L14 - movl %edx,%eax -L14: - incl %edx - cmpb $0,(%edx) - jne L16 -L13: - movl %ebp,%esp - popl %ebp - ret -LC1: - .ascii "%s: Can't copy \"%s\", %s\12\0" - .align 4 -_xstrdup: - pushl %ebp - movl %esp,%ebp - pushl %edi - pushl %ebx - movl 8(%ebp),%ebx - xorb %al,%al - movl %ebx,%edi - cld - movl $-1,%ecx - repne - scasb - movl %ecx,%eax - notl %eax - pushl %eax - call _malloc - addl $4,%esp - testl %eax,%eax - jne L18 - call _xstrerror - pushl %eax - pushl %ebx - movl _argv0,%edx - pushl %edx - pushl $LC1 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L18: - pushl %ebx - pushl %eax - call _strcpy - leal -8(%ebp),%esp - popl %ebx - popl %edi - movl %ebp,%esp - popl %ebp - ret -LC2: - .ascii "%s: Can't unlink %s, %s\12\0" -LC3: - .ascii "%s: Can't link %s to %s, %s\12\0" - .align 4 -_mv: - pushl %ebp - movl %esp,%ebp - pushl %esi - pushl %ebx - movl 8(%ebp),%esi - movl 12(%ebp),%ebx - pushl %ebx - call _unlink - addl $4,%esp - testl %eax,%eax - jge L20 - cmpl $2,_errno - je L20 - call _xstrerror - pushl %eax - pushl %ebx - jmp L23 - .align 4,0x90 -L20: - pushl %ebx - pushl %esi - call _link - addl $8,%esp - testl %eax,%eax - jge L21 - call _xstrerror - pushl %eax - pushl %ebx - pushl %esi - movl _argv0,%edx - pushl %edx - pushl $LC3 - pushl $__IO_stderr_ - call _fprintf - jmp L19 - .align 4,0x90 -L21: - pushl %esi - call _unlink - addl $4,%esp - testl %eax,%eax - jge L19 - call _xstrerror - pushl %eax - pushl %esi -L23: - movl _argv0,%edx - pushl %edx - pushl $LC2 - pushl $__IO_stderr_ - call _fprintf -L19: - leal -8(%ebp),%esp - popl %ebx - popl %esi - movl %ebp,%esp - popl %ebp - ret -LC4: - .ascii "r\0" - .align 4 -_cmp: - pushl %ebp - movl %esp,%ebp - pushl %edi - pushl %esi - pushl %ebx - pushl $LC4 - movl 8(%ebp),%edx - pushl %edx - call _fopen - movl %eax,%edi - addl $8,%esp - testl %edi,%edi - jne L25 - movl $1,%eax - jmp L37 - .align 4,0x90 -L25: - pushl $LC4 - movl 12(%ebp),%edx - pushl %edx - call _fopen - movl %eax,%ebx - addl $8,%esp - testl %ebx,%ebx - jne L27 - pushl %edi - jmp L38 - .align 4,0x90 - .align 2,0x90 -L27: - movl 4(%edi),%eax - cmpl %eax,8(%edi) - ja L29 - pushl %edi - call ___uflow - addl $4,%esp - movl %eax,%esi - jmp L30 - .align 4,0x90 -L29: - movl 4(%edi),%eax - movzbl (%eax),%esi - incl 4(%edi) -L30: - cmpl $-1,%esi - je L28 - movl 4(%ebx),%eax - cmpl %eax,8(%ebx) - ja L32 - pushl %ebx - call ___uflow - addl $4,%esp - cmpl %esi,%eax - jne L36 - jmp L27 - .align 4,0x90 -L32: - movl 4(%ebx),%eax - movzbl (%eax),%eax - incl 4(%ebx) - cmpl %esi,%eax - je L27 - jmp L36 - .align 4,0x90 -L28: - movl 4(%ebx),%eax - cmpl %eax,8(%ebx) - ja L35 - pushl %ebx - call ___uflow - addl $4,%esp - cmpl $-1,%eax - jne L36 - jmp L34 - .align 4,0x90 -L35: - movl 4(%ebx),%eax - movzbl (%eax),%eax - incl 4(%ebx) - cmpl $-1,%eax - je L34 -L36: - pushl %edi - call _fclose - pushl %ebx -L38: - call _fclose - movl $1,%eax - jmp L37 - .align 4,0x90 -L34: - pushl %edi - call _fclose - pushl %ebx - call _fclose - xorl %eax,%eax -L37: - leal -12(%ebp),%esp - popl %ebx - popl %esi - popl %edi - movl %ebp,%esp - popl %ebp - ret - .align 4 -_istemplate: - pushl %ebp - movl %esp,%ebp - pushl %ebx - movl 8(%ebp),%eax - .align 2,0x90 -L40: - pushl $61 - pushl %eax - call _xstrchr - addl $8,%esp - testl %eax,%eax - je L46 - cmpb $40,1(%eax) - jne L42 - cmpb $41,2(%eax) - jne L42 - cmpb $60,3(%eax) - je L41 -L42: - incl %eax - jmp L40 - .align 4,0x90 -L41: - testl %eax,%eax - jne L44 - jmp L46 - .align 4,0x90 -L50: - movb $10,(%eax) - movb $0,1(%eax) - movl %ebx,%eax - jmp L49 - .align 4,0x90 -L44: - addl $4,%eax - movl %eax,%ebx - .align 2,0x90 -L45: - pushl $62 - pushl %eax - call _xstrchr - addl $8,%esp - testl %eax,%eax - je L46 - cmpb $40,1(%eax) - jne L47 - cmpb $41,2(%eax) - jne L47 - cmpb $61,3(%eax) - je L50 -L47: - incl %eax - jmp L45 - .align 4,0x90 -L46: - xorl %eax,%eax -L49: - movl -4(%ebp),%ebx - movl %ebp,%esp - popl %ebp - ret -LC5: - .ascii "%s: Can't splice %s+%s+%s, %s\12\0" -LC6: - .ascii "%s%s%s\0" - .align 4 -_splice: - pushl %ebp - movl %esp,%ebp - subl $4,%esp - pushl %edi - pushl %esi - pushl %ebx - movl 12(%ebp),%esi - movl 16(%ebp),%ebx - xorb %al,%al - movl 8(%ebp),%edi - cld - movl $-1,%ecx - repne - scasb - movl %ecx,%edx - notl %edx - movl %edx,-4(%ebp) - movl %esi,%edi - cld - movl $-1,%ecx - repne - scasb - movl %ecx,%edx - notl %edx - movl %ebx,%edi - cld - movl $-1,%ecx - repne - scasb - movl %ecx,%eax - notl %eax - addl %edx,%eax - movl -4(%ebp),%ecx - leal -2(%ecx,%eax),%eax - pushl %eax - call _malloc - movl %eax,%edi - addl $4,%esp - testl %edi,%edi - jne L53 - call _xstrerror - pushl %eax - pushl %ebx - pushl %esi - movl 8(%ebp),%ecx - pushl %ecx - movl _argv0,%ecx - pushl %ecx - pushl $LC5 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L53: - pushl %ebx - pushl %esi - movl 8(%ebp),%ecx - pushl %ecx - pushl $LC6 - pushl %edi - call _sprintf - movl %edi,%eax - leal -16(%ebp),%esp - popl %ebx - popl %esi - popl %edi - movl %ebp,%esp - popl %ebp - ret -LC7: - .ascii "%s: subst loop in %s:\12\11%s\12\0" -LC8: - .ascii "%s: can't write %s, %s\12\0" - .align 4 -_doline: - pushl %ebp - movl %esp,%ebp - subl $8,%esp - pushl %edi - pushl %esi - pushl %ebx - movl $0,-8(%ebp) - movl 16(%ebp),%ecx - pushl %ecx - call _xstrdup - movl %eax,-4(%ebp) - addl $4,%esp - jmp L67 - .align 4,0x90 - .align 2,0x90 -L58: - movl -4(%ebp),%esi - .align 2,0x90 -L59: - movl 20(%ebp),%ecx - movl (%ecx),%eax - movsbl (%eax),%eax - pushl %eax - pushl %esi - call _xstrchr - movl %eax,%esi - addl $8,%esp - testl %esi,%esi - je L57 - movl 20(%ebp),%edx - movl 4(%edx),%edx - pushl %edx - movl 20(%ebp),%ecx - movl (%ecx),%ecx - pushl %ecx - pushl %esi - call _strncmp - addl $12,%esp - testl %eax,%eax - jne L61 - movb (%esi),%bl - movb $0,(%esi) - incl -8(%ebp) - movl %esi,%eax - movl 20(%ebp),%edx - addl 4(%edx),%eax - pushl %eax - movl 8(%edx),%ecx - pushl %ecx - movl -4(%ebp),%edx - pushl %edx - call _splice - movl %eax,%edi - movb %bl,(%esi) - movl -4(%ebp),%ecx - pushl %ecx - pushl %edi - call _strcmp - addl $20,%esp - testl %eax,%eax - jne L63 - movl -4(%ebp),%edx - pushl %edx - movl 8(%ebp),%ecx - pushl %ecx - movl _argv0,%edx - pushl %edx - pushl $LC7 - pushl $__IO_stderr_ - call _fprintf - pushl %edi - call _free - addl $24,%esp - jmp L57 - .align 4,0x90 -L63: - movl -4(%ebp),%ecx - pushl %ecx - call _free - movl %edi,-4(%ebp) - addl $4,%esp - jmp L58 - .align 4,0x90 -L61: - incl %esi - jmp L59 - .align 4,0x90 -L57: - addl $12,20(%ebp) -L67: - movl 24(%ebp),%edx - cmpl %edx,20(%ebp) - jb L58 - cmpl $0,-8(%ebp) - jle L65 - movl 12(%ebp),%ecx - pushl %ecx - movl -4(%ebp),%edx - pushl %edx - call _fputs - addl $8,%esp - cmpl $-1,%eax - jne L65 - call _xstrerror - pushl %eax - movl 8(%ebp),%ecx - pushl %ecx - movl _argv0,%edx - pushl %edx - pushl $LC8 - pushl $__IO_stderr_ - call _fprintf - movl -4(%ebp),%ecx - pushl %ecx - call _free - movl $-1,%eax - jmp L66 - .align 4,0x90 -L65: - movl -4(%ebp),%edx - pushl %edx - call _free - movl -8(%ebp),%eax -L66: - leal -20(%ebp),%esp - popl %ebx - popl %esi - popl %edi - movl %ebp,%esp - popl %ebp - ret -LC9: - .ascii "substtmp.new\0" -LC10: - .ascii "substtmp.old\0" -LC11: - .ascii "%s/substtmp.new\0" -LC12: - .ascii "%s/substtmp.old\0" -LC13: - .ascii "%s: can't open %s, %s\12\0" -LC14: - .ascii "%s: %s exists, cannot proceed\12\0" -LC15: - .ascii "w\0" -LC16: - .ascii "%s: cannot create temporaries %s and %s\12\0" -LC17: - .ascii "%s: Line %d of %s is too long\12\0" -LC18: - .ascii "%s: %s:%d: unknown variable:\12\11%s\0" -LC19: - .ascii "%s: can't close %s, %s\12\0" -LC20: - .ascii "%s: unchanged\12\0" -LC21: - .ascii "%s: updated\12\0" - .align 4 -_Process: - pushl %ebp - movl %esp,%ebp - subl $3084,%esp - pushl %edi - pushl %esi - pushl %ebx - pushl $47 - movl 8(%ebp),%edx - pushl %edx - call _xstrrchr - movl %eax,%ebx - addl $8,%esp - testl %ebx,%ebx - jne L69 - movl LC9,%edx - movl %edx,-1024(%ebp) - movl LC9+4,%edx - movl %edx,-1020(%ebp) - movl LC9+8,%edx - movl %edx,-1016(%ebp) - movb LC9+12,%dl - movb %dl,-1012(%ebp) - movl LC10,%edx - movl %edx,-2048(%ebp) - movl LC10+4,%edx - movl %edx,-2044(%ebp) - movl LC10+8,%edx - movl %edx,-2040(%ebp) - movb LC10+12,%dl - movb %dl,-2036(%ebp) - jmp L70 - .align 4,0x90 -L69: - movb $0,(%ebx) - movl 8(%ebp),%edx - pushl %edx - pushl $LC11 - leal -1024(%ebp),%eax - pushl %eax - call _sprintf - movl 8(%ebp),%edx - pushl %edx - pushl $LC12 - leal -2048(%ebp),%eax - pushl %eax - call _sprintf - movb $47,(%ebx) - addl $24,%esp -L70: - pushl $LC4 - movl 8(%ebp),%edx - pushl %edx - call _fopen - movl %eax,-3080(%ebp) - addl $8,%esp - testl %eax,%eax - jne L71 - call _xstrerror - pushl %eax - movl 8(%ebp),%edx - pushl %edx - movl _argv0,%edx - pushl %edx - pushl $LC13 - pushl $__IO_stderr_ - call _fprintf - jmp L68 - .align 4,0x90 -L71: - pushl $LC4 - leal -1024(%ebp),%esi - pushl %esi - call _fopen - movl %eax,%ebx - addl $8,%esp - testl %ebx,%ebx - je L72 - movl -3080(%ebp),%edx - pushl %edx - call _fclose - pushl %esi - movl _argv0,%edx - pushl %edx - pushl $LC14 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L72: - pushl $LC4 - leal -2048(%ebp),%esi - pushl %esi - call _fopen - movl %eax,%ebx - addl $8,%esp - testl %ebx,%ebx - je L73 - pushl %esi - movl _argv0,%edx - pushl %edx - pushl $LC14 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L73: - pushl $LC15 - leal -2048(%ebp),%eax - pushl %eax - call _fopen - movl %eax,%ebx - pushl $LC15 - leal -1024(%ebp),%eax - pushl %eax - call _fopen - movl %eax,-3084(%ebp) - addl $16,%esp - testl %eax,%eax - je L75 - testl %ebx,%ebx - jne L74 -L75: - testl %ebx,%ebx - je L76 - pushl %ebx - call _fclose - addl $4,%esp -L76: - leal -2048(%ebp),%eax - pushl %eax - call _unlink - addl $4,%esp - cmpl $0,-3084(%ebp) - je L77 - movl -3084(%ebp),%edx - pushl %edx - call _fclose - addl $4,%esp -L77: - leal -1024(%ebp),%ebx - pushl %ebx - call _unlink - pushl %ebx - leal -2048(%ebp),%eax - pushl %eax - movl _argv0,%edx - pushl %edx - pushl $LC16 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L90: - movl 8(%ebp),%edx - pushl %edx - pushl %edi - movl _argv0,%edx - pushl %edx - pushl $LC17 - pushl $__IO_stderr_ - call _fprintf - incl -3076(%ebp) - addl $20,%esp - jmp L79 - .align 4,0x90 -L91: - incl -3076(%ebp) - jmp L79 - .align 4,0x90 -L74: - pushl %ebx - call _fclose - movl $1,%edi - movl $0,-3076(%ebp) - addl $4,%esp - leal -3072(%ebp),%esi - .align 2,0x90 -L78: - movl -3080(%ebp),%edx - pushl %edx - pushl $1024 - pushl %esi - call _fgets - addl $12,%esp - testl %eax,%eax - je L79 - pushl $10 - pushl %esi - call _xstrchr - movl %eax,%ebx - addl $8,%esp - testl %ebx,%ebx - je L90 - movl -3084(%ebp),%edx - pushl %edx - pushl %esi - call _fputs - pushl %esi - call _istemplate - movl %eax,%ebx - addl $12,%esp - testl %ebx,%ebx - je L80 - movl 16(%ebp),%edx - pushl %edx - movl 12(%ebp),%edx - pushl %edx - pushl %ebx - movl -3084(%ebp),%edx - pushl %edx - movl 8(%ebp),%edx - pushl %edx - call _doline - addl $20,%esp - testl %eax,%eax - jl L91 - jle L84 - movl -3080(%ebp),%edx - pushl %edx - pushl $1024 - pushl %esi - call _fgets - incl %edi - addl $12,%esp - jmp L80 - .align 4,0x90 -L84: - pushl %ebx - pushl %edi - movl 8(%ebp),%edx - pushl %edx - movl _argv0,%edx - pushl %edx - pushl $LC18 - pushl $__IO_stderr_ - call _fprintf - addl $24,%esp -L80: - incl %edi - jmp L78 - .align 4,0x90 -L79: - movl -3080(%ebp),%edx - pushl %edx - call _fclose - movl -3084(%ebp),%edx - pushl %edx - call _fflush - addl $8,%esp - cmpl $-1,%eax - je L87 - movl -3084(%ebp),%edx - pushl %edx - call _fclose - addl $4,%esp - cmpl $-1,%eax - jne L86 -L87: - call _xstrerror - pushl %eax - movl 8(%ebp),%edx - pushl %edx - movl _argv0,%edx - pushl %edx - pushl $LC19 - pushl $__IO_stderr_ - call _fprintf - incl -3076(%ebp) - addl $20,%esp -L86: - cmpl $0,-3076(%ebp) - jne L89 - movl 8(%ebp),%edx - pushl %edx - leal -1024(%ebp),%eax - pushl %eax - call _cmp - addl $8,%esp - testl %eax,%eax - jne L88 -L89: - leal -2048(%ebp),%eax - pushl %eax - call _unlink - leal -1024(%ebp),%eax - pushl %eax - call _unlink - movl 8(%ebp),%edx - pushl %edx - pushl $LC20 - call _printf - jmp L68 - .align 4,0x90 -L88: - pushl $1 - pushl $1 - call _signal - pushl $1 - pushl $2 - call _signal - pushl $1 - pushl $15 - call _signal - leal -2048(%ebp),%ebx - pushl %ebx - movl 8(%ebp),%edx - pushl %edx - call _mv - addl $32,%esp - movl 8(%ebp),%edx - pushl %edx - leal -1024(%ebp),%eax - pushl %eax - call _mv - pushl $0 - pushl $1 - call _signal - pushl $0 - pushl $2 - call _signal - pushl $0 - pushl $15 - call _signal - addl $32,%esp - movl 8(%ebp),%edx - pushl %edx - pushl $LC21 - call _printf - pushl %ebx - call _unlink -L68: - leal -3096(%ebp),%esp - popl %ebx - popl %esi - popl %edi - movl %ebp,%esp - popl %ebp - ret -LC22: - .ascii "Usage: %s -f file victims...\12\0" - .align 4 -_Usage: - pushl %ebp - movl %esp,%ebp - movl _argv0,%edx - pushl %edx - pushl $LC22 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -.data -_NIL.25: - .ascii "\0" -.text -LC23: - .ascii "f:\0" -LC24: - .ascii "%s: Can't open %s to read it, %s\12\0" -LC25: - .ascii "%s: Can't allocate %d table elements, %s\12\0" -LC26: - .ascii "%s: Parameter %s is too long\12\0" -LC27: - .ascii "@<%s>@\0" - .align 4 -.globl _main -_main: - pushl %ebp - movl %esp,%ebp - subl $1180,%esp - pushl %edi - pushl %esi - pushl %ebx - movl 8(%ebp),%ebx - call ___main - movl $0,-1156(%ebp) - movl 12(%ebp),%edi - movl (%edi),%edi - movl %edi,_argv0 - .align 2,0x90 -L94: - pushl $LC23 - movl 12(%ebp),%eax - pushl %eax - pushl %ebx - call _getopt - movl %eax,%esi - addl $12,%esp - cmpl $-1,%esi - je L95 - cmpl $102,%esi - je L98 - call _Usage -L98: - cmpl $0,-1156(%ebp) - je L99 - call _Usage -L99: - movl _optarg,%edi - movl %edi,-1156(%ebp) - jmp L94 - .align 4,0x90 -L95: - movl _optind,%eax - sall $2,%eax - movl %eax,-1176(%ebp) - addl %eax,12(%ebp) - pushl $LC4 - movl -1156(%ebp),%edi - pushl %edi - call _fopen - movl %eax,-1160(%ebp) - addl $8,%esp - testl %eax,%eax - jne L101 - call _xstrerror - movl %eax,-1176(%ebp) - pushl %eax - pushl %edi - movl _argv0,%eax - pushl %eax - pushl $LC24 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L101: - xorl %esi,%esi - leal -1024(%ebp),%ebx - .align 2,0x90 -L102: - movl -1160(%ebp),%edi - pushl %edi - pushl $1024 - pushl %ebx - call _fgets - movl %eax,-1176(%ebp) - addl $12,%esp - testl %eax,%eax - je L103 - incl %esi - jmp L102 - .align 4,0x90 -L103: - leal (%esi,%esi,2),%eax - sall $2,%eax - pushl %eax - call _malloc - movl %eax,-1164(%ebp) - addl $4,%esp - testl %eax,%eax - jne L105 - call _xstrerror - movl %eax,-1176(%ebp) - pushl %eax - pushl %esi - movl _argv0,%eax - pushl %eax - pushl $LC25 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L105: - pushl $0 - pushl $0 - movl -1160(%ebp),%edi - pushl %edi - call _fseek - movl $1,%esi - movl -1164(%ebp),%eax - movl %eax,-1168(%ebp) - addl $12,%esp - leal -1024(%ebp),%edi - movl %edi,-1172(%ebp) - .align 2,0x90 -L106: - movl -1160(%ebp),%eax - pushl %eax - pushl $1024 - movl -1172(%ebp),%edi - pushl %edi - call _fgets - movl %eax,-1176(%ebp) - addl $12,%esp - testl %eax,%eax - je L107 - pushl $10 - pushl %edi - call _xstrchr - movl %eax,-1180(%ebp) - addl $8,%esp - testl %eax,%eax - jne L109 - movl -1156(%ebp),%eax - pushl %eax - pushl %esi - movl _argv0,%edi - pushl %edi - pushl $LC17 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L109: - movl -1180(%ebp),%eax - movb $0,(%eax) - cmpb $0,-1024(%ebp) - je L108 - cmpb $35,-1024(%ebp) - je L108 - leal -1024(%ebp),%edi - movl %edi,-1180(%ebp) - cmpb $32,-1024(%ebp) - je L114 - cmpb $9,-1024(%ebp) - jne L113 - .align 2,0x90 -L114: - incl -1180(%ebp) - movl -1180(%ebp),%eax - cmpb $32,(%eax) - je L114 - cmpb $9,(%eax) - je L114 -L113: - movl -1180(%ebp),%edi - cmpb $0,(%edi) - je L108 - leal -1024(%ebp),%eax - movl %eax,-1180(%ebp) - cmpb $0,-1024(%ebp) - je L139 - cmpb $32,-1024(%ebp) - je L119 - cmpb $9,-1024(%ebp) - je L119 - .align 2,0x90 -L121: - incl -1180(%ebp) - movl -1180(%ebp),%edi - cmpb $0,(%edi) - je L139 - cmpb $32,(%edi) - je L119 - cmpb $9,(%edi) - jne L121 -L119: - movl -1180(%ebp),%eax - cmpb $0,(%eax) - jne L122 -L139: - movl -1168(%ebp),%edi - movl $_NIL.25,8(%edi) - jmp L123 - .align 4,0x90 -L122: - movl -1180(%ebp),%eax - movb $0,(%eax) - incl %eax - movl %eax,-1180(%ebp) - cmpb $0,(%eax) - je L125 - .align 2,0x90 -L128: - movl -1180(%ebp),%edi - cmpb $32,(%edi) - je L126 - cmpb $9,(%edi) - jne L125 -L126: - incl -1180(%ebp) - movl -1180(%ebp),%eax - cmpb $0,(%eax) - jne L128 -L125: - movl -1180(%ebp),%edi - pushl %edi - call _xstrdup - movl %eax,-1176(%ebp) - movl -1168(%ebp),%edi - movl %eax,8(%edi) - movl -1176(%ebp),%ecx - movl %ecx,-1180(%ebp) - addl $4,%esp - cmpb $0,(%ecx) - je L130 - .align 2,0x90 -L134: - movl %ecx,%ebx - incl %ecx - movl -1180(%ebp),%eax - cmpb $92,(%eax) - jne L132 - cmpb $0,1(%eax) - je L132 - incl %eax - movl %eax,-1180(%ebp) - movb (%eax),%dl - jmp L133 - .align 4,0x90 -L132: - movl -1180(%ebp),%edi - movb (%edi),%dl -L133: - movb %dl,(%ebx) - incl -1180(%ebp) - movl -1180(%ebp),%eax - cmpb $0,(%eax) - jne L134 -L130: - movb $0,(%ecx) -L123: - xorb %al,%al - movl -1172(%ebp),%edi - cld - movl $-1,%ecx - repne - scasb - movl %ecx,%eax - notl %eax - subl $1,%eax - cmpl $124,%eax - jbe L135 - movl -1172(%ebp),%edi - pushl %edi - movl _argv0,%eax - pushl %eax - pushl $LC26 - pushl $__IO_stderr_ - call _fprintf - pushl $1 - call _exit - .align 4,0x90 -L135: - movl -1172(%ebp),%edi - pushl %edi - pushl $LC27 - leal -1152(%ebp),%ebx - pushl %ebx - call _sprintf - pushl %ebx - call _xstrdup - movl %eax,-1176(%ebp) - movl -1168(%ebp),%edi - movl %eax,(%edi) - xorb %dl,%dl - movl -1176(%ebp),%ebx - movl %ebx,%edi - movb %dl,%al - cld - movl $-1,%ecx - repne - scasb - notl %ecx - movl %ecx,%edi - subl $1,%edi - movl -1168(%ebp),%eax - movl %edi,4(%eax) - addl $12,%eax - movl %eax,-1168(%ebp) - addl $16,%esp -L108: - incl %esi - jmp L106 - .align 4,0x90 -L107: - movl -1160(%ebp),%eax - pushl %eax - call _fclose - addl $4,%esp - jmp L140 - .align 4,0x90 - .align 2,0x90 -L138: - movl -1168(%ebp),%eax - pushl %eax - movl -1164(%ebp),%edi - pushl %edi - movl 12(%ebp),%eax - movl (%eax),%eax - pushl %eax - addl $4,12(%ebp) - call _Process - addl $12,%esp -L140: - movl 12(%ebp),%edi - cmpl $0,(%edi) - jne L138 - pushl $0 - call _exit - .align 4,0x90 -.lcomm _argv0,4 diff --git a/fakeh/Makefile b/fakeh/Makefile index 60afa7e..59a3139 100644 --- a/fakeh/Makefile +++ b/fakeh/Makefile @@ -1,52 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@ >()= -DEFSN = -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -## =()@ $(DEFSN)>()= -CFLAGSN = -O2 -Wall $(DEFSN) - -## =()@>()= -SYS = linux - -SOURCES = fakeh.c - -OBJ = fakeh.o -ALL = - -all: $(OBJ) $(ALL) - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) $(TESTSOURCES) - -depend: Makefile $(SOURCES) $(TESTSOURCES) - $(CC) -M $(DEFS) $(SOURCES) $(TESTSOURCES) > .depend - -clean: - rm -f $(OBJ) $(ALL) $(TESTALL) $(TESTOBJ) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - - -load: - insmod fakeh.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/final/Makefile b/final/Makefile deleted file mode 100644 index bfdb28e..0000000 --- a/final/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -SHELL = /bin/sh -MAKE = make -## =()@>()= -SYS = linux - -## =()@>()= -CC = gcc -## =()@ @@ >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -## =()@ $(DEFS)>()= -CFLAGS = -g -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux -## =()@>()= -DESTDIR = /usr/local/isdn - -SOURCES = x75.c - -doinstall: - #@$(MAKE) $(MAKEFLAGS) -C .. install - -install.sys: - @sh ../iftrue.sh "-f $(SYS)/Makefile" "cd $(SYS) && $(MAKE) $(MAKEFLAGS) install \ - CFLAGS=\"$(CFLAGS)\" CC=\"$(CC)\"" - if test ! -d ${DESTDIR} ; then mkdir ${DESTDIR} ; else true ; fi - if test ! -d ${DESTDIR}/bin ; then mkdir ${DESTDIR}/bin ; else true ; fi - if test ! -f /etc/isdn.conf; then cp ../cf.tcp /etc/isdn.conf ; else true ; fi - -install.bin: - DIR=${DESTDIR}/bin-$$(uname -r) ; \ - if test -d $$DIR ; then true; else mkdir -p $$DIR; fi ; \ - for i in `/bin/ls ../bin` ; do \ - test -f $$DIR/$$i && \ - mv -f $$DIR/$$i $$DIR/$$i.old ; \ - cp ../bin/$$i $$DIR/$$i ; \ - done - -# "install" does _not_ depend on all, because all calls install indirectly -#install: install.sys install.bin -install: install.sys - -clean: - @sh ../iftrue.sh "-f $(SYS)/Makefile" "cd $(SYS) && $(MAKE) $(MAKEFLAGS) clean" - -run: - @sh ../iftrue.sh "-f $(SYS)/Makefile" "cd $(SYS) && $(MAKE) $(MAKEFLAGS) run" - -lib: - -depend: - -load: - -all: - diff --git a/iftrue.sh b/iftrue.sh deleted file mode 100644 index 2b1b8ca..0000000 --- a/iftrue.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh -## $Revision: 1.2 $ -## Perform a test(1) and execute a command string if the test is true; -## otherwise exit 0. Usage: -## testit -## On some systems (those with a /bin/sh from BSD4.2), the following -## line in a Makefile will always fail: -## if [ ! -f x ] ; then echo No x -- stop. ; exit 1 ; else exit 0 ; fi -case $# in -2) - ;; -*) - echo "Can't perform test: wrong number of arguments." 1>&2 - exit 1 - ;; -esac -TEST="$1" -COMMAND="$2" - -## Note the lack of quotes around ${TEST} below. -if test ${TEST} ; then - eval "${COMMAND}" - exit $? -fi -exit 0 diff --git a/include/Makefile b/include/Makefile index 782c22f..aa4dc37 100644 --- a/include/Makefile +++ b/include/Makefile @@ -1,18 +1,5 @@ +HEADERS = $(wildcard *.h) -SHELL = /bin/sh - -HEADERS = alaw.h config.h dump.h isdn3_phone.h isdn_12.h isdn_2.h isdn_23.h \ - isdn_3.h isdn_34.h isdn_limits.h isdn_proto.h kernel.h lap.h msgtype.h \ - phone_1TR6.h primitives.h proto.h q_data.h sioctl.h smallq.h streamlib.h \ - streams.h timeout.h v110.h x75.h x75lib.h - -SOURCES = -OBJ = -ALL = - -all prog lib install update clean depend load: - -indent: - ../indent.sh $(HEADERS) $(SOURCES) - +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/include/config.h b/include/config.h index 0336bfd..b3f8ed9 100644 --- a/include/config.h +++ b/include/config.h @@ -40,9 +40,9 @@ typedef unsigned char streamchar; #ifdef KERNEL /* =()<#define CONF_MOD2 @@>()= */ -#define CONF_MOD2 0x00 +#define CONF_MOD2 0x30 /* =()<#define CONF_DEBUG @@>()= */ -#define CONF_DEBUG 0x0000 +#define CONF_DEBUG 0x5016 #else #ifdef DO_DEBUGGING diff --git a/include/isdn3_phone.h b/include/isdn3_phone.h index 08ed904..f86f580 100644 --- a/include/isdn3_phone.h +++ b/include/isdn3_phone.h @@ -1,11 +1,6 @@ #ifndef _ISDN3_PHONE #define _ISDN3_PHONE -/* PD */ -#define PD_Q931 8 -#define PD_N0 0x40 -#define PD_N1 0x41 - /* * Interface for different phone protocol handlers. */ @@ -78,11 +73,6 @@ typedef struct _isdn3_prot { */ int isdn3_attach_prot (isdn3_prot prot); -/* - * Find the protocol; "info" has a list of allowable protocols - */ -isdn3_prot isdn3_findprot (mblk_t *info, uchar_t protocol); - /* * Extract data into a conn vector. */ diff --git a/include/isdn_23.h b/include/isdn_23.h index bda8b42..abaf38f 100644 --- a/include/isdn_23.h +++ b/include/isdn_23.h @@ -18,6 +18,7 @@ typedef struct _isdn23_hdr { uchar_t key; + ushort_t seqnum; union { /* Length param must be first if it's needed */ struct { /* Command mode data/response. */ @@ -159,6 +160,7 @@ typedef struct _isdn23_hdr { * somewhat cleaner if the TEI negotiation * handler is just another L3 protocol */ struct { + ushort_t len; uchar_t card; int seqnum; int foffset; @@ -169,7 +171,7 @@ typedef struct _isdn23_hdr { */ } sel; -} *isdn23_hdr; +} __attribute__((packed)) *isdn23_hdr; /* Aliases for writing actual programs. *//* Keys for debugging L2. */ #define hdr_atcmd sel._hdr_atcmd /* A */ diff --git a/include/isdn_3.h b/include/isdn_3.h index 5e2c9c1..93554c9 100644 --- a/include/isdn_3.h +++ b/include/isdn_3.h @@ -31,6 +31,7 @@ typedef struct _isdn3_card { /* One per card */ uchar_t nr; /* Card number, for L2. */ uchar_t TEI; /* For reference */ uchar_t bchans; /* Number of B channels. */ + unsigned is_up:1; } *isdn3_card; /** @@ -102,6 +103,11 @@ typedef void (*P_hndl_killconn) (struct _isdn3_conn * conn, char force); */ typedef void (*P_hndl_hook) (struct _isdn3_conn * conn); +/* + * Catch what's sent down to L2. If data returns NULL, forward nothing. + */ +typedef int (*P_hndl_proto) (struct _isdn3_conn * conn, mblk_t **data, char down); + typedef struct _isdn3_hndl { struct _isdn3_hndl *next; /* Next handler */ uchar_t SAPI; @@ -119,6 +125,7 @@ typedef struct _isdn3_hndl { P_hndl_kill kill; /* Say goodbye */ P_hndl_killconn killconn; /* terminate a connection */ P_hndl_hook hook; /* isdn3_setup_conn was called */ + P_hndl_proto proto; /* Send cmd; used for catching protocol lists */ } *isdn3_hndl; /** @@ -127,6 +134,9 @@ typedef struct _isdn3_hndl { ** Calls managed by this connection are chained off the struct. **/ +#define NITALK 3 +#define NSTALK 1 + typedef struct _isdn3_talk { /* one per card's D channel connection */ struct _isdn3_conn *conn; /* connections managed on this channel */ struct _isdn3_card *card; /* Back ref to my card */ @@ -134,15 +144,16 @@ typedef struct _isdn3_talk { /* one per card's D channel connection */ struct _isdn3_hndl *hndl; /* Handler for this type of talk. */ uchar_t state; /* . Zero: first call / uninitialized. Others * depend on the talker. */ - int talk_a, talk_b, talk_c, talk_d; /* additional variables, handler - * dependent */ + long talki[NITALK]; + void *talks[NSTALK]; } *isdn3_talk; /** ** One struct isdn3_conn represents one ISDN call. **/ -#define NCONNVEC 5 #define STACK_LEN 10 +#define NICONN 15 +#define NSCONN 3 typedef struct _isdn3_conn { struct _isdn3_card *card; /* Card this call is running on */ @@ -156,8 +167,9 @@ typedef struct _isdn3_conn { * vs... */ char stack[STACK_LEN]; /* Protocol stack to set up on this * connection */ - int *v[NCONNVEC]; /* additional and possibly-long parameters */ int delay; /* don't get at it right away */ + long conni[NICONN]; /* additional variables, handler dependent */ + void *conns[NSCONN]; #ifdef NEW_TIMEOUT /* Grumble */ int start_timer; int delay_timer; diff --git a/include/isdn_34.h b/include/isdn_34.h index 0abe368..797c219 100644 --- a/include/isdn_34.h +++ b/include/isdn_34.h @@ -55,6 +55,7 @@ * will be interpreted directly. This * way, specialized drivers can do * their own call management. */ +#define CMD_NOCARD CHAR2('q','C') /* (active) card is to be presumed dead */ /* Commands for ISDN-B access. */ #define CMD_DIAL CHAR2 ('d','o')/* Dial out. */ @@ -103,6 +104,7 @@ #define ARG_NOREJECT CHAR2('n','j') /* don't send REJ code */ #define ARG_FASTDROP CHAR2('f','X') #define ARG_FASTREDIAL CHAR2('f','r') +#define ARG_CHANBUSY CHAR2('i','b') #define ARG_IGNORELIMIT CHAR2('i','l') #define ARG_FORCE CHAR2('f','d') /* In CMD_OFF: Force DISC */ @@ -124,11 +126,15 @@ #define ARG_CONNREF CHAR2 ('C','r') /* uchar refnum for a connection. */ #define ARG_CARD CHAR2 ('c','d') /* ident Card */ #define ARG_CHANNEL CHAR2 ('b','c') /* uchar B channel to use */ +#define ARG_ASSOC CHAR2 ('a','=') /* associate card IDs */ +#define ARG_LISTEN CHAR2 ('l','p') /* listen params */ + #define ARG_MINOR CHAR2 ('m','i') /* uchar minor number of data * connection */ #define ARG_FMINOR CHAR2 ('m','f') /* uchar minor number of command * connection */ #define ARG_CALLREF CHAR2 ('c','r') /* long call reference number */ +#define ARG_EAZ CHAR2 ('e','a') /* map EAZ to local phone nr */ #define ARG_LNUMBER CHAR2 ('l','r') /* local phone nr */ #define ARG_NUMBER CHAR2 ('n','r') /* remote phone nr */ #define ARG_OUTNUMS CHAR2 ('o','m') /* outgoing, for build */ @@ -162,6 +168,7 @@ #define ARG_SEQNUM CHAR2('s','N') /* number of the file */ #define ARG_OFFSET CHAR2('o','F') /* offset within the file */ +#define ARG_LENGTH CHAR2('l','N') /* offset within the file */ #define ARG_UPDELAY CHAR2('u','d') /* Delay the data exchange */ diff --git a/include/isdn_proto.h b/include/isdn_proto.h index d0f671e..7d1fc96 100644 --- a/include/isdn_proto.h +++ b/include/isdn_proto.h @@ -46,6 +46,7 @@ #define PROTO_AT CHAR2('a','t') /* Command. "*at ATD9612521". */ #define PROTO_MODULE CHAR2('m','s') /* Setup for a protocol */ #define PROTO_MODLIST CHAR2('m','l') /* list of modules to be pushed */ +#define PROTO_UPDATEMODLIST CHAR2('m','L') /* informational: list of modules */ #define PROTO_ERROR CHAR2('e','r')/* Error. */ #define PROTO_NOERROR CHAR2('o','k') /* Error. */ /* diff --git a/include/kernel.h b/include/kernel.h index ebfd216..d39a93b 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -4,19 +4,23 @@ #if defined(linux) #include -#ifdef CONFIG_DEBUG_LATENCY -#undef CONFIG_DEBUG_LATENCY -#endif #endif +#include +#include +#include extern int spl6 (void); extern int spl1 (void); extern int splhi (void); extern int splx (int ms); +extern int spl (int ms); extern void timeout (void *a, void *b, int c); extern void untimeout (void *a, void *b); +int min (int a, int b); +int max (int a, int b); + extern void panic(const char *x, ...); #define KERN_EMERG "0:" /* system is unusable */ @@ -28,5 +32,29 @@ extern void panic(const char *x, ...); #define KERN_INFO "6:" /* informational */ #define KERN_DEBUG "7:" /* debug-level messages */ +#define kmalloc(a,b) malloc((a)) +#define kfree(a) free((a)) +#define kfree_s(a,b) free((a)) + +#else /* KERNEL */ +#include +char *loghdr(char level); +#undef KERN_EMERG +#undef KERN_ALERT +#undef KERN_CRIT +#undef KERN_ERR +#undef KERN_WARNING +#undef KERN_NOTICE +#undef KERN_INFO +#undef KERN_DEBUG +#define KERN_EMERG loghdr(0) +#define KERN_ALERT loghdr(1) +#define KERN_CRIT loghdr(2) +#define KERN_ERR loghdr(3) +#define KERN_WARNING loghdr(4) +#define KERN_NOTICE loghdr(5) +#define KERN_INFO loghdr(6) +#define KERN_DEBUG loghdr(7) + #endif #endif diff --git a/include/lap.h b/include/lap.h index 40c9700..6b4794d 100644 --- a/include/lap.h +++ b/include/lap.h @@ -1,6 +1,5 @@ /* Defs for Q.921. */ -#define SAPI_INVALID 0xFF #define TEI_FIXED 0x12 /* if using a fixed TEI value */ #define TEI_BROADCAST 0x7F #define TEI_REQUESTED 0xFF /* invalid value, used in L2 only diff --git a/include/loader.h b/include/loader.h new file mode 100644 index 0000000..817e859 --- /dev/null +++ b/include/loader.h @@ -0,0 +1,15 @@ +#ifndef LOADER_H +#define LOADER_H +#include + +struct cardinfo { + long memaddr; + short ioaddr; + unsigned char irq, ipl; + unsigned long ID; + unsigned int debug; + +}; + +#endif + diff --git a/include/primitives.h b/include/primitives.h index fab0ee1..feb4b7b 100644 --- a/include/primitives.h +++ b/include/primitives.h @@ -1,24 +1,19 @@ #ifndef _PRIM_H #define _PRIM_H -#ifdef linux -#ifdef KERNEL #include -#endif -#include #include -#endif - #include "config.h" +#include "kernel.h" + #include "msgtype.h" #include #include #ifdef linux +#include #ifdef KERNEL #include -#include #else -#include "kernel.h" #include /* printf */ #include #include diff --git a/include/sapi.h b/include/sapi.h new file mode 100644 index 0000000..b26a926 --- /dev/null +++ b/include/sapi.h @@ -0,0 +1,23 @@ +#ifndef ISDN_SAPI +#define ISDN_SAPI + +/* + * Service Access Point Identifiers. (Oder sowas in der Art...) + */ + +#define SAPI_PHONE 0 +#define SAPI_PHONE_DSS1 8 +#define SAPI_PHONE_1TR6_0 64 /* Unused (so far) */ +#define SAPI_PHONE_1TR6_1 65 + +#define SAPI_TEI 63 + +/* pseudo-SAPIs */ +#define SAPI_FIXED 64 + +#define SAPI_CAPI 65 +#define SAPI_CAPI_BINTEC 0 + +#define SAPI_INVALID 127 + +#endif diff --git a/include/streamlib.h b/include/streamlib.h index 066b1c6..ef1419c 100644 --- a/include/streamlib.h +++ b/include/streamlib.h @@ -78,15 +78,15 @@ int putctlx1 (queue_t * q, char type, streamchar msg); #ifdef CONFIG_DEBUG_STREAMS -#define pullupm(q,x) deb_pullupm(__FILE__,__LINE__,q,x) +#define pullupm(q,x) deb_pullupm(__FILE__,__LINE__,(q),(x)) mblk_t *deb_pullupm (const char *deb_file, unsigned int deb_line, mblk_t * mb, short what); -#define putctlx(q,t) deb_putctlx(__FILE__,__LINE__,q,t) -#define putctlx1(q,t,p) deb_putctlx1(__FILE__,__LINE__,q,t,p) +#define putctlx(q,t) deb_putctlx(__FILE__,__LINE__,(q),(t)) +#define putctlx1(q,t,p) deb_putctlx1(__FILE__,__LINE__,(q),(t),(p)) int deb_putctlx (const char *deb_file, unsigned int deb_line, queue_t * q, char type); int deb_putctlx1 (const char *deb_file, unsigned int deb_line, queue_t * q, char type, streamchar msg); -#define putbqf(q,m) deb_putbqf(__FILE__,__LINE__,q,m) +#define putbqf(q,m) deb_putbqf(__FILE__,__LINE__,(q),(m)) void deb_putbqf (const char *deb_file, unsigned int deb_line, queue_t * q, mblk_t *mb); #endif /* CONFIG_DEBUG_STREAMS */ @@ -112,18 +112,23 @@ int m_getlx (mblk_t * mb, ulong_t * id); int m_geti (mblk_t * mb, long *id); int m_getx (mblk_t * mb, ulong_t * id); int m_getstr (mblk_t * mb, char *str, int maxlen); +int m_getstrlen (mblk_t * mb); int m_getc (mblk_t * mb, char *c); int m_gethex (mblk_t *mb, uchar_t *data, int len); int m_gethexlen (mblk_t *mb); + #ifdef CONFIG_DEBUG_STREAMS void deb_m_reply (const char*, unsigned int, queue_t * q, mblk_t * mb, int err); -#define m_reply(a,b,c) deb_m_reply(__FILE__,__LINE__,a,b,c) +#define m_reply(a,b,c) deb_m_reply(__FILE__,__LINE__,(a),(b),(c)) void deb_md_reply (const char*, unsigned int, queue_t * q, mblk_t * mb, int err); -#define md_reply(a,b,c) deb_md_reply(__FILE__,__LINE__,a,b,c) +#define md_reply(a,b,c) deb_md_reply(__FILE__,__LINE__,(a),(b),(c)) +mblk_t * deb_make_reply (const char*, unsigned int, int err); +#define make_reply(a) deb_make_reply(__FILE__,__LINE__,(a)) #else void m_reply (queue_t * q, mblk_t * mb, int err); void md_reply (queue_t * q, mblk_t * mb, int err); +mblk_t * make_reply (int err); #endif #endif /* _STREAMLIB_H */ diff --git a/include/streams.h b/include/streams.h index cef2397..0996fa8 100644 --- a/include/streams.h +++ b/include/streams.h @@ -90,9 +90,16 @@ mblk_t *allocsb (ushort_t size, streamchar *data); void modregister (struct streamtab *info); struct xstream *stropen (int flag); void strclose (struct xstream *xp, int flag); -int strread (struct xstream *xp, streamchar *data, int *len, int usehq); -int strwrite (struct xstream *xp, streamchar *data, int *len, int usehq); +int strread (struct xstream *xp, streamchar *data, int len, int usehq); +#ifdef CONFIG_DEBUG_STREAMS +#define strwrite(a,b,c,d) deb_strwrite(__FILE__,__LINE__,(a),(b),(c),(d)) +int deb_strwrite (const char *deb_file,unsigned int deb_line, struct xstream *xp, streamchar *data, int len, int usehq); +#define strwritev(a,b,c,d) deb_strwritev(__FILE__,__LINE__,(a),(b),(c),(d)) +int deb_strwritev (const char *deb_file,unsigned int deb_line, struct xstream *xp, struct iovec *iov, int iovlen, int usehq); +#else +int strwrite (struct xstream *xp, streamchar *data, int len, int usehq); int strwritev (struct xstream *xp, struct iovec *iov, int iovlen, int usehq); +#endif int strioctl (struct xstream *xp, long cmd, long arg); #endif /* KERNEL */ diff --git a/include/vanj.h b/include/vanj.h index e1d13cc..fa5a697 100644 --- a/include/vanj.h +++ b/include/vanj.h @@ -12,4 +12,6 @@ #define VANJ_PPP CHAR2('p','p') /* turn on PPP mode */ #define VANJ_NORM CHAR2('n','p') /* turn off PPP mode */ +#define VANJ_SIZES CHAR2('s','b') /* length of TX and TX queues */ + #endif /* __VAN_J */ diff --git a/ip_mon/Makefile b/ip_mon/Makefile index c741cbe..b4b4b71 100644 --- a/ip_mon/Makefile +++ b/ip_mon/Makefile @@ -1,63 +1,6 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 +SUBDIRS=tools -## =()@>()= -CCU = gcc -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@ -I../include >()= -DEFSN = -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -I../include -## =()@ $(DEFSN)>()= -CFLAGSN = -O2 -Wall $(DEFSN) -## =()@>()= -LIBS = -lbsd -## =()@>()= -LDFLAGS = -v - -## =()@>()= -SYS = linux - -SOURCES = ip_mon.c monitor.c - -OBJ = ip_mon.o monitor.o -ALL = monitor - -all: ip_mon.o -prog: monitor - -monitor: monitor.o - $(CCU) $(LDFLAGS) -o monitor monitor.o $(LIBS) -monitor.o: monitor.c - $(CCU) $(CFLAGSN) -c monitor.c - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -clean: - rm -f $(OBJ) $(ALL) monitor.old - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - insmod ip_mon.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/ip_mon/ip_mon.c b/ip_mon/ip_mon.c index 4b7c0f7..c853f01 100644 --- a/ip_mon/ip_mon.c +++ b/ip_mon/ip_mon.c @@ -50,7 +50,7 @@ struct streamtab ip_mon2info = {&ip_mon_rinit, &ip_mon_winit, NULL, NULL}; #define NIP_MON 8 -#define NIP_INFO 40 +#define NIP_INFO 50 struct _ip_mon { queue_t *qptr; @@ -348,7 +348,7 @@ static mblk_t *count_packet (struct _ip_mon *ipmon, mblk_t *mp, char doswap) return mp; /* oh well -- don't count it */ } ms = splstr(); - ipp = (struct ip *) (mq->b_rptr+ipmon->encap ? 2 : 0); + ipp = (struct ip *) (mq->b_rptr+(ipmon->encap ? 2 : 0)); switch (ipp->ip_p) { default: @@ -361,7 +361,7 @@ static mblk_t *count_packet (struct _ip_mon *ipmon, mblk_t *mp, char doswap) struct tcphdr *tcp; mq = mp; - ipp = (struct ip *) (mq->b_rptr+ipmon->encap ? 2 : 0); + ipp = (struct ip *) (mq->b_rptr+(ipmon->encap ? 2 : 0)); tcp = (struct tcphdr *) (((char *)ipp) + (ipp->ip_hl << 2)); localp = tcp->th_sport; remotep = tcp->th_dport; @@ -375,7 +375,7 @@ static mblk_t *count_packet (struct _ip_mon *ipmon, mblk_t *mp, char doswap) struct udphdr *udp; mq = mp; - ipp = (struct ip *) (mq->b_rptr+ipmon->encap ? 2 : 0); + ipp = (struct ip *) (mq->b_rptr+(ipmon->encap ? 2 : 0)); udp = (struct udphdr *) (((char *)ipp) + (ipp->ip_hl << 2)); localp = udp->uh_sport; remotep = udp->uh_dport; @@ -388,7 +388,7 @@ static mblk_t *count_packet (struct _ip_mon *ipmon, mblk_t *mp, char doswap) struct icmp *icm; mq = mp; - ipp = (struct ip *) (mq->b_rptr+ipmon->encap ? 2 : 0); + ipp = (struct ip *) (mq->b_rptr+(ipmon->encap ? 2 : 0)); icm = (struct icmp *) (((char *)ipp) + (ipp->ip_hl << 2)); if(doswap) { localp = htons(icm->icmp_code); diff --git a/ip_mon/tools/Makefile b/ip_mon/tools/Makefile new file mode 100644 index 0000000..7951cf2 --- /dev/null +++ b/ip_mon/tools/Makefile @@ -0,0 +1,6 @@ +PROGRAMS = monitor +EXTRA_INCLUDES=-I.. + +TOPDIR=../.. +include $(TOPDIR)/Make.rules + diff --git a/ip_mon/monitor.c b/ip_mon/tools/monitor.c similarity index 93% rename from ip_mon/monitor.c rename to ip_mon/tools/monitor.c index dddfe45..b23f7d1 100644 --- a/ip_mon/monitor.c +++ b/ip_mon/tools/monitor.c @@ -16,10 +16,12 @@ #include "ip_mon.h" #include #include +#include #include #ifdef linux #include #endif +#include #if 0 #define FD_SETSIZE (sizeof(fd_set) * 8) @@ -76,6 +78,9 @@ set_inval (unsigned long inv) next_inval = 0; } +int tostr (char *bf, struct _monitor *mon); +int tomon (char *bf, struct _monitor *mon); + int main (int argc, char *argv[]) { int c; @@ -145,7 +150,7 @@ int main (int argc, char *argv[]) openlog (progname, LOG_PID, LOG_USER); if(logtime) - printf("*%ld\n",lastpri = time(NULL)); + printf("*%d\n",lastpri = time(NULL)); #ifdef linux { FILE * fd; @@ -174,8 +179,6 @@ int main (int argc, char *argv[]) if(monitordev == 0) syslog(LOG_CRIT, "No IP monitor driver found!"); else { - int i; - unlink(IP_MON_NAME); mknod (IP_MON_NAME, S_IFCHR | S_IRUSR | S_IWUSR, MKDEV(monitordev,0)); syslog(LOG_DEBUG,"ISDN: monitor: major number %d\n",monitordev); @@ -266,7 +269,7 @@ int main (int argc, char *argv[]) int tomon (char *bf, struct _monitor *mon) { - struct sockaddr_in server; + /* struct sockaddr_in server; */ struct hostent *hp, *gethostbyname (); char a[256], b[256]; @@ -305,11 +308,12 @@ void alju(int nix) { longjmp(jp,1); } int tostr (char *bf, struct _monitor *mon) { - struct sockaddr_in server; struct hostent *hp; struct protoent *proto; struct servent *serv1, *serv2; char a[256], b[256]; + static char *bfx; + bfx = bf; /* to prevent longjmp clobber */ if (mon->sofar_p == 0 && mon->sofar_b == 0) return -1; @@ -346,10 +350,10 @@ tostr (char *bf, struct _monitor *mon) alarm(0); if(logtime) { unsigned long thispri = time(NULL); - bf += sprintf(bf,"%d:",thispri-lastpri); + bfx += sprintf(bfx,"%ld:",thispri-lastpri); lastpri=thispri; } - bf += sprintf (bf, "%s %s %d %d ", a, b, mon->sofar_p, mon->sofar_b); + bfx += sprintf (bfx, "%s %s %d %ld ", a, b, mon->sofar_p, mon->sofar_b); if(!notprotocol && (proto = getprotobynumber(mon->p_protocol)) != NULL) { if((serv1 = getservbyport((mon->p_local), proto->p_name)) != NULL) strcpy(a, serv1->s_name); @@ -359,9 +363,9 @@ tostr (char *bf, struct _monitor *mon) strcpy(b, serv2->s_name); else sprintf(b,"_%u",ntohs(mon->p_remote)); - bf += sprintf (bf, "%s %s %s",proto->p_name,a,b); + bfx += sprintf (bfx, "%s %s %s",proto->p_name,a,b); } else { - bf += sprintf (bf, "_%d _%u _%u", mon->p_protocol, ntohs(mon->p_local), ntohs(mon->p_remote)); + bfx += sprintf (bfx, "_%d _%u _%u", mon->p_protocol, ntohs(mon->p_local), ntohs(mon->p_remote)); } return 0; } diff --git a/isdn_2/Makefile b/isdn_2/Makefile index de2563b..59a3139 100644 --- a/isdn_2/Makefile +++ b/isdn_2/Makefile @@ -1,48 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@>()= -RANLIB = ranlib - -## =()@>()= -SYS = linux - -SOURCES = isdn_2.c - -OBJ = isdn_2.o -ALL = ../isdn_2.a - -all: $(OBJ) $(ALL) - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -../isdn_2.a: $(OBJ) - ar r ../isdn_2.a $(OBJ) - @$(RANLIB) ../isdn_2.a - -clean: - rm -f $(OBJ) $(ALL) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - insmod isdn_2.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/isdn_2/isdn_2.c b/isdn_2/isdn_2.c index 8aa058a..fd7d391 100644 --- a/isdn_2/isdn_2.c +++ b/isdn_2/isdn_2.c @@ -10,6 +10,7 @@ #define UAREA #include "f_module.h" +#include "kernel.h" #include "primitives.h" #include "isdn_2.h" #include @@ -35,10 +36,13 @@ #include "x75lib.h" #include "smallq.h" #include "lap.h" +#include "sapi.h" #include "isdn_limits.h" #include "isdn_proto.h" #include +ushort_t hdrseq = 1; + extern void log_printmsg (void *log, const char *text, mblk_t * mp, const char*); extern void logh_printmsg (void *log, const char *text, mblk_t * mp); @@ -135,10 +139,17 @@ static int D_send (isdn2_state state, char cmd, mblk_t * data); static int D_recv (isdn2_state state, char isUI, mblk_t * data); static int D_backenable (isdn2_state state); +#ifdef CONFIG_DEBUG_ISDN +#define D_L1_up(a) deb_D_L1_up(__FILE__,__LINE__,(a)) +static int deb_D_L1_up (const char *deb_file, unsigned int deb_line, isdn2_card card); +#define D_L1_down(a) deb_D_L1_down(__FILE__,__LINE__,(a)) +static int deb_D_L1_down (const char *deb_file, unsigned int deb_line, isdn2_card card); +#else static int D_L1_up (isdn2_card card); +static int D_L1_down (isdn2_card card); +#endif static void D_L1_not_up (isdn2_card card); static void D_L1_re_up (isdn2_card card); -static int D_L1_down (isdn2_card card); static void D_checkactive (isdn2_card card); static void D_takedown (isdn2_card card); @@ -168,7 +179,7 @@ D_kill_one (isdn2_state state, char ind) ch = 0; #endif if (isdn2_debug & 0x10) - printf ("D_kill_one %x %p %d\n", state->SAPI, state, ind); + printf ("%sD_kill_one %x %p %d\n",KERN_DEBUG, state->SAPI, state, ind); /* Unhook the state info from the card's chain */ @@ -223,9 +234,9 @@ D_kill_all (isdn2_card card, char ind) if (isdn2_debug & 0x10) { #ifdef CONFIG_DEBUG_ISDN - printf ("D_kill_all %s:%d %d:%d\n", deb_file,deb_line, card->nr, ind); + printf ("%sD_kill_all %s:%d %d:%d\n",KERN_DEBUG, deb_file,deb_line, card->nr, ind); #else - printf ("D_kill_all %d:%d\n", card->nr, ind); + printf ("%sD_kill_all %d:%d\n",KERN_DEBUG, card->nr, ind); #endif } if (ind == 0) { @@ -329,7 +340,7 @@ D_register (isdn2_card card, uchar_t SAPI, uchar_t ch, uchar_t broadcast) int ms = splstr (); if (isdn2_debug & 0x40) - printf ("D_register %d %x/%x\n", + printf ("%sD_register %d %x/%x\n",KERN_DEBUG, card->nr, SAPI,card->TEI[ch]); /* Check if this SAPI is in use. */ @@ -341,7 +352,7 @@ D_register (isdn2_card card, uchar_t SAPI, uchar_t ch, uchar_t broadcast) if (state->SAPI == SAPI) { splx (ms); if (isdn2_debug & 0x10) - printf ("D_register: State table already present for %d:%x/%x\n", + printf ("%sD_register: State table already present for %d:%x/%x\n",KERN_DEBUG, card->nr, SAPI, card->TEI[ch]); return -EEXIST; } @@ -351,7 +362,7 @@ D_register (isdn2_card card, uchar_t SAPI, uchar_t ch, uchar_t broadcast) if (state == NULL) { splx (ms); if (isdn2_debug & 0x10) - printf ("D_register: No state table free for %d:%x/%x\n", + printf ("%sD_register: No state table free for %d:%x/%x\n",KERN_DEBUG, card->nr, SAPI, card->TEI[ch]); return -ENOMEM; } @@ -409,10 +420,10 @@ D_state (isdn2_state state, uchar_t ind, short add) ch = 0; #endif if (isdn2_debug & 0x40) - printf ("D_state %d %x:%x\n", state->card->nr, ind, add); + printf ("%sD_state %d %x:%x\n",KERN_DEBUG, state->card->nr, ind, add); if (ind == MDL_ERROR_IND) { if(add & (ERR_C | ERR_D | ERR_G /* | ERR_H */ )) { - printf("\nISDN Fatal Error, TEI cleared\n"); + printf("%s\nISDN Fatal Error, TEI cleared\n",KERN_DEBUG); state->card->TEI[ch] = TEI_BROADCAST; } } @@ -421,7 +432,7 @@ D_state (isdn2_state state, uchar_t ind, short add) if (mb == NULL) { if (isdn2_debug & 0x10) - printf ("D_state: nomem to send ind %x:%x for %d:%x/%x\n", ind, add, + printf ("%sD_state: nomem to send ind %x:%x for %d:%x/%x\n",KERN_DEBUG, ind, add, state->card->nr, state->SAPI, state->card->TEI[ch]); return -ENOMEM; } @@ -430,6 +441,7 @@ D_state (isdn2_state state, uchar_t ind, short add) case DL_ESTABLISH_IND: case DL_ESTABLISH_CONF: hdr->key = HDR_OPENPROT; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_openprot.card = state->card->nr; hdr->hdr_openprot.SAPI = state->SAPI; #ifdef DO_MULTI_TEI @@ -440,6 +452,7 @@ D_state (isdn2_state state, uchar_t ind, short add) case DL_RELEASE_IND: case DL_RELEASE_CONF: hdr->key = HDR_CLOSEPROT; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_closeprot.card = state->card->nr; hdr->hdr_closeprot.SAPI = state->SAPI; hdr->hdr_closeprot.ind = ind; @@ -450,6 +463,7 @@ D_state (isdn2_state state, uchar_t ind, short add) break; default: hdr->key = HDR_NOTIFY; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_notify.card = state->card->nr; hdr->hdr_notify.SAPI = state->SAPI; #ifdef DO_MULTI_TEI @@ -520,9 +534,9 @@ set_card_status (isdn2_card card, enum C_state status) *(unsigned long *)cid = card->id; cid[4]='\0'; #ifdef CONFIG_DEBUG_ISDN - printf ("!!! Card %4s = %s at %s %d\n", cid, sta, deb_file,deb_line); + printf ("%s!!! Card %4s = %s at %s %d\n",KERN_DEBUG, cid, sta, deb_file,deb_line); #else - printf ("!!! Card %4s = %s\n", cid, sta); + printf ("%s!!! Card %4s = %s\n",KERN_DEBUG, cid, sta); #endif } switch(card->status) { @@ -605,11 +619,11 @@ D_L1_not_up (isdn2_card card) return; card->timeup = 0; if(card->status != C_await_up) { - printf("D_L1_not_up called at wrong time! S %d\n",card->status); + printf("%sD_L1_not_up called at wrong time! S %d\n",KERN_DEBUG,card->status); return; } if (isdn2_debug & 0x10) - printf ("isdn: Card %d: Disconnected??\n", card->nr); + printf ("%sisdn: Card %d: Disconnected??\n",KERN_DEBUG, card->nr); if(!card->offline) D_kill_all (card, PH_DISCONNECT_IND); set_card_status (card, C_wont_up); @@ -620,11 +634,12 @@ D_L1_not_up (isdn2_card card) mb = allocb (sizeof (struct _isdn23_hdr), BPRI_HI); if (mb == NULL) { if (isdn2_debug & 0x10) - printf ("D_L1_not_up: no memory\n"); + printf ("%sD_L1_not_up: no memory\n",KERN_DEBUG); return; } hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_NOCARD; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_nocard.card = card->nr; if (isdn_chan.qptr != NULL) { if(isdn2_debug & 0x2000) logh_printmsg (NULL, "Up", mb); @@ -641,18 +656,26 @@ D_L1_not_up (isdn2_card card) * Upper level wants to send data -- (re)start L1. */ static int +#ifdef CONFIG_DEBUG_ISDN +deb_D_L1_up (const char *deb_file, unsigned int deb_line, isdn2_card card) +#else D_L1_up (isdn2_card card) +#endif { if (isdn2_debug & 0x48) - printf ("D_L1_up %d: S was %d\n", card->nr,card->status); + printf ("%sD_L1_up %d: S was %d\n",KERN_DEBUG, card->nr,card->status); if (card->card == NULL) { if (isdn2_debug & 0x10) - printf ("D_L1_up: Card %d not registered\n", card->nr); + printf ("%sD_L1_up: Card %d not registered\n",KERN_DEBUG, card->nr); return -ENXIO; } switch (card->status) { case C_await_up: +#ifdef CONFIG_DEBUG_ISDN + deb_set_card_status (deb_file,deb_line, card, C_await_up); /* Re-set the timeout */ +#else set_card_status (card, C_await_up); /* Re-set the timeout */ +#endif break; case C_up: case C_lock_up: @@ -662,11 +685,12 @@ D_L1_up (isdn2_card card) case C_await_down: case C_down: case C_wont_down: - if(card->card->modes & CHM_INTELLIGENT) { - set_card_status (card, C_up); - isdn2_new_state(card->card,1); - } else { + if(!(card->card->modes & CHM_INTELLIGENT)) { +#ifdef CONFIG_DEBUG_ISDN + deb_set_card_status (deb_file,deb_line, card, C_await_up); +#else set_card_status (card, C_await_up); +#endif (*card->card->ch_mode) (card->card, 0, M_HDLC, 0); } break; @@ -680,17 +704,21 @@ D_L1_up (isdn2_card card) * connections for a few seconds. */ static int +#ifdef CONFIG_DEBUG_ISDN +deb_D_L1_down (const char *deb_file, unsigned int deb_line, isdn2_card card) +#else D_L1_down (isdn2_card card) +#endif { if (isdn2_debug & 0x40) - printf ("D_L1_down %d\n", card->nr); + printf ("%sD_L1_down %d\n",KERN_DEBUG, card->nr); if (card->card == NULL) { if (isdn2_debug & 0x10) - printf ("D_L1_down: Card %d not registered\n", card->nr); + printf ("%sD_L1_down: Card %d not registered\n",KERN_DEBUG, card->nr); return -ENXIO; } if (isdn2_debug & 0x10) - printf ("D_L1_Down: State was %d\n", card->status); + printf ("%sD_L1_Down: State was %d\n",KERN_DEBUG, card->status); switch (card->status) { case C_await_down: case C_down: @@ -701,7 +729,11 @@ D_L1_down (isdn2_card card) case C_lock_up: break; case C_await_up: +#ifdef CONFIG_DEBUG_ISDN + deb_set_card_status (deb_file,deb_line, card, C_down); +#else set_card_status (card, C_down); +#endif if (isdn_chan.qptr != NULL) (*card->card->ch_mode) (card->card, 0, M_STANDBY, 1); else @@ -709,13 +741,26 @@ D_L1_down (isdn2_card card) break; case C_up: if (isdn_chan.qptr != NULL) { - if(card->card->modes & CHM_INTELLIGENT) + if(card->card->modes & CHM_INTELLIGENT) { +#ifdef CONFIG_DEBUG_ISDN + deb_set_card_status(deb_file,deb_line, card, C_down); +#else set_card_status(card, C_down); - else +#endif + } else { +#ifdef CONFIG_DEBUG_ISDN + deb_set_card_status (deb_file,deb_line, card, C_await_down); +#else set_card_status (card, C_await_down); +#endif + } (*card->card->ch_mode) (card->card, 0, M_STANDBY, 1); } else { +#ifdef CONFIG_DEBUG_ISDN + deb_set_card_status (deb_file,deb_line, card, C_down); +#else set_card_status (card, C_down); +#endif (*card->card->ch_mode) (card->card, 0, M_OFF, 0); } break; @@ -731,7 +776,7 @@ static int D_backenable (isdn2_state state) { if (isdn2_debug & 0x40) - printf ("D_backenable %p\n", state); + printf ("%sD_backenable %p\n",KERN_DEBUG, state); if (isdn_chan.qptr != NULL) qenable (WR (isdn_chan.qptr)); return 0; @@ -744,10 +789,10 @@ static int D_canrecv (isdn2_state state) { if (isdn2_debug & 0x40) - printf ("D_canrecv %d ", state->card->nr); + printf ("%sD_canrecv %d ",KERN_DEBUG, state->card->nr); if (isdn_chan.qptr == 0 || isdn_chan.qptr->q_next == NULL) { #ifdef CONFIG_DEBUG_ISDN - printf("-NoStream"); + printf("%s-NoStream",KERN_DEBUG); #endif return 0; } else @@ -756,6 +801,9 @@ D_canrecv (isdn2_state state) /* * Send data upstream. Called from X75. + * + * If used for an intelligent card, state is NULL and isUI denotes the + * card. */ static int D_recv (isdn2_state state, char isUI, mblk_t * mb) @@ -768,17 +816,18 @@ D_recv (isdn2_state state, char isUI, mblk_t * mb) return 0; #endif if (isdn2_debug & 0x40) - printf ("D_recv %d %d %d\n", state->card->nr, msgdsize(mb), isUI); + printf ("%sD_recv %d %d %d\n",KERN_DEBUG, state->card->nr, msgdsize(mb), isUI); mb2 = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb2 == NULL) { if (isdn2_debug & 0x10) - printf ("D_recv: no mblk for header\n"); + printf ("%sD_recv: no mblk for header\n",KERN_DEBUG); return -ENOMEM; } hdr = ((isdn23_hdr) mb2->b_wptr)++; if (isUI) { hdr->key = HDR_UIDATA; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_uidata.card = state->card->nr; hdr->hdr_uidata.SAPI = state->SAPI; #ifdef DO_MULTI_TEI @@ -788,6 +837,7 @@ D_recv (isdn2_state state, char isUI, mblk_t * mb) hdr->hdr_uidata.broadcast = (isUI & 2); } else { hdr->key = HDR_DATA; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_data.card = state->card->nr; hdr->hdr_data.SAPI = state->SAPI; #ifdef DO_MULTI_TEI @@ -822,13 +872,11 @@ D_send (isdn2_state state, char cmd, mblk_t * mb) if(msgdsize(mb) < 0) return 0; #endif -#if 0 if (isdn2_debug & 0x40) - printf ("D_send %d %d %d %d\n", state->card->nr, state->card->status, msgdsize(mb), cmd); -#endif + printf ("%sD_send %d %d %d %d\n",KERN_DEBUG, state->card->nr, state->card->status, msgdsize(mb), cmd); if ((crd = state->card->card) == NULL) { if (isdn2_debug & 0x10) - printf (" -- no card\n"); + printf ("%s -- no card\n",KERN_DEBUG); return -ENXIO; } #ifdef DO_MULTI_TEI @@ -838,17 +886,17 @@ D_send (isdn2_state state, char cmd, mblk_t * mb) #endif if (state->card->status != C_up && state->card->status != C_lock_up) { if (isdn2_debug & 0x10) - printf ("D_send: %d:%x/%x sending, state %d\n", state->card->nr, + printf ("%sD_send: %d:%x/%x sending, state %d\n",KERN_DEBUG, state->card->nr, state->SAPI, state->card->TEI[ch], state->card->status); if (isdn2_debug & 0x10) - printf (" -- card down\n"); + printf ("%s -- card down 1\n",KERN_DEBUG); if ((err = D_L1_up (state->card)) == 0) err = -EAGAIN; return err; } if (!(*crd->cansend) (crd, 0)) { if (isdn2_debug & 0x10) - printf (" -- can't send\n"); + printf ("%s -- can't send\n",KERN_DEBUG); return -EAGAIN; } @@ -858,15 +906,16 @@ D_send (isdn2_state state, char cmd, mblk_t * mb) isdn23_hdr hdr; if (isdn2_debug & 0x10) - printf ("D_send: %d:%x/NO_TEI\n", state->card->nr, state->SAPI); + printf ("%sD_send: %d:%x/NO_TEI\n",KERN_DEBUG, state->card->nr, state->SAPI); if ((mp = allocb (sizeof (struct _isdn23_hdr), BPRI_MED)) == NULL) { if (isdn2_debug & 0x10) - printf ("D_recv: no mblk for TEIreq\n"); + printf ("%sD_recv: no mblk for TEIreq\n",KERN_DEBUG); return -EAGAIN; } hdr = ((isdn23_hdr) mp->b_wptr)++; hdr->key = HDR_TEI; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_tei.card = state->card->nr; hdr->hdr_tei.TEI = state->card->TEI[ch]; #ifdef DO_MULTI_TEI @@ -887,11 +936,13 @@ D_send (isdn2_state state, char cmd, mblk_t * mb) /* * If there's room in front, don't bother with a new mblk. */ - if (DATA_START(mb) + 2 <= mb->b_rptr && DATA_REFS(mb) == 1) { + if(crd->modes & CHM_INTELLIGENT) + err = (*crd->send)(crd,0,mb); + else if (DATA_START(mb) + 2 <= mb->b_rptr && DATA_REFS(mb) == 1) { *--mb->b_rptr = (((cmd & 2) ? TEI_BROADCAST : state->card->TEI[ch]) << 1) | 1; *--mb->b_rptr = (state->SAPI << 2) | ((cmd & 1) ? 0 : 2); if(mod2 & 0x20) { - printf (KERN_DEBUG "*** %d", state->card->nr); + printf ("%s*** %d", KERN_DEBUG,state->card->nr); log_printmsg (NULL, " Send", mb, KERN_DEBUG); } if ((err = (*crd->send) (crd, 0, mb)) != 0) @@ -901,14 +952,14 @@ D_send (isdn2_state state, char cmd, mblk_t * mb) if (mb2 == NULL) { if (isdn2_debug & 0x10) - printf ("D_send: No mem to send %s to %d:%x/%x\n", cmd ? "Cmd" : "Resp", state->card->nr, state->SAPI, state->card->TEI[ch]); + printf ("%sD_send: No mem to send %s to %d:%x/%x\n",KERN_DEBUG, cmd ? "Cmd" : "Resp", state->card->nr, state->SAPI, state->card->TEI[ch]); return -ENOMEM; } *mb2->b_wptr++ = (state->SAPI << 2) | ((cmd & 1) ? 0 : 2); *mb2->b_wptr++ = (((cmd & 2) ? TEI_BROADCAST : state->card->TEI[ch]) << 1) | 1; linkb (mb2, mb); if(mod2 & 0x20) { - printf (KERN_DEBUG "*** %d", state->card->nr); + printf ("%s*** %d", KERN_DEBUG,state->card->nr); log_printmsg (NULL, " Send", mb2, KERN_DEBUG); } if ((err = (*crd->send) (crd, 0, mb2)) != 0) @@ -916,7 +967,7 @@ D_send (isdn2_state state, char cmd, mblk_t * mb) } D_checkactive(state->card); if(err != 0) - printf("D_Send Err %d ",err); + printf("%sD_Send Err %d ",KERN_DEBUG,err); return err; } @@ -929,21 +980,23 @@ D_cansend (isdn2_state state) struct _isdn1_card *crd; if (isdn2_debug & 0x40) - printf ("D_cansend %d %d\n", state->card->nr, state->card->status); + printf ("%sD_cansend %d %d\n", KERN_DEBUG,state->card->nr, state->card->status); if ((crd = state->card->card) == NULL) { if (isdn2_debug & 0x10) - printf (" -- card NULL\n"); + printf ("%s -- card NULL\n",KERN_DEBUG); return 0; } + if(!(state->card->card->modes & CHM_INTELLIGENT)) { if (state->card->status != C_up && state->card->status != C_lock_up) { if (isdn2_debug & 0x10) - printf (" -- card down\n"); + printf ("%s -- card down 2\n",KERN_DEBUG); (void) D_L1_up (state->card); return 0; /* Yet. */ } + } if (!(*crd->cansend) (crd, 0)) { if (isdn2_debug & 0x10) - printf (" -- card busy\n"); + printf ("%s -- card busy\n",KERN_DEBUG); return 0; } return 1; @@ -959,18 +1012,18 @@ D__findstate (isdn2_card card, uchar_t SAPI, uchar_t ch) if(card->card->modes & CHM_INTELLIGENT) return state; - if(isdn2_debug&0x900) printf("D_findstate %d:%x/%x:",card->nr,SAPI,card->TEI[ch]); + if(isdn2_debug&0x900) printf("%sD_findstate %d:%x/%x:",KERN_DEBUG,card->nr,SAPI,card->TEI[ch]); while (state != NULL) { - if(isdn2_debug&0x900) printf("_%x",state->SAPI); + if(isdn2_debug&0x900) printf("%s_%x",KERN_DEBUG,state->SAPI); if (state->SAPI == SAPI) break; state = state->next; } if (state == NULL) { if ((isdn2_debug&0x910) == 0x10) - printf("D_findstate %d:%x/%x:",card->nr,SAPI,card->TEI[ch]); + printf("%sD_findstate %d:%x/%x:",KERN_DEBUG,card->nr,SAPI,card->TEI[ch]); if (isdn2_debug & 0x900) - printf (" not found\n"); + printf ("%s not found\n",KERN_DEBUG); } return state; } @@ -991,7 +1044,7 @@ isdn2_register (struct _isdn1_card *card, long id) uchar_t nr, found_nr; if (isdn2_debug & 0x10) - printf ("isdn2_register %p %lx\n", card, id); + printf ("%sisdn2_register %p %lx\n",KERN_DEBUG, card, id); nr = 0; do { nr++; @@ -1000,7 +1053,7 @@ isdn2_register (struct _isdn1_card *card, long id) if (crd->id == id) { splx (ms); if (isdn2_debug & 0x10) - printf ("ISDN register: ID %lx already registered as %d\n", id, crd->nr); + printf ("%sISDN register: ID %lx already registered as %d\n",KERN_DEBUG, id, crd->nr); return -EEXIST; } if (crd->nr == nr) { @@ -1012,7 +1065,7 @@ isdn2_register (struct _isdn1_card *card, long id) crd = malloc(sizeof(*crd)); if (crd == NULL) { if (isdn2_debug & 0x10) - printf ("isdn2_register: no free card store\n"); + printf ("%sisdn2_register: no free card store\n",KERN_DEBUG); splx (ms); return -EBUSY; } @@ -1049,19 +1102,19 @@ isdn2_unregister (struct _isdn1_card *card) isdn2_card *pcrd = &isdn_card; if (isdn2_debug & 0x10) - printf ("isdn2_unregister %p, 2 is %p\n", card,card->ctl); + printf ("%sisdn2_unregister %p, 2 is %p\n",KERN_DEBUG, card,card->ctl); crd = (isdn2_card) card->ctl; if (crd == NULL) { splx (ms); if (isdn2_debug & 0x10) - printf ("isdn2_unregister: card not registered\n"); + printf ("%sisdn2_unregister: card not registered\n",KERN_DEBUG); return -ENODEV; } while(*pcrd != NULL && *pcrd != crd) pcrd = &(*pcrd)->next; if (*pcrd == NULL) { splx (ms); - printf ("isdn2_unregister: card chain broken\n"); + printf ("%sisdn2_unregister: card chain broken\n",KERN_DEBUG); return -EIO; } set_card_status(crd,C_down); @@ -1072,11 +1125,12 @@ isdn2_unregister (struct _isdn1_card *card) if (mb == NULL) { if (isdn2_debug & 0x10) - printf ("isdn2_unregister: no memory\n"); + printf ("%sisdn2_unregister: no memory\n",KERN_DEBUG); return -ENOMEM; } hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_NOCARD; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_nocard.card = crd->nr; if (isdn_chan.qptr != NULL) { if(isdn2_debug & 0x2000) logh_printmsg (NULL, "Up", mb); @@ -1106,7 +1160,7 @@ isdn2_new_state (struct _isdn1_card *card, char state) return /* ENXIO */ ; if (isdn2_debug & 0x40) - printf ("isdn2_new_state %d %d %d\n", ctl->nr, ctl->status, state); + printf ("%sisdn2_new_state %d %d %d\n",KERN_DEBUG, ctl->nr, ctl->status, state); mb = allocb (sizeof (struct _isdn23_hdr), BPRI_HI); @@ -1114,11 +1168,12 @@ isdn2_new_state (struct _isdn1_card *card, char state) if (state == 0) D_kill_all (ctl, PH_DEACTIVATE_IND); if (isdn2_debug & 0x10) - printf ("New_State: No hdr mem for %d\n", ctl->nr); + printf ("%sNew_State: No hdr mem for %d\n",KERN_DEBUG, ctl->nr); return /* ENOMEM */ ; } hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_NOTIFY; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_notify.card = ctl->nr; hdr->hdr_notify.SAPI = SAPI_INVALID; /* all */ if (state == 2) { /* Card is bouncing */ @@ -1193,6 +1248,9 @@ isdn2_new_state (struct _isdn1_card *card, char state) /* FALL THRU */ case C_await_down: /* Oops, bus doesn't want to go down. * Continue to listen for incoming frames. */ + if(ctl->card->modes & CHM_INTELLIGENT) + set_card_status (ctl, C_up); + else set_card_status (ctl, C_wont_down); /* (*card->ch_mode) (card, 0, M_HDLC, 1); */ hdr->hdr_notify.ind = PH_ACTIVATE_NOTE; @@ -1227,7 +1285,7 @@ isdn2_chprot (struct _isdn1_card *card, short channel, mblk_t * proto, int flags isdn2_card ctl; if (isdn2_debug & 0x80) - printf ("isdn2_new_proto %p %p %d 0%o\n", card, proto, channel, flags); + printf ("%sisdn2_new_proto %p %p %d 0%o\n",KERN_DEBUG, card, proto, channel, flags); ctl = (isdn2_card) card->ctl; if (ctl == NULL || (channel == 0 && isdn_chan.qptr == NULL)) return -ENXIO; @@ -1239,11 +1297,12 @@ isdn2_chprot (struct _isdn1_card *card, short channel, mblk_t * proto, int flags if (mb == NULL) { if (isdn2_debug & 0x10) - printf ("isdn2_data for %d: No rawhdr mem\n", ctl->nr); + printf ("%sisdn2_data for %d: No rawhdr mem\n",KERN_DEBUG, ctl->nr); return -ENOMEM; } hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_PROTOCMD; + hdr->seqnum = hdrseq; hdrseq += 2; if (channel == 0) /* D channel is always ready... */ hdr->hdr_protocmd.minor = 0; else { @@ -1324,13 +1383,20 @@ isdn2_recv (struct _isdn1_card *card, short channel, mblk_t * data) return 0; #endif if(mod2 & 0x10) { - printf (KERN_DEBUG "*** %d", ctl->nr); + printf ("%s*** %d", KERN_DEBUG,ctl->nr); log_printmsg (NULL, " Recv", data, KERN_DEBUG); } (void)msgdsize(data); + if (card->modes & CHM_INTELLIGENT) { + state = ctl->state[0]; + if(state != NULL) + err = D_recv(state,0,data); + else + err = -ENXIO; + } else { if (ctl->status != C_up && ctl->status != C_wont_down) { if(isdn2_debug & 0x80) - printf(" -- L1 up\n"); + printf("%s -- L1 up\n",KERN_DEBUG); (void) D_L1_up (ctl); } @@ -1341,7 +1407,7 @@ isdn2_recv (struct _isdn1_card *card, short channel, mblk_t * data) x1 = SAPI = *data->b_rptr++; if (SAPI & 0x01) { /* TODO: X25 packet? */ if (isdn2_debug & 0x10) - printf ("isdn2_data %d: SAPI %x invalid\n", ctl->nr, SAPI); + printf ("%sisdn2_data %d: SAPI %x invalid\n",KERN_DEBUG, ctl->nr, SAPI); freemsg (data); return 0 /* ESRCH */ ; } @@ -1351,7 +1417,7 @@ isdn2_recv (struct _isdn1_card *card, short channel, mblk_t * data) x2 = TEI = *data->b_rptr++; if ((TEI & 0x01) == 0) { if (isdn2_debug & 0x10) - printf ("isdn2_data %d: TEI %x invalid\n", ctl->nr, TEI); + printf ("%sisdn2_data %d: TEI %x invalid\n",KERN_DEBUG, ctl->nr, TEI); goto rawdata; } cmd = (SAPI & 0x02) ? 1 : 0; @@ -1363,7 +1429,7 @@ isdn2_recv (struct _isdn1_card *card, short channel, mblk_t * data) } if(ch > N_TEI) { if (isdn2_debug & 0x100) - printf("isdn2_data %d: %02x: not my TEI (%02x)\n",ctl->nr,TEI,ctl->TEI[0]); + printf("%sisdn2_data %d: %02x: not my TEI (%02x)\n",KERN_DEBUG,ctl->nr,TEI,ctl->TEI[0]); freemsg (data); return 0; } @@ -1373,13 +1439,9 @@ isdn2_recv (struct _isdn1_card *card, short channel, mblk_t * data) state = D__findstate (ctl, SAPI,ch); if (state != NULL) { - if(card->modes & CHM_INTELLIGENT) { - err = D_recv(state,0,data); - } else { if (TEI == TEI_BROADCAST) cmd |= 2; err = x75_recv (&state->state, cmd, data); - } } else if (TEI == TEI_BROADCAST && isdn_chan.qptr != NULL) { isdn23_hdr hdr; mblk_t *mb; @@ -1387,13 +1449,14 @@ isdn2_recv (struct _isdn1_card *card, short channel, mblk_t * data) rawdata: if ((mb = allocb (sizeof (struct _isdn23_hdr) + 2, BPRI_HI)) == NULL) { if (isdn2_debug & 0x10) - printf ("isdn2_data for %d: No rawhdr mem\n", + printf ("%sisdn2_data for %d: No rawhdr mem\n",KERN_DEBUG, ctl->nr); freemsg (data); return 0 /* ENOMEM */ ; } hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_RAWDATA; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_rawdata.card = ctl->nr; *mb->b_wptr++ = x1; *mb->b_wptr++ = x2; @@ -1409,6 +1472,7 @@ isdn2_recv (struct _isdn1_card *card, short channel, mblk_t * data) err = 0; /* Not an error */ freemsg (data); } + } } else { /* B Channel */ isdn2_chan chn = ctl->chan[channel]; @@ -1437,7 +1501,7 @@ isdn2_backenable (struct _isdn1_card *card, short channel) if (ctl == NULL) return -ENXIO; if (isdn2_debug & 0x80) - printf ("isdn2_backenable %d %d\n", ctl->nr, channel); + printf ("%sisdn2_backenable %d %d\n",KERN_DEBUG, ctl->nr, channel); if (channel > 0 && (unsigned) channel <= ctl->card->nr_chans) { if ((chan = ctl->chan[channel]) != NULL && chan->qptr != NULL) qenable (WR (chan->qptr)); @@ -1463,7 +1527,7 @@ isdn2_backenable (struct _isdn1_card *card, short channel) int isdn2_init (void) { - printf ("ISDN library present.\n Max %d channels per card, min %d D channel connections\n", MAXCHAN, MAX_D); + printf ("%sISDN library present.\n Max %d channels per card, min %d D channel connections\n",KERN_DEBUG, MAXCHAN, MAX_D); bzero (&isdn_chan, sizeof (isdn_chan)); bzero (isdnchan, sizeof (isdnchan)); @@ -1487,12 +1551,13 @@ isdn2_sendcard (isdn2_card card) card->offline = 0; if ((mb = allocb (sizeof (struct _isdn23_hdr), BPRI_HI)) == NULL) { if (isdn2_debug & 0x10) - printf ("isdn2_sendcard: no memory\n"); + printf ("%sisdn2_sendcard: no memory\n",KERN_DEBUG); return /* ENOMEM */ ; } hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_CARD; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_card.card = card->nr; hdr->hdr_card.id = card->id; hdr->hdr_card.bchans = card->card->nr_chans; @@ -1537,7 +1602,7 @@ isdn2_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) static unsigned char nr = 0; do { dev = ++nr; } while (minor(dev) == 0); #else - printf ("isdn2_open: CLONE/MODOPEN\n"); + printf ("%sisdn2_open: CLONE/MODOPEN\n",KERN_DEBUG); ERR_RETURN(-ENXIO); #endif } @@ -1546,7 +1611,7 @@ isdn2_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) * The master driver can't be opened more than once. */ if (dev >= NPORT) { - printf ("isdn2_open: dev %d > NPORT %d\n",dev,NPORT); + printf ("%sisdn2_open: dev %d > NPORT %d\n",KERN_DEBUG,dev,NPORT); ERR_RETURN(-ENXIO); } if (dev == 0) { @@ -1561,7 +1626,7 @@ isdn2_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) if ((ch = (isdn2_chan)q->q_ptr) == NULL) { #if 0 if (!(flag & O_EXCL)) { - printf ("isdn2_open: open must be exclusive\n",dev,nport); + printf ("%sisdn2_open: open must be exclusive\n",KERN_DEBUG,dev,nport); ERR_RETURN(-ENXIO); } #endif @@ -1589,11 +1654,12 @@ isdn2_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) if (mb != NULL) { hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_OPEN; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_open.minor = dev; hdr->hdr_open.flags = flag; #ifdef __linux__ hdr->hdr_open.uid = (current->suid == 0) ? current->suid : current->uid; - if(0) printk(KERN_DEBUG "2_open:uid %d\n",hdr->hdr_open.uid); + if(0) printk("%s2_open:uid %d\n",KERN_DEBUG,hdr->hdr_open.uid); #else hdr->hdr_open.uid = u.u_uid; #endif @@ -1601,7 +1667,7 @@ isdn2_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) putnext (isdn_chan.qptr, mb); } else { if (isdn2_debug & 0x10) - printf ("isdn2_open %d: Can't notify controller: no mem\n", dev); + printf ("%sisdn2_open %d: Can't notify controller: no mem\n",KERN_DEBUG, dev); ERR_RETURN(-ENOMEM); } } @@ -1633,7 +1699,7 @@ isdn2_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) timeout (isdn2_sendcards, NULL, HZ * 2); } if (isdn2_debug & 0x10) - printf ("ISDN %d open (%p)\n", dev, q); + printf ("%sISDN %d open (%p)\n",KERN_DEBUG, dev, q); MORE_USE; return dev; } @@ -1650,7 +1716,7 @@ putproto (SUBDEV minor, ushort_t inf) mblk_t *mb; if (isdn2_debug & 0x100) - printf ("putproto %d %d\n", minor, inf); + printf ("%sputproto %d %d\n",KERN_DEBUG, minor, inf); if (minor >= NPORT) return; else if (isdnchan[minor] == NULL || (q = isdnchan[minor]->qptr) == NULL) @@ -1673,10 +1739,10 @@ isdn2_disconnect (isdn2_chan ch, uchar_t error) struct _isdn1_card *chx; if (isdn2_debug & 0x100) - printf ("isdn2_disconnect %p %d\n", ch, error); + printf ("%sisdn2_disconnect %p %d\n",KERN_DEBUG, ch, error); if (ch->status != M_free && (ch->channel > MAXCHAN)) { splx (ms); - printf ("Severe problem: isdn2_disconnect: Channel %d !?!\n", ch->channel); + printf ("%sSevere problem: isdn2_disconnect: Channel %d !?!\n",KERN_DEBUG, ch->channel); return -EFAULT; } switch (ch->status) { @@ -1688,7 +1754,7 @@ isdn2_disconnect (isdn2_chan ch, uchar_t error) case M_D_conn: if (ch->card != NULL) { if (ch->card->chan[ch->channel] != ch) - printf ("*** Chan ptr in disconnect bad! Cd %x, Ch %x, Ch->Ch %x\n", ch->dev, ch->card->nr, ch->channel); + printf ("%s*** Chan ptr in disconnect bad! Cd %x, Ch %x, Ch->Ch %x\n",KERN_DEBUG, ch->dev, ch->card->nr, ch->channel); else ch->card->chan[ch->channel] = NULL; } @@ -1706,6 +1772,7 @@ isdn2_disconnect (isdn2_chan ch, uchar_t error) if (mb != NULL) { hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_DETACH; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_detach.minor = ch->dev; hdr->hdr_detach.error = error; hdr->hdr_detach.perm = 0; @@ -1713,7 +1780,7 @@ isdn2_disconnect (isdn2_chan ch, uchar_t error) putnext (isdn_chan.qptr, mb); } else { if (isdn2_debug & 0x10) - printf ("isdn2_disconnect %d: Can't notify controller: no mem\n", ch->dev); + printf ("%sisdn2_disconnect %d: Can't notify controller: no mem\n",KERN_DEBUG, ch->dev); } } } @@ -1732,7 +1799,7 @@ isdn2_disconnect (isdn2_chan ch, uchar_t error) for (i = 1; i < NPORT; i++) if ((isdnchan[i] != NULL) && ((q = isdnchan[i]->qptr) != NULL)) { if (isdn2_debug & 0x10) - printf ("Hang 2\n"); + printf ("%sHang 2\n",KERN_DEBUG); putctlx (q, M_HANGUP); } if (isdn2_notsent) { @@ -1768,7 +1835,7 @@ isdn2_close (queue_t *q, int dummy) ch->qptr = NULL; if (isdn2_debug & 0x10) - printf ("ISDN %d: Closed.\n", ch->dev); + printf ("%sISDN %d: Closed.\n",KERN_DEBUG, ch->dev); switch (ch->status) { case M_D_ctl: case M_B_conn: @@ -1785,12 +1852,13 @@ isdn2_close (queue_t *q, int dummy) if (mb != NULL) { hdr = ((isdn23_hdr) mb->b_wptr)++; hdr->key = HDR_CLOSE; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_close.minor = ch->dev; hdr->hdr_close.error = 0; if(isdn2_debug & 0x2000) logh_printmsg (NULL, "Up", mb); putnext (isdn_chan.qptr, mb); } else if (isdn2_debug & 0x10) - printf ("isdn2_close %d: Can't notify controller: no mem\n", ch->dev); + printf ("%sisdn2_close %d: Can't notify controller: no mem\n",KERN_DEBUG, ch->dev); ch->status = M_blocked; #ifdef NEW_TIMEOUT ch->timer_unblock = @@ -1862,7 +1930,7 @@ c_qattach (struct streamtab *qinfo, queue_t * qp, int flag) WR (rq)->q_flag |= QWANTR; if ((err = (*rq->q_qinfo->qi_qopen) (rq, 0, flag, sflg)) < 0) { - printf (" :No Open %d %p", err, rq->q_qinfo->qi_qopen); + printf ("%s :No Open %d %p",KERN_DEBUG, err, rq->q_qinfo->qi_qopen); qdetach (rq, 0, 0); splx (s); return err; @@ -1891,7 +1959,7 @@ pushlist (queue_t * q, mblk_t * mp) return 0; #endif if (isdn2_debug & 0x100) - printf ("pushlist %p %p\n", q, mp); + printf ("%spushlist %p %p\n",KERN_DEBUG, q, mp); xq = q->q_next; /* for qattach */ @@ -1924,13 +1992,13 @@ pushlist (queue_t * q, mblk_t * mp) splx (ms); if (mp->b_wptr < DATA_END(mp)) *mp->b_wptr = '\0'; - printf (KERN_ERR "Q_Push: %s -- not found\n", mp->b_rptr); + printf ("%sQ_Push: %s -- not found\n", KERN_ERR,mp->b_rptr); return -ENOENT; found: if(0)printf (" %s", fm->f_name); if ((err = c_qattach (fm->f_str, xq, 0)) < 0) { splx (ms); - printf (KERN_WARNING "Q_Push: %s -- can't attach\n", fm->f_name); + printf ("%sQ_Push: %s -- can't attach\n", KERN_WARNING,fm->f_name); return err; } mp->b_rptr += i + 1; @@ -1947,7 +2015,7 @@ poplist (queue_t * q, char initial) mblk_t *mb; if (q == NULL || q->q_next == NULL) { - printf ("Err PopList NULL! %p\n", q); + printf ("%sErr PopList NULL! %p\n",KERN_DEBUG, q); return; } while (q->q_next->q_next) { @@ -1998,7 +2066,7 @@ poplist (queue_t * q, char initial) pushlist (q, mb); freeb (mb); } -else printf("POPLIST: could not alloc\n"); +else printf("%sPOPLIST: could not alloc\n",KERN_DEBUG); } /* Streams code to write data. */ @@ -2012,7 +2080,7 @@ isdn2_wput (queue_t *q, mblk_t *mp) return; #endif if (isdn2_debug & 0x100) - printf ("isdn2_wput %p.%p.%p %d of %d\n", mp,DATA_BLOCK(mp),mp->b_cont, msgdsize(mp),DATA_TYPE(mp)); + printf ("%sisdn2_wput %p.%p.%p %d of %d\n",KERN_DEBUG, mp,DATA_BLOCK(mp),mp->b_cont, msgdsize(mp),DATA_TYPE(mp)); switch (DATA_TYPE(mp)) { case M_IOCTL: DATA_TYPE(mp) = M_IOCNAK; @@ -2080,13 +2148,14 @@ h_reply (queue_t * q, isdn23_hdr hdr, short err) return 0; if (isdn2_debug & 0x100) - printf ("h_reply %p %p %d\n", q, hdr, err); + printf ("%sh_reply %p %p %d\n",KERN_DEBUG, q, hdr, err); if ((mb = allocb (2 * sizeof (struct _isdn23_hdr), BPRI_HI)) == NULL) return -ENOMEM; hd = ((isdn23_hdr) mb->b_wptr)++; hd->key = HDR_INVAL; + hd->seqnum = hdrseq; hdrseq += 2; if(err < 0) err = -err; hd->hdr_inval.error = err; @@ -2095,7 +2164,7 @@ h_reply (queue_t * q, isdn23_hdr hdr, short err) q = RD (q); #ifdef CONFIG_DEBUG_ISDN - logh__printmsg (deb_line,NULL, "Up", mb); + if(isdn2_debug & 0x2000) logh__printmsg (deb_line,NULL, "Up", mb); #else if(isdn2_debug & 0x2000) logh_printmsg (NULL, "Up", mb); #endif @@ -2122,17 +2191,13 @@ isdn2_wsrv (queue_t *q) * Actually, we don't collect anything; the stuff is just discarded. */ #define XLENHDR(_len) do { \ - if (_len <= 0) { \ - if(mp != NULL) \ - freemsg(mp); \ - h_reply(q,&hdr,EINVAL); \ - break; \ - } \ if(dsize(mp) < _len) { \ freemsg(mp); \ + printf("%s -- dsize %d, len %d\n",KERN_DEBUG,dsize(mp),_len); \ h_reply(q,&hdr,EIO); \ - break; \ + mp = NULL; goto free_it; \ }; \ + if(_len > 0) \ mp = pullupm(mp,1); \ } while(0) /**/ #define LENHDR(_who) XLENHDR(hdr.hdr_##_who.len) @@ -2146,7 +2211,7 @@ isdn2_wsrv (queue_t *q) for(crd = isdn_card; crd != NULL; crd = crd->next) \ if (crd->nr == i) break; \ if(crd == NULL) { \ - if(isdn2_debug&1)printf(" -- Card %d\n",i); \ + if(isdn2_debug&1)printf("%s -- Card %d\n",KERN_DEBUG,i); \ h_reply(q,&hdr,ENXIO); goto free_it; } \ } while(0) /**/ @@ -2155,13 +2220,13 @@ isdn2_wsrv (queue_t *q) minor = hdr.hdr_##_who.minor; \ if ((minor < 1) || (minor >= NPORT) || \ ((chan = isdnchan[minor]) == NULL) || (chan->qptr) == NULL) { \ - if(isdn2_debug&1)printf(" -- Minor %d\n",minor); \ + if(isdn2_debug&1)printf("%s -- Minor %d\n",KERN_DEBUG,minor); \ h_reply (q, &hdr, ENXIO); goto free_it; } \ } while(0) /**/ if (isdn2_debug & 0x8) - printf ("wsrv %p.%p.%p\n", mp, DATA_BLOCK(mp), mp->b_cont); + printf ("%swsrv %p.%p.%p\n",KERN_DEBUG, mp, DATA_BLOCK(mp), mp->b_cont); if(q == WR(isdn_chan.qptr)) if(isdn2_debug & 0x2000) logh_printmsg (NULL, "Down", mp); @@ -2192,16 +2257,17 @@ isdn2_wsrv (queue_t *q) { struct _isdn1_card *crd1; - if (chan->card == NULL || (crd1 = chan->card->card) == NULL || (*crd1->ch_prot)(crd1,chan->channel,mp,CHP_FROMSTACK) < 0) { + if (chan->card == NULL || (crd1 = chan->card->card) == NULL || (crd1->ch_prot == NULL) || (*crd1->ch_prot)(crd1,chan->channel,mp,CHP_FROMSTACK) < 0) { mblk_t *mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) { - printf(KERN_DEBUG "NoMemHdr isdn_2.c %d\n",__LINE__); + printf("%sNoMemHdr isdn_2.c %d\n",KERN_DEBUG,__LINE__); putbqf (q, mp); return; } hdr2 = ((isdn23_hdr) mb->b_wptr)++; hdr2->key = HDR_PROTOCMD; + hdr2->seqnum = hdrseq; hdrseq += 2; hdr2->hdr_protocmd.minor = chan->dev; hdr2->hdr_protocmd.card = 0; hdr2->hdr_protocmd.channel = 0; @@ -2216,7 +2282,7 @@ isdn2_wsrv (queue_t *q) putnext (isdn_chan.qptr, mb); } else { freemsg (mb); - printf ("Hang 4\n"); + printf ("%sHang 4\n",KERN_DEBUG); putctlx (RD (q), M_HANGUP); } } @@ -2236,7 +2302,7 @@ isdn2_wsrv (queue_t *q) freemsg (mp); mp = NULL; if (isdn2_debug & 0x10) - printf ("ISDN %d: Msg arrived for status %d\n", chan->dev, chan->status); + printf ("%sISDN %d: Msg arrived for status %d\n",KERN_DEBUG, chan->dev, chan->status); } break; /* message deleted below */ case M_D_ctl: @@ -2257,12 +2323,12 @@ isdn2_wsrv (queue_t *q) break; } if(isdn2_debug & 0x100) - printf("Dispatch %x\n",hdr.key); + printf("%sDispatch %x\n",KERN_DEBUG,hdr.key); switch (hdr.key & ~HDR_FLAGS) { default: if (isdn2_debug & 0x100) - printf ("unknown key %d\n", hdr.key); + printf ("%sunknown key %d\n",KERN_DEBUG, hdr.key); h_reply (q, &hdr, EINVAL); free_it: if (mp != NULL) { @@ -2274,7 +2340,7 @@ isdn2_wsrv (queue_t *q) mblk_t *mz = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mz == NULL) { - printf(KERN_DEBUG "FreeReturn\n"); + printf("%sFreeReturn\n",KERN_DEBUG); freemsg (mp); return; } @@ -2312,11 +2378,12 @@ isdn2_wsrv (queue_t *q) LENHDR (protocmd); if (hdr.hdr_protocmd.minor == 0) { CARD (protocmd); + err = -EIO; if (hdr.hdr_protocmd.channel > crd->card->nr_chans) { - printf (" -- bad channel\n"); - h_reply (q, &hdr, EINVAL); - } else if ((err = (*crd->card->ch_prot) (crd->card, hdr.hdr_protocmd.channel, mp,0)) != 0) { - printf (" -- Err SetMode\n"); + printf ("%s -- bad channel\n",KERN_DEBUG); + h_reply (q, &hdr, -EINVAL); + } else if ((crd->card == NULL) || (crd->card->ch_prot == NULL) || (err = (*crd->card->ch_prot) (crd->card, hdr.hdr_protocmd.channel, mp,0)) != 0) { + printf ("%s -- Err SetMode\n",KERN_DEBUG); h_reply (q, &hdr, err); } else mp = NULL; @@ -2329,17 +2396,23 @@ isdn2_wsrv (queue_t *q) struct _isdn1_card *crd1; mp->b_rptr = oldhd; + if(id == PROTO_UPDATEMODLIST) { + if (isdn2_debug & 0x10) + printf ("%sUpdatePushlist to %p, minor %d\n",KERN_DEBUG, chan->qptr, minor); + h_reply(q,&hdr,0); + goto free_it; + } if (chan->card != NULL) crd1 = chan->card->card; else crd1 = NULL; - if(crd1 == NULL || chan->card == NULL || (*crd1->ch_prot)(crd1,chan->channel,mp,0) < 0) + if(crd1 == NULL || crd1->ch_prot == NULL || (*crd1->ch_prot)(crd1,chan->channel,mp,0) < 0) putnext (chan->qptr, mp); mp = NULL; } else { while(m_getsx(mp,&id) == 0) ; if (isdn2_debug & 0x10) - printf ("Pushlist to %p, minor %d\n", chan->qptr, minor); + printf ("%sPushlist to %p, minor %d\n",KERN_DEBUG, chan->qptr, minor); poplist (chan->qptr, 0); h_reply (q, &hdr, pushlist (chan->qptr, mp)); /* pushlist doesn't free */ @@ -2442,7 +2515,7 @@ isdn2_wsrv (queue_t *q) else putctlx (qq, M_HANGUP); } else { - if(isdn2_debug&1)printf("-- not open\n"); + if(isdn2_debug&1)printf("%s-- not open\n",KERN_DEBUG); h_reply (q, &hdr, ENXIO); } } @@ -2456,27 +2529,27 @@ isdn2_wsrv (queue_t *q) CARD (attach); if (isdn2_debug & 0x10) - printf ("Attach card %d channel %d to minor %d mode %d %s%s\n", hdr.hdr_attach.card, hdr.hdr_attach.chan, minor, hdr.hdr_attach.mode, hdr.hdr_attach.listen & 1 ? "listen" : "talk", hdr.hdr_attach.listen & 2 ? " force" : ""); + printf ("%sAttach card %d channel %d to minor %d mode %d %s%s\n",KERN_DEBUG, hdr.hdr_attach.card, hdr.hdr_attach.chan, minor, hdr.hdr_attach.mode, hdr.hdr_attach.listen & 1 ? "listen" : "talk", hdr.hdr_attach.listen & 2 ? " force" : ""); ms = splstr (); if (chan->card != NULL && chan->card != crd) { - printf (" -- minor not free\n"); + printf ("%s -- minor not free\n",KERN_DEBUG); h_reply (q, &hdr, EBUSY); splx (ms); break; } else if (hdr.hdr_attach.mode == 0) { - printf (" -- mode zero\n"); + printf ("%s -- mode zero\n",KERN_DEBUG); h_reply (q, &hdr, EINVAL); splx (ms); break; } else if (hdr.hdr_attach.chan > crd->card->nr_chans) { - printf (" -- bad channel (%d > %d)\n", hdr.hdr_attach.chan, crd->card->nr_chans); + printf ("%s -- bad channel (%d > %d)\n",KERN_DEBUG, hdr.hdr_attach.chan, crd->card->nr_chans); h_reply (q, &hdr, EINVAL); splx (ms); break; } if (crd->status != C_up) { - printf(" -- card down"); + printf("%s -- card down 3",KERN_DEBUG); if(hdr.hdr_attach.listen & 2) err = (*crd->card->ch_mode) (crd->card, 0, M_HDLC, 0); else @@ -2490,7 +2563,7 @@ isdn2_wsrv (queue_t *q) if (hdr.hdr_attach.chan > 0) { /* B channel */ if (crd->chan[hdr.hdr_attach.chan] != NULL && crd->chan[hdr.hdr_attach.chan] != chan) { #if 0 - printf (" -- Err Chan busy\n"); + printf ("%s -- Err Chan busy\n",KERN_DEBUG); h_reply (q, &hdr, EBUSY); splx (ms); break; @@ -2499,7 +2572,7 @@ isdn2_wsrv (queue_t *q) #endif } if ((err = (*crd->card->ch_mode) (crd->card, hdr.hdr_attach.chan, hdr.hdr_attach.mode, hdr.hdr_attach.listen & 1)) != 0) { - printf (" -- Err SetMode\n"); + printf ("%s -- Err SetMode\n",KERN_DEBUG); h_reply (q, &hdr, EIO); splx (ms); break; @@ -2511,7 +2584,7 @@ isdn2_wsrv (queue_t *q) /* putproto (minor, PROTO_CONNECTED); */ #if 0 if (isdn2_debug & 0x10) - printf (" -- Conn B\n"); + printf ("%s -- Conn B\n",KERN_DEBUG); #endif } else { /* D channel */ int i; @@ -2521,7 +2594,7 @@ isdn2_wsrv (queue_t *q) break; if (i >= MAXCHAN) { if (isdn2_debug & 0x10) - printf (" -- Err no chan free\n"); + printf ("%s -- Err no chan free\n",KERN_DEBUG); h_reply (q, &hdr, EBUSY); splx (ms); break; @@ -2532,7 +2605,7 @@ isdn2_wsrv (queue_t *q) chan->channel = i; /* putproto (minor, PROTO_CONNECTED); */ if (isdn2_debug & 0x10) - printf (" -- Conn D\n"); + printf ("%s -- Conn D\n",KERN_DEBUG); } splx (ms); } @@ -2549,17 +2622,21 @@ isdn2_wsrv (queue_t *q) break; case HDR_LOAD: { - CARD (uidata); + LENHDR (load); + CARD (load); if(crd->card->boot == NULL) { - printf (" -- Load: no loader\n"); + printf ("%s -- Load: no loader\n",KERN_DEBUG); h_reply (q, &hdr, EIO); } - mp = pullupm(mp,0); + if(hdr.hdr_load.seqnum == 1 && hdr.hdr_load.foffset == 0) + isdn2_new_state(crd->card,0); if((err = (*crd->card->boot) (crd->card, hdr.hdr_load.seqnum, hdr.hdr_load.foffset, mp)) != 0) { - printf (" -- Err Load\n"); + printf ("%s -- Err Load %d\n",KERN_DEBUG,err); h_reply (q, &hdr, err); - } else + } else { mp = NULL; + h_reply (q, &hdr, 0); + } goto free_it; } case HDR_TEI: @@ -2605,7 +2682,7 @@ isdn2_wsrv (queue_t *q) } else { for (state = crd->state[ch]; state != NULL; state = state->next) { if(isdn2_debug&0x40) - printf("Wakeup %d/%d/%d",state->card->nr, state->SAPI, *state->card->TEI); + printf("%sWakeup %d/%d/%d",KERN_DEBUG,state->card->nr, state->SAPI, *state->card->TEI); if(state->card != crd) printf("\n*!*Bad state for card!\n"); x75_changestate (&state->state, DL_ESTABLISH_IND, 0); @@ -2651,7 +2728,7 @@ isdn2_wsrv (queue_t *q) #endif if ((state == NULL) != (hdr.hdr_openprot.ind == 0)) { #ifdef CONFIG_DEBUG_ISDN - printf("Err state 0x%p ind 0x%x\n",state,hdr.hdr_openprot.ind); + printf("%sErr state 0x%p ind 0x%x\n",KERN_DEBUG,state,hdr.hdr_openprot.ind); #endif h_reply (q, &hdr, EINVAL); break; @@ -2770,6 +2847,7 @@ isdn2_wsrv (queue_t *q) } hdr3 = ((isdn23_hdr) mz->b_wptr)++; hdr3->key = HDR_XDATA; + hdr3->seqnum = hdrseq; hdrseq += 2; hdr3->hdr_xdata.minor = chan->dev; hdr3->hdr_xdata.len = dsize (mp); linkb (mz, mp); diff --git a/isdn_3/Makefile b/isdn_3/Makefile index 4fe4cd6..a2a6cc0 100644 --- a/isdn_3/Makefile +++ b/isdn_3/Makefile @@ -1,51 +1,19 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +TOPDIR=.. +include $(TOPDIR)/Make.config -## =()@>()= -CC = gcc - -## Change this to @@ @@ @@ -I../include -#### if you want to move isdn_3 into the kernel -#### Also swap the commented lines for all: and lib: - -## =()@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -RANLIB = ranlib - -HEADERS = phone.h capi.h prot_1TR6_0.h prot_1TR6_1.h tei.h fixed.h - -SOURCES = isdn_3.c tei.c fixed.c capi.c phone.c prot_1TR6_0.c prot_1TR6_1.c prot_1TR6_common.c prot_ETS.c - -OBJ = isdn_3.o tei.o fixed.o capi.o phone.o prot_1TR6_0.o prot_1TR6_1.o prot_1TR6_common.o prot_ETS.o - -ALL = ../isdn_3.a - -all prog: $(OBJ) $(ALL) - -../isdn_3.a: $(OBJ) - ar r ../isdn_3.a $? - @ $(RANLIB) ../isdn_3.a - -indent: - ../indent.sh $(HEADERS) $(SOURCES) - -install update: all - -clean: - rm -f $(ALL) $(OBJ) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - -ifeq (.depend,$(wildcard .depend)) -include .depend +PSOURCES := isdn_3.c $(addsuffix .c,$(PROTOCOLS)) +ifneq ($(strip $(filter phone, $(PROTOCOLS))),) +ifneq ($(strip $(filter euro, $(SUBPROTOCOLS))),) +PSOURCES += prot_ETS.c +endif +ifneq ($(strip $(filter german, $(SUBPROTOCOLS))),) +PSOURCES += prot_1TR6_1.c +PSOURCES += prot_1TR6_common.c +endif endif +EXTRA_CFLAGS=$(addsuffix _,$(addprefix -D_,$(PROTOCOLS) $(SUBPROTOCOLS))) + +LIB = ../isdn_3.a + +include $(TOPDIR)/Make.rules diff --git a/isdn_3/capi.c b/isdn_3/capi.c index cfdd5fb..46b9b57 100644 --- a/isdn_3/capi.c +++ b/isdn_3/capi.c @@ -4,7 +4,6 @@ #include "dump.h" #include "streamlib.h" #include "phone_1TR6.h" -#include "phone_ETSI.h" #include "q_data.h" #include "isdn_23.h" #include "isdn3_phone.h" @@ -14,14 +13,309 @@ #include "prot_1TR6_1.h" #include "prot_ETS.h" #include "capi.h" +#include "../cards/capi/capi.h" #include "isdn_12.h" +#include "asm/byteorder.h" +#include "sapi.h" + + +#if NICONN <= 14 +#error "Need NICONN > 14" +#endif +#if NITALK <= 1 +#error "Need NITALK > 1" +#endif +#define message_id talki[0] +#define tstate talki[1] + +#define ncci0 conni[0] +#define waitflags conni[1] +#define msgid0 conni[2] +#define WF_CONNECTACTIVE_IND 3 +#define WF_CONNECTB3ACTIVE_IND 4 +#define WF_DISCONNECTB3_IND 5 +#define WF_DISCONNECT_IND 6 +#define WF_SELECTB2_CONF 7 +#define WF_SELECTB3_CONF 8 +#define WF_LISTENB3_CONF 9 +#define WF_CONNECTB3_IND 10 +#define WF_CONNECTB3_CONF 11 +#define WF_DISCONNECTB3_CONF 12 +#define WF_DISCONNECT_CONF 13 +#define WF_CONNECT_CONF 14 + +/* Card states */ +#define STATE_BOOTING 1 +#define STATE_OPENING 2 +#define STATE_REGISTER 3 + +#define STATE_CONF_FIRST 10 +#define STATE_CONF_LAST 99 +#define STATE_RUNNING 100 + +#define RUN_CAPI_TALERT 01 + +#define VAL_CAPI_TALERT ( 2 *HZ) /* timer for delaying an ALERT response */ + +static void CAPI_TALERT (isdn3_conn conn); + +/* Connection states: + 0: unknown + + 1: outgoing, wait for CONNECT_CONF + 2: outgoing, wait for CONNECTACTIVE_IND SELECTB2_CONF SELECTB3_CONF + 3: outgoing, wait for CONNECTB3_CONF CONNECTB3ACTIVE_IND + + 7: incoming, wait for master program + 8: incoming, wait for SELECTB2_CONF SELECTB3_CONF + 9: incoming, wait for LISTENB3_CONF CONNECTACTIVE_IND CONNECTB3_CONF CONNECTB3ACTIVE_IND + + 15: CONNECTED + + 20: wait for DISCONNECTB3_CONF DISCONNECTB3_IND + 21: wait for DISCONNECT_CONF DISCONNECT_IND + 22: wait for DISCONNECTB3_CONF DISCONNECTB3_IND DISCONNECT_CONF DISCONNECT_IND +*/ + +struct capi_info { + unsigned short service; + unsigned char flags; + unsigned char eaz; + unsigned char nr[MAXNR]; +}; + + +extern void log_printmsg (void *log, const char *text, mblk_t * mp, const char*); + + +static void +capi_timerup (isdn3_conn conn) +{ + rtimer (CAPI_TALERT, conn); +} + +#define setstate(a,b) Xsetstate(__LINE__,(a),(b)) +static void +Xsetstate(unsigned int deb_line, isdn3_conn conn, uchar_t state) +{ +printf ("Conn CAPI:%d %08lx: State %d --> %d\n", deb_line, conn->call_ref, conn->state, state); + + if(conn->state == state) + return; + switch(conn->state) { + case 13: + untimer(CAPI_TALERT, conn); + break; + } + conn->state = state; + switch(state) { + case 13: + timer(CAPI_TALERT,conn); + break; + } +} + +static ushort_t newmsgid(isdn3_talk talk) +{ + talk->message_id = ((talk->message_id + 1) & 0x3FFF) | 0x4000; + + return talk->message_id; +} + +static int +capi_send(isdn3_talk talk, ushort_t appl, ushort_t msgtype, mblk_t *data, ushort_t msgid) +{ + int err; + mblk_t *mb; + struct CAPI_every_header *capi; + /* build a message */ + + mb = allocb(sizeof(*capi), BPRI_LO); + if(mb == NULL) + return -ENOMEM; + capi = ((struct CAPI_every_header *)mb->b_wptr)++; + bzero(capi,sizeof(*capi)); + capi->len = sizeof(*capi) + (data ? msgdsize(data) : 0); + capi->appl = 0; + capi->PRIM_type = msgtype; + capi->messid = msgid; + + if(data != NULL) + linkb(mb,data); + if((err = isdn3_send(talk,AS_DATA,mb)) < 0) + freeb(mb); + return err; +} + +static int +capi_sendctl(isdn3_talk talk, ushort_t appl, ushort_t code, mblk_t *data, ushort_t msgid) +{ + int err; + mblk_t *mb; + /* build a message */ + struct CAPI_control_req *capi; + + mb = allocb(sizeof(*capi), BPRI_LO); + if(mb == NULL) + return -ENOMEM; + capi = ((struct CAPI_control_req *)mb->b_wptr)++; + bzero(capi,sizeof(*capi)); + capi->type = code; + capi->datalen = msgdsize(data); + + linkb(mb,data); + if((err = capi_send(talk,appl,CAPI_CONTROL_REQ,mb,msgid)) < 0) + freeb(mb); + return err; +} +/* open: + * 0001 ID LLHH capiLen LLHH appl LLHH type LLHH messid LLHH control + * LLHH type CCCC protocol ... + */ + + +static void +CAPI_TALERT(isdn3_conn conn) +{ + printf("CAPI_TALERT %08lx\n",conn->call_ref); + if(conn->state != 6) + return; + /* Hmmm. Do we really have to do this? I think not... */ + /* So let's try without. */ + conn->timerflags &= ~RUN_CAPI_TALERT; +} + +static int +send_setup(isdn3_conn conn) +{ + int err; + struct CAPI_selectb2_req *c2; + struct CAPI_selectb3_req *c3; + struct dlpd *dl; + mblk_t *m2,*m3; + + m2 = allocb(sizeof(*c2)+sizeof(*dl),BPRI_MED); + m3 = allocb(sizeof(*c3),BPRI_MED); + if(m2 == NULL || m3 == NULL) { + if(m2 != NULL) + freemsg(m2); + if(m3 != NULL) + freemsg(m3); + return -ENOMEM; + } + c2 = ((typeof(c2))m2->b_wptr)++; + dl = ((typeof(dl))m2->b_wptr)++; + c3 = ((typeof(c3))m3->b_wptr)++; + + bzero(c2,sizeof(*c2)); + bzero(dl,sizeof(*dl)); + bzero(c3,sizeof(*c3)); + + c2->plci = conn->call_ref & 0xFFFF; + c2->B2_proto = 0x02; /* transparent HDLC */ + c2->dlpdlen = sizeof(*dl); + dl->data_length = 4096; + c3->plci = conn->call_ref & 0xFFFF; + c3->B3_proto = 0x04; /* transparent */ + err = capi_send(conn->talk,conn->call_ref >> 16, CAPI_SELECTB2_REQ, m2, conn->conni[WF_SELECTB2_CONF] = newmsgid(conn->talk)); + if(err < 0) { + freemsg(m2); + freemsg(m3); + } else { + err = capi_send(conn->talk,conn->call_ref >> 16, CAPI_SELECTB3_REQ, m3, conn->conni[WF_SELECTB3_CONF] = newmsgid(conn->talk)); + if(err < 0) + freemsg(m3); + } + return err; +} static int chstate (isdn3_talk talk, uchar_t ind, short add) { - printf("CAPI: chstate %d %d\n",ind,add); + printf("CAPI: chstate %d %d, in state %ld\n",ind,add,talk->tstate); + switch (ind) { + case PH_ACTIVATE_NOTE: + case DL_ESTABLISH_IND: + case DL_ESTABLISH_CONF: + { + { + isdn3_conn conn, nconn; + for(conn = talk->conn; conn != NULL; conn = nconn) { + nconn = conn->next; + capi_timerup(conn); + } + } + if(talk->tstate != STATE_BOOTING) { + /* TODO: reset / restart / XXX the card? */ + break; + } + { + struct apiopen *capi; + int err; + mblk_t *data; +#define DEFPROFILE "u_dss1_pmp" + char profile[32] = DEFPROFILE; + { /* Find correct driver name */ + int err; char skip = 0; + mblk_t *info = talk->card->info; + if(info != NULL) { + streamchar *sta = info->b_rptr; + ushort_t idx; + + while(m_getid(info,&idx) == 0) { + long sap; + switch(idx) { + case ARG_PROTOCOL: + if (m_geti(info,&sap) == 0) { + skip = (sap != SAPI_CAPI); + } + break; + case ARG_SUBPROT: + if (m_geti(info,&sap) == 0 && !skip) { + switch(sap) { + case SAPI_CAPI_BINTEC: + skip=0; + break; + default: + /* Wrong card. TODO: Do something! */ + info->b_rptr = sta; return -ENXIO; -#if 0 + } + } + break; + case ARG_STACK: + if(skip) + break; + if((err = m_getstr(info,profile,sizeof(profile)-1)) < 0) + strcpy(profile,DEFPROFILE); + break; + } + } + info->b_rptr = sta; + } + } + + data = allocb(sizeof(*capi), BPRI_MED); + if(data == NULL) /* XXX error processing */ + return -ENOMEM; + capi = ((struct apiopen *)data->b_wptr)++; + bzero(capi,sizeof(*capi)); + strcpy(capi->protocol,"u_dss1_pmp"); + capi->teid = ~0; + capi->t3id = ~0; + capi->contrl = 0; + capi->time = time(NULL); + if((err = capi_sendctl(talk,0,CONTROL_API_OPEN,data,newmsgid(talk))) < 0) { + freemsg(data); + break; + } + talk->tstate = STATE_OPENING; + } + } + } + return 0; + +#if 0 /* to end of function */ int killit = 0; if(0)printf ("PHONE state for card %d says %s:%o\n", talk->card->nr, conv_ind(ind), add); @@ -38,7 +332,7 @@ chstate (isdn3_talk talk, uchar_t ind, short add) (*prot->chstate) (conn, ind, add); } - talk->state |= PHONE_UP; + talk->tstate |= PHONE_UP; if(0)printf ("PHONE is UP\n"); } break; case PH_DEACTIVATE_IND: @@ -61,7 +355,7 @@ chstate (isdn3_talk talk, uchar_t ind, short add) isdn3_killconn (conn, 1); } - talk->state &= ~PHONE_UP; + talk->tstate &= ~PHONE_UP; if(0)printf ("PHONE i4s DOWN\n"); } break; @@ -70,11 +364,907 @@ chstate (isdn3_talk talk, uchar_t ind, short add) #endif } +static inline isdn3_conn +capi_findconn(isdn3_talk talk, ushort_t appl, ushort_t plci) +{ + isdn3_conn conn; + ulong_t cref = (appl << 16) | plci; + + for(conn = talk->conn; conn != NULL; conn = conn->next) { + if(conn->call_ref == cref) { + printf(" (conn %08lx) ",conn->call_ref); + return conn; + } + } + return NULL; +} + +static inline isdn3_conn +capi_findconn3(isdn3_talk talk, ushort_t appl, ushort_t ncci) +{ + isdn3_conn conn; + + for(conn = talk->conn; conn != NULL; conn = conn->next) { + if((conn->call_ref >> 16) == appl && conn->ncci0 == ncci) { + printf(" (conn %08lx) ",conn->call_ref); + return conn; + } + } + return NULL; +} + +static inline isdn3_conn +capi_findconnm(isdn3_talk talk, ushort_t appl, ushort_t msgid) +{ + isdn3_conn conn; + + for(conn = talk->conn; conn != NULL; conn = conn->next) { + if((conn->call_ref >> 16) == appl && conn->msgid0 == msgid) { + printf(" (conn %08lx) ",conn->call_ref); + return conn; + } + } + return NULL; +} + +static int +report_incoming (isdn3_conn conn) +{ + int err = 0; + + mblk_t *mb = allocb (256, BPRI_MED); + + if (mb == NULL) { + setstate (conn, 0); + return -ENOMEM; + } + m_putid (mb, IND_CONN); + conn_info (conn, mb); + + if ((err = isdn3_at_send (conn, mb, 0)) != 0) { + freemsg (mb); + setstate (conn, 0); + return err; + } + return err; +} + +static void +report_terminate (isdn3_conn conn) +{ + int err = 0; + + mblk_t *mb = allocb (256, BPRI_MED); + + if (conn->minorstate & MS_TERM_SENT) { + m_putid (mb, IND_INFO); + m_putid (mb, ID_N1_REL); + } else { + conn->minorstate |= MS_TERM_SENT; + m_putid (mb, IND_DISC); + } + conn_info (conn, mb); + if ((err = isdn3_at_send (conn, mb, 0)) != 0) { + freemsg (mb); + setstate (conn, 0); + return; + } + return; +} + +static void +checkterm (isdn3_conn conn) +{ + if (conn->state == 0) { + report_terminate (conn); + isdn3_killconn (conn, 1); /* XXX */ + } +} + +static int +send_disconnect(isdn3_conn conn, char do_L3) +{ + int err; + + if(conn->state >= 21) + return 0; + if(conn->state == 0) + return 0; + conn->waitflags = 0; + report_terminate(conn); + if(do_L3 && (conn->state < 20)) { + struct CAPI_disconnectb3_req *c3; + mblk_t *m3 = allocb(sizeof(*c3),BPRI_MED); + if(m3 == NULL) + return -ENOMEM; + + c3 = ((typeof(c3))m3->b_wptr)++; + bzero(c3,sizeof(*c3)); + c3->ncci = conn->ncci0; + if((err = capi_send(conn->talk,conn->call_ref >> 16,CAPI_DISCONNECTB3_REQ,m3, + conn->conni[WF_DISCONNECTB3_CONF] = newmsgid(conn->talk))) < 0) { + freemsg(m3); + } else { + conn->waitflags |= 1 << WF_DISCONNECTB3_CONF; + conn->waitflags |= 1 << WF_DISCONNECTB3_IND; + setstate(conn,20); + } + } + { + struct CAPI_disconnect_req *c3; + mblk_t *m3 = allocb(sizeof(*c3),BPRI_MED); + if(m3 == NULL) + return -ENOMEM; + + c3 = ((typeof(c3))m3->b_wptr)++; + bzero(c3,sizeof(*c3)); + c3->plci = conn->call_ref; + if((err = capi_send(conn->talk,conn->call_ref >> 16,CAPI_DISCONNECT_REQ,m3, + conn->conni[WF_DISCONNECT_CONF] = newmsgid(conn->talk))) < 0) { + freemsg(m3); + } else { + conn->waitflags |= 1 << WF_DISCONNECT_CONF; + conn->waitflags |= 1 << WF_DISCONNECT_IND; + if(conn->state < 20) + setstate(conn,21); + else + setstate(conn,22); + } + } + return err; +} + +static int +after_active(isdn3_conn conn) +{ + int err; + if(conn->waitflags) + return 0; /* not yet */ + switch(conn->state) { + default: + err = -EIO; + if(send_disconnect(conn,0) < 0) + setstate(conn,0); + break; + case 3: + case 9: + setstate(conn,15); + isdn3_setup_conn (conn, EST_CONNECT); + err = 0; + break; + } + return err; +} + +static int +after_selectb(isdn3_conn conn) +{ + int err; + if(conn->waitflags) + return 0; /* not yet */ + switch(conn->state) { + case 2: /* active */ + { + struct CAPI_connect_resp *c3; + mblk_t *m3 = allocb(sizeof(*c3),BPRI_MED); + if(m3 == NULL) { + err = -ENOMEM; + break; + } + c3 = ((typeof(c3))m3->b_wptr)++; + bzero(c3,sizeof(*c3)); + c3->plci = conn->call_ref; + if((err = capi_send(conn->talk,conn->call_ref>>16,CAPI_CONNECT_RESP,m3,conn->msgid0)) < 0) + freemsg(m3); + else { + conn->waitflags = 1<waitflags |= 1<b_wptr)++; + c3 = ((typeof(c3))m3->b_wptr)++; + bzero(c2,sizeof(*c2)); + bzero(c3,sizeof(*c3)); + c2->plci = conn->call_ref; + c3->plci = conn->call_ref; + if((err = capi_send(conn->talk,conn->call_ref>>16,CAPI_LISTENB3_REQ,m3,conn->conni[WF_LISTENB3_CONF] = newmsgid(conn->talk))) < 0) { + freemsg(m2); + freemsg(m3); + } else if((err = capi_send(conn->talk,conn->call_ref>>16,CAPI_CONNECT_RESP,m3,conn->msgid0)) < 0) + freemsg(m3); + else { + conn->waitflags = 1<waitflags |= 1<waitflags |= 1<waitflags |= 1<state); + err = send_disconnect(conn,0); + if(err < 0) + setstate(conn,0); + } + if(err < 0) + send_disconnect(conn,0); + return err; +} + static int recv (isdn3_talk talk, char isUI, mblk_t * data) { - printf("CAPI: recv %d\n",isUI); + struct CAPI_every_header *capi; + streamchar *origmb; + int err = 0; + isdn3_conn conn = 0; + + printf("CAPI: recv %d, in state %ld\n",isUI,talk->tstate); + origmb = data->b_rptr; + if(data->b_wptr-data->b_rptr < sizeof(*capi)) + goto less_room; + + capi = ((typeof(capi))data->b_rptr)++; + + switch(capi->PRIM_type) { + default: + printf("CAPI: Unknown primary type 0x%04x\n",capi->PRIM_type); + err = -ENXIO; + goto printit; + + case CAPI_DISCONNECTB3_CONF: + { + struct CAPI_disconnectb3_conf *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn3(talk,capi->appl,c2->ncci)) == NULL) { + printf("CAPI error: DISCONNECTB3_CONF has unknown cref3 %04x%04x\n",capi->appl,c2->ncci); + err = -ENXIO; + break; + } + if(c2->info != 0) { + printf("CAPI error: DISCONNECTB3_CONF returns %04x\n",c2->info); + send_disconnect(conn,0); + break; + } + if(conn->waitflags & (1<waitflags &=~ (1<waitflags == 0) { + setstate(conn,0); + break; + } + + } else { + printf("CAPI error: DISCONNECTB3_CONF in wrong state %d\n",conn->state); + err = -EIO; + break; + } + } + break; + case CAPI_DISCONNECTB3_IND: + { + struct CAPI_disconnectb3_ind *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn3(talk,capi->appl,c2->ncci)) == NULL) { + printf("CAPI error: DISCONNECTB3_IND has unknown cref3 %04x%04x\n",capi->appl,c2->ncci); + err = -ENXIO; + break; + } + if((c2->info == 0) && (conn->waitflags & (1<waitflags &=~ (1<waitflags == 0) { + report_terminate(conn); + if(conn->state == 20) { + err = send_disconnect(conn,0); + if(err < 0) + setstate(conn,0); + } else + setstate(conn,0); + } + } else if((c2->info != 0) || (conn->state >= 20)) { + printf("CAPI error: DISCONNECTB3_IND in wrong state %d, info %04x\n",conn->state,c2->info); + err = -EIO; + } else { + isdn3_setup_conn (conn, EST_DISCONNECT); + send_disconnect(conn,0); + report_terminate(conn); + } + { + int err3 = 0; + struct CAPI_disconnectb3_resp *c3; + mblk_t *m3 = allocb(sizeof(*c3),BPRI_MED); + if(m3 == NULL) + err3 = -ENOMEM; + if(err3 == 0) { + c3 = ((typeof(c3))data->b_wptr)++; + bzero(c3,sizeof(*c3)); + c3->ncci = c2->ncci; + if((err3 = capi_send(talk,capi->appl,CAPI_DISCONNECTB3_RESP,m3,capi->messid)) < 0) + freemsg(m3); + } + if(err == 0) + err = send_disconnect(conn,0); + if(err == 0) + err = err3; + } + } + break; + case CAPI_DISCONNECT_IND: + { + struct CAPI_disconnect_ind *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) == NULL) { + printf("CAPI error: DISCONNECT_IND has unknown cref %04x%04x\n",capi->appl,c2->plci); + err = -ENXIO; + break; + } + if((c2->info == 0) && (conn->waitflags & (1<waitflags &=~ (1<waitflags == 0) { + report_terminate(conn); + setstate(conn,0); + } + } else if((c2->info != 0) || (conn->state >= 21)) { + printf("CAPI error: DISCONNECT_IND in wrong state %d, info %04x\n",conn->state,c2->info); + err = -EIO; + } else { + isdn3_setup_conn (conn, EST_DISCONNECT); + send_disconnect(conn,0); + report_terminate(conn); + } + { + int err3 = 0; + struct CAPI_disconnect_resp *c3; + mblk_t *m3 = allocb(sizeof(*c3),BPRI_MED); + if(m3 == NULL) + err3 = -ENOMEM; + if(err3 == 0) { + c3 = ((typeof(c3))data->b_wptr)++; + bzero(c3,sizeof(*c3)); + c3->plci = c2->plci; + if((err3 = capi_send(talk,capi->appl,CAPI_DISCONNECT_RESP,m3,capi->messid)) < 0) + freemsg(m3); + } + if(err == 0) + err = send_disconnect(conn,0); + if(err == 0) + err = err3; + } + } + break; + + case CAPI_DISCONNECT_CONF: + { + struct CAPI_disconnect_conf *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) == NULL) { + printf("CAPI error: DISCONNECT_CONF has unknown cref %04x%04x\n",capi->appl,c2->plci); + err = -ENXIO; + break; + } + if((c2->info == 0) || (conn->waitflags & (1<waitflags &=~ (1<waitflags == 0) { + report_terminate(conn); + setstate(conn,0); + } + } else { + printf("CAPI error: DISCONNECT_CONF in wrong state %d, info %04x\n",conn->state,c2->info); + isdn3_setup_conn (conn, EST_DISCONNECT); + setstate(conn,0); + report_terminate(conn); + } + } + break; + + case CAPI_CONNECT_CONF: + { + struct CAPI_connect_conf *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) != NULL) { + printf("CAPI error: CONNECT_CONF has known cref %04x%04x\n",capi->appl,c2->plci); + setstate(conn,0); + err = -ENXIO; + break; + } + if((conn = capi_findconnm(talk,capi->appl,capi->messid)) == NULL) { + printf("CAPI error: CONNECT_CONF has unknown msgid %04x.%04x\n",capi->appl,capi->messid); + setstate(conn,0); + err = -ENXIO; + break; + } + conn->call_ref = (capi->appl << 16) | c2->plci; + if((c2->info == 0) && (conn->waitflags & (1<waitflags &=~ (1<waitflags == 0) { + if((err = send_setup(conn)) < 0) { + if(send_disconnect(conn,0) < 0) { + setstate(conn,0); + } + } else { + conn->waitflags |= 1<state,c2->info); + isdn3_setup_conn (conn, EST_DISCONNECT); + report_terminate(conn); + if(send_disconnect(conn,0) < 0) + setstate(conn,0); + } + } + break; + + case CAPI_SELECTB2_CONF: + { + struct CAPI_selectb2_conf *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) == NULL) { + printf("CAPI error: SELECTB2_CONF has unknown cref %04x%04x\n",capi->appl,c2->plci); + err = -ENXIO; + break; + } + if((c2->info == 0) && (conn->waitflags & (1<waitflags &=~ (1<state,c2->info); + report_terminate(conn); + if(send_disconnect(conn,0) < 0) + setstate(conn,0); + } + } + break; + case CAPI_SELECTB3_CONF: + { + struct CAPI_selectb3_conf *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) == NULL) { + printf("CAPI error: SELECTB3_CONF has unknown cref %04x%04x\n",capi->appl,c2->plci); + err = -ENXIO; + break; + } + if((c2->info == 0) && (conn->waitflags & (1<waitflags &=~ (1<state,c2->info); + report_terminate(conn); + if(send_disconnect(conn,0) < 0) + setstate(conn,0); + } + } + break; + case CAPI_CONNECTACTIVE_IND: + { + struct CAPI_connectactive_ind *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) == NULL) { + printf("CAPI error: CONNECTACTIVE_IND has unknown cref %04x%04x\n",capi->appl,c2->plci); + err = -ENXIO; + break; + } + if(conn->waitflags & (1<waitflags &=~ (1<state); + if(send_disconnect(conn,0) < 0) + setstate(conn,0); + } + { + int err3 = 0; + struct CAPI_connectactive_resp *c3; + mblk_t *m3 = allocb(sizeof(*c3),BPRI_MED); + if(m3 == NULL) + err3 = -ENOMEM; + if(err3 == 0) { + c3 = ((typeof(c3))data->b_wptr)++; + bzero(c3,sizeof(*c3)); + c3->plci = c2->plci; + if((err3 = capi_send(talk,capi->appl,CAPI_CONNECTACTIVE_RESP,m3,capi->messid)) < 0) + freemsg(m3); + } + if(err == 0) + err = err3; + } + } + break; + case CAPI_LISTENB3_CONF: + { + struct CAPI_listenb3_conf *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) == NULL) { + printf("CAPI error: LISTENB3_CONF has unknown cref %04x%04x\n",capi->appl,c2->plci); + err = -ENXIO; + break; + } + if((c2->info == 0) && (conn->waitflags & (1<waitflags &=~ (1<state,c2->info); + if(send_disconnect(conn,0) < 0) + setstate(conn,0); + } + } + break; + case CAPI_CONNECTB3_CONF: + { + struct CAPI_connectb3_conf *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) == NULL) { + printf("CAPI error: CONNECTB3_CONF has unknown cref %04x%04x\n",capi->appl,c2->plci); + err = -ENXIO; + break; + } + if((c2->info == 0) && (conn->waitflags & (1<waitflags &=~ (1<appl); + m_puti(mz,c2->plci); + m_puti(mz,c2->ncci); + err = isdn3_send(conn->talk,AS_PROTO,mz); + if(err < 0) { + freemsg(mz); + goto exSendD; + } + conn->ncci0 = c2->ncci; + } + err = after_active(conn); + } else { + err = -EIO; + printf("CAPI error: CONNECTB3_CONF in wrong state %d, info %04x\n",conn->state,c2->info); + exSendD: + if(send_disconnect(conn,0) < 0) + setstate(conn,0); + } + } + break; + + case CAPI_CONNECTB3ACTIVE_IND: + { + struct CAPI_connectb3active_ind *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if((conn = capi_findconn3(talk,capi->appl,c2->ncci)) == NULL) { + printf("CAPI error: CONNECTB3ACTIVE_IND has unknown cref %04x%04x\n",capi->appl,c2->ncci); + err = -ENXIO; + break; + } + if(conn->waitflags & (1<waitflags &=~ (1<state); + if(send_disconnect(conn,0) < 0) + setstate(conn,0); + } + { + int err3 = 0; + struct CAPI_connectb3active_resp *c3; + mblk_t *m3 = allocb(sizeof(*c3),BPRI_MED); + if(m3 == NULL) + err3 = -ENOMEM; + if(err3 == 0) { + c3 = ((typeof(c3))data->b_wptr)++; + bzero(c3,sizeof(*c3)); + c3->ncci = c2->ncci; + if((err3 = capi_send(talk,capi->appl,CAPI_CONNECTB3ACTIVE_RESP,m3,capi->messid)) < 0) + freemsg(m3); + } + if(err == 0) + err = err3; + } + } + break; + + case CAPI_CONNECT_IND: + { + struct CAPI_connect_ind *c2; + + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((typeof(c2))data->b_rptr)++; + if(data->b_wptr-data->b_rptr < c2->telnolen) + goto less_room; + if((conn = capi_findconn(talk,capi->appl,c2->plci)) != NULL) { /* Duplicate. Hmmm. */ + printf("CAPI error: Incoming call has dup cref %04x%04x for conn %d\n",capi->appl, c2->plci,conn->conn_id); + err = 0; + break; + } else { + conn = isdn3_new_conn (talk); + if (conn == NULL) + err = -ENOMEM; + else { + if((conn->p_data = malloc(sizeof(struct capi_info))) == NULL) { + err = -ENOMEM; + } else { + struct capi_info *info = conn->p_data; + info->eaz = c2->DST_eaz; + info->service = (c2->DST_service << 8) | c2->DST_addinfo; + bcopy(data->b_rptr,info->nr,c2->telnolen); + + conn->call_ref = (capi->appl << 16) | c2->plci; + conn->msgid0 = capi->messid; + + err = report_incoming(conn); + if(err == 0) { + setstate(conn,7); + break; + } + } + } + } + + /* Reject. */ + { + struct CAPI_connect_resp *c3; + mblk_t *mp = allocb(sizeof(*c3),BPRI_MED); + if(mp != NULL) { + c3 = ((struct CAPI_connect_resp *)mp->b_wptr)++; + c3->plci = c2->plci; + c3->reject = N1_OutOfOrder; + if((err = capi_send(talk,capi->appl,CAPI_CONNECT_RESP,mp,capi->messid)) < 0) + freemsg(mp); + } + } + } + break; + + /* Non-connection-related messages */ + case CAPI_REGISTER_CONF: + talk->tstate = STATE_CONF_LAST; + /* TODO: get parameters (EAZMAP, et al.) and send them */ + { + mblk_t *info = talk->card->info; + if(info != NULL) { + streamchar *sta = info->b_rptr; + ushort_t idx; + char skip = 0; + + while(m_getid(info,&idx) == 0) { + long sap; + switch(idx) { + case ARG_PROTOCOL: + if (m_geti(info,&sap) == 0) { + skip = (sap != SAPI_CAPI); + } + break; + case ARG_SUBPROT: + if (m_geti(info,&sap) == 0 && !skip) { + switch(sap) { + case SAPI_CAPI_BINTEC: + skip=0; + break; + default: + /* Wrong card. Do something! */ + info->b_rptr = sta; return -ENXIO; + } + } + break; + case ARG_EAZ: + if(skip) + break; + { + char eaz; + struct eazmapping *ce; + mblk_t *mp; + int len; + + if((err = m_getc(info,&eaz)) < 0) + break; + if((len = m_getstrlen(info)) < 0) + break; + mp = allocb(sizeof(*ce)+len, BPRI_MED); + if(mp == NULL) + break; + ce = ((struct eazmapping *)mp->b_wptr)++; + bzero(ce,sizeof(*ce)); + ce->eaz = eaz; + ce->telnolen = len; + if((err = m_getstr(info,mp->b_wptr,len)) < 0) { + freemsg(mp); + break; + } + mp->b_wptr += len; + if((err = capi_sendctl(talk,0,CONTROL_EAZMAPPING,mp,newmsgid(talk))) < 0) { + freemsg(mp); + break; + } + } + break; /* ARG_EAZ */ + } + } + info->b_rptr = sta; + } + } + + { /* Tell the board to listen to everything */ + struct CAPI_listen_req *c2; + mblk_t *mp = allocb(sizeof(*c2),BPRI_MED); + + if(mp == NULL) + return -ENOMEM; + c2 = ((struct CAPI_listen_req *)mp->b_wptr)++; + bzero(c2,sizeof(*c2)); + c2->info_mask = 0x003F; + c2->eaz_mask = 0x03FF; + c2->service_mask = 0xFFFF; + { /* Find correct driver name */ + int err; char skip = 0; + mblk_t *info = talk->card->info; + if(info != NULL) { + streamchar *sta = info->b_rptr; + ushort_t idx; + + while(m_getid(info,&idx) == 0) { + long sap; + switch(idx) { + case ARG_PROTOCOL: + if (m_geti(info,&sap) == 0) { + skip = (sap != SAPI_CAPI); + } + break; + case ARG_SUBPROT: + if (m_geti(info,&sap) == 0 && !skip) { + switch(sap) { + case SAPI_CAPI_BINTEC: + skip=0; + break; + default: + /* Wrong card. TODO: Do something! */ + info->b_rptr = sta; + return -ENXIO; + } + } + break; + case ARG_LISTEN: + { + long x; + if(skip) + break; + if((err = m_getx(info,&x)) >= 0) { + c2->eaz_mask = x; + if((err = m_getx(info,&x)) >= 0) { + c2->service_mask = x; + if((err = m_getx(info,&x)) >= 0) { + c2->info_mask = x; + } + } + } + } + break; + } + } + info->b_rptr = sta; + } + } + if((err = capi_send(talk,0,CAPI_LISTEN_REQ,mp,newmsgid(talk))) < 0) { + freemsg(mp); + return err; + } + talk->tstate--; + } + break; + case CAPI_LISTEN_CONF: + { + struct CAPI_listen_conf *c2; + c2 = ((typeof(c2))data->b_rptr)++; + if(c2->info != 0) { + printf("CAPI error: LISTEN failed %04x\n",c2->info); + return -EIO; + } + if(talk->tstate < STATE_CONF_FIRST || talk->tstate > STATE_CONF_LAST) { + printf("CAPI error: LISTEN return in bad state\n"); + return -EIO; + } + if(++talk->tstate == STATE_CONF_LAST) + talk->tstate = STATE_RUNNING; + } + break; + case CAPI_ALIVE_IND: + if(talk->tstate < STATE_CONF_FIRST) { + printf("CAPI: ALIVE_REQ in state %ld\n",talk->tstate); + goto printit; + } + err = capi_send(talk,0,CAPI_ALIVE_RESP,NULL,capi->messid); + break; + case CAPI_CONTROL_CONF: + { + struct CAPI_control_conf *c2; + if(data->b_wptr-data->b_rptr < sizeof(*c2)) + goto less_room; + c2 = ((struct CAPI_control_conf *)data->b_rptr)++; + switch(c2->type) { + default: + printf("Unknown control_conf type 0x%02x\n",c2->type); + goto printit; + case CONTROL_API_OPEN: /* Boot: Step One */ + if(talk->tstate != STATE_OPENING) { + printf("CAPI error: API_OPEN reply for bad state\n"); + return -EINVAL; + } + if(c2->info <= 0) { + printf("CAPI error: open failed!\n"); + return -EIO; + } + if(c2->info > 1) + printf("CAPI: %d D channels -- using only the first, for now\n",c2->info); + { + struct CAPI_register_req *c3; + + mblk_t *mp = allocb(sizeof(*c3), BPRI_MED); + if(mp == NULL) /* XXX error processing */ + return -ENOMEM; + c3 = ((struct CAPI_register_req *)mp->b_wptr)++; + bzero(c3,sizeof(*c3)); + c3->nmess = 10; + c3->nconn = 2 /* TODO: 30 */ ; + c3->ndblock = c3->nconn*10; + c3->dblocksiz = 4096; + if((err = capi_send(talk,0,CAPI_REGISTER_REQ,mp,newmsgid(talk))) < 0) { + freemsg(mp); + break; + } + talk->tstate = STATE_REGISTER; + } + break; + } + } + } + if(err >= 0) + freemsg(data); + return err; + #if 0 isdn3_conn conn = NULL; uchar_t prot; @@ -152,12 +1342,20 @@ recv (isdn3_talk talk, char isUI, mblk_t * data) freemsg (data); return 0; #endif + less_room: + printf("CAPI error: too few data bytes\n"); + printit: + data->b_rptr = origmb; + log_printmsg(NULL,"CAPI recvErr",data,"="); + if(conn != NULL) + checkterm(conn); + return err ? err : -EINVAL; } static int send (isdn3_conn conn, mblk_t * data) { - printf("CAPI: send\n"); + printf("CAPI: send %08lx\n",conn->call_ref); return -ENXIO; #if 0 isdn3_prot prot = isdn3_findprot (conn->card->info, conn->subprotocol); @@ -174,8 +1372,144 @@ send (isdn3_conn conn, mblk_t * data) static int sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) { - printf("CAPI: sendcmd %x\n",id); - return -ENXIO; + streamchar *oldpos = NULL; + int err = 0; + ushort_t typ; + /* uchar_t suppress = 0; */ + /* uchar_t svc = 0; */ + struct capi_info *info; + int force = 0; + + printf("CAPI: sendcmd %08lx %04x: ",conn->call_ref,id); + { + mblk_t *mb = data; + if(mb == NULL) printf("NULL"); else + while(mb != NULL) { + dumpascii(mb->b_rptr,mb->b_wptr-mb->b_rptr); + mb = mb->b_cont; + } + } + printf("\n"); + if(conn->p_data == NULL) { + if((conn->p_data = malloc(sizeof(struct capi_info))) == NULL) { + return -ENOMEM; + } + bzero(conn->p_data,sizeof(struct capi_info)); + } + conn->lockit++; + info = conn->p_data; + if (data != NULL) { + unsigned long x; + + oldpos = data->b_rptr; + while ((err = m_getsx (data, &typ)) == 0) { + switch (typ) { + case ARG_SERVICE: + if ((err = m_getx (data, &x)) != 0) { + data->b_rptr = oldpos; + printf("GetX Service: "); + conn->lockit--; + return err; + } + info->service = x; + break; + case ARG_EAZ: + if ((err = m_getc (data, &info->eaz)) != 0) { + data->b_rptr = oldpos; + printf("GetX EAZ: "); + conn->lockit--; + return err; + } + break; + case ARG_NUMBER: + m_getskip (data); + if ((err = m_getstr (data, (char *) info->nr, MAXNR)) != 0) { + data->b_rptr = oldpos; + printf("GetStr Number: "); + conn->lockit--; + return err; + } + break; + case ARG_FORCE: + force = 1; + break; + default:; + } + } + data->b_rptr = oldpos; + } + err = 0; + switch (id) { + case CMD_ANSWER: + { + if (data == NULL) { + printf("DataNull: "); + conn->lockit--; + return -EINVAL; + } + if(conn->state != 7) { + printf("CAPI error: ANSWER in bad state!\n"); + conn->lockit--; + return -EINVAL; + } + err = send_setup(conn); + if(err == 0) { + freemsg(data); + setstate(conn,8); + conn->waitflags = 1 << WF_SELECTB2_CONF; + conn->waitflags |= 1 << WF_SELECTB3_CONF; + } else + send_disconnect(conn,0); + } + case CMD_DIAL: + { + if (data == NULL) { + printf("DataNull: "); + conn->lockit--; + return -EINVAL; + } + if(conn->state != 0) { + printf("CAPI error: DIAL in bad state!\n"); + conn->lockit--; + return -EINVAL; + } + { + struct CAPI_connect_req *c2; + mblk_t *m2 = allocb(sizeof(*c2)+strlen(info->nr),BPRI_MED); + + if(m2 == NULL) + return -ENOMEM; + c2 = ((typeof(c2))m2->b_wptr++); + bzero(c2,sizeof(*c2)); + c2->infomask = ~0; + c2->DST_service = info->service >> 8; + c2->DST_addinfo = info->service; + c2->SRC_eaz = info->eaz; + c2->telnolen = strlen(info->nr); + strcpy(m2->b_wptr,info->nr); + m2->b_wptr += strlen(info->nr); + if((err = capi_send(conn->talk,0,CAPI_CONNECT_REQ,m2,conn->conni[WF_CONNECT_CONF]=newmsgid(conn->talk))) < 0) + freemsg(m2); + else { + conn->waitflags = 1<card->info, conn->subprotocol); @@ -188,18 +1522,40 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) return EINVAL; } #endif + checkterm(conn); + return err; } static void report (isdn3_conn conn, mblk_t * data) { - printf("CAPI: report\n"); -#if 0 - isdn3_prot prot = isdn3_findprot (conn->card->info, conn->subprotocol); - - if (prot != NULL && prot->report != NULL) - (*prot->report) (conn, data); -#endif + struct capi_info *info; + printf("CAPI: report %08lx: ",conn->call_ref); + { + mblk_t *mb = data; + if(mb == NULL) printf("NULL"); else + while(mb != NULL) { + dumpascii(mb->b_rptr,mb->b_wptr-mb->b_rptr); + mb = mb->b_cont; + } + } + printf("\n"); + info = conn->p_data; + if (info == NULL) + return; + if (info->nr[0] != 0) { + m_putsx (data, ARG_NUMBER); + m_putsz (data, info->nr); + } + if (info->eaz != 0) { + m_putsx (data, ARG_EAZ); + *data->b_wptr++=' '; + *data->b_wptr++=info->eaz; + } + if (info->service != 0) { + m_putsx (data, ARG_SERVICE); + m_putx (data, info->service); + } } static void @@ -208,8 +1564,8 @@ ckill (isdn3_talk talk, char force) printf("CAPI: ckill %d\n",force); #if 0 if (force) { - if (talk->state & PHONE_UP) { - talk->state &= ~PHONE_UP; + if (talk->tstate & PHONE_UP) { + talk->tstate &= ~PHONE_UP; if(0)printf("Phone is aDown\n"); isdn3_chstate (talk, DL_RELEASE_REQ, 0, CH_CLOSEPROT); } @@ -220,7 +1576,17 @@ ckill (isdn3_talk talk, char force) static void killconn (isdn3_conn conn, char force) { - printf("CAPI: killconn %d\n",force); + printf("CAPI: killconn %08lx: %d\n",conn->call_ref,force); + if (conn->p_data != NULL) { + free (conn->p_data); + conn->p_data = NULL; + } + if (force) { + untimer (CAPI_TALERT, conn); + } + switch(conn->state) { + } + #if 0 isdn3_talk talk = conn->talk; isdn3_prot prot = isdn3_findprot (conn->card->info, conn->subprotocol); @@ -228,9 +1594,9 @@ killconn (isdn3_conn conn, char force) if (prot != NULL) (*prot->killconn) (conn, force); - if (talk != NULL && talk->conn == NULL && (talk->state & PHONE_UP)) { + if (talk != NULL && talk->conn == NULL && (talk->tstate & PHONE_UP)) { /* Last talker got closed. Shutdown for level 2. */ - talk->state &= ~PHONE_UP; + talk->tstate &= ~PHONE_UP; if(0)printf ("PHONE i2s DOWN\n"); (void) isdn3_chstate (talk, DL_RELEASE_REQ, 0, CH_CLOSEPROT); } else { @@ -239,8 +1605,8 @@ killconn (isdn3_conn conn, char force) if (talk == NULL) printf (": Talk NULL"); else if (talk->conn != NULL) - printf (": talk->conn %x (ref %d, state %d)", talk->conn, talk->conn->call_ref, talk->conn->state); - if (!(talk->state & PHONE_UP)) + printf (": talk->conn %x (ref %08lx, state %d)", talk->conn, talk->conn->call_ref, talk->conn->state); + if (!(talk->tstate & PHONE_UP)) if(0)printf (": PHONE i3s DOWN\n"); printf ("\n"); #endif @@ -251,7 +1617,7 @@ killconn (isdn3_conn conn, char force) static void hook (isdn3_conn conn) { - printf("CAPI: hook\n"); + printf("CAPI: hook %08lx\n",conn->call_ref); #if 0 isdn3_prot prot = isdn3_findprot (conn->card->info, conn->subprotocol); @@ -264,20 +1630,46 @@ hook (isdn3_conn conn) static void newcard (isdn3_card card) { + isdn3_talk talk; + printf("CAPI: newcard\n"); - (void) isdn3_findtalk (card, &CAPI_hndl, card->info, 1); + talk = isdn3_findtalk (card, &CAPI_hndl, card->info, 1); + if(talk == NULL) { + printf("CAPI: newcard: talker not found ???\n"); + return; + } + talk->message_id = 0x4000; + talk->tstate = STATE_BOOTING; + if(card->is_up) + chstate (talk, DL_ESTABLISH_CONF,0); - /* That's enough. */ } static ulong_t modeflags (long protocol) { - printf("CAPI: modeflags\n"); + printf("CAPI: modeflags %lx\n",protocol); return 1 << M_HDLC || 1 << CHM_INTELLIGENT; } +static int +proto(struct _isdn3_conn * conn, mblk_t **data, char down) +{ + mblk_t *mb = *data; + + printf("CAPI: proto %08lx %s: ",conn->call_ref, down ? "down" : "up"); + if(mb == NULL) printf("NULL"); else + while(mb != NULL) { + dumpascii(mb->b_rptr,mb->b_wptr-mb->b_rptr); + mb = mb->b_cont; + } + printf("\n"); + + return 0; +} + + static void init (void) { @@ -288,5 +1680,6 @@ struct _isdn3_hndl CAPI_hndl = { NULL, /* SAPI */ 65,0, &init, &newcard, &modeflags, &chstate, &report, &recv, &send, - &sendcmd, &ckill, &killconn, &hook, + &sendcmd, &ckill, &killconn, &hook, &proto, }; + diff --git a/isdn_3/fixed.c b/isdn_3/fixed.c index 215359e..a952e54 100644 --- a/isdn_3/fixed.c +++ b/isdn_3/fixed.c @@ -9,8 +9,8 @@ #include #include #include +#include "sapi.h" -#define SAPI_FIXED 64 #define ST_up 01 static int @@ -102,7 +102,7 @@ fixed_sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) { if (data == NULL) { printf("DataInvalA "); - return EINVAL; + return -EINVAL; } while ((err = m_getsx (data, &typ)) == 0) { switch (typ) { @@ -124,9 +124,9 @@ fixed_sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) case 0: case 2: if (conn->minor == 0) - return ENOENT; + return -ENOENT; if (conn->mode == 0) - err = ENOEXEC; + err = -ENOEXEC; conn->state++; { int err = 0; @@ -135,7 +135,7 @@ fixed_sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (mb == NULL) { conn->state = 0; - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_CONN); conn_info (conn, mb); @@ -150,7 +150,7 @@ fixed_sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) } break; default: - return EBUSY; + return -EBUSY; } } break; @@ -179,7 +179,7 @@ fixed_sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) } break; default: - err = EINVAL; + err = -EINVAL; break; } if (data != NULL && err == 0) @@ -220,5 +220,6 @@ struct _isdn3_hndl FIXED_hndl = { NULL, SAPI_FIXED,1, NULL, &fixed_newcard, NULL, &fixed_chstate, NULL, NULL, - NULL, &fixed_sendcmd, NULL, &fixed_killconn, NULL, + NULL, &fixed_sendcmd, NULL, &fixed_killconn, NULL, NULL, }; + diff --git a/isdn_3/isdn_3.c b/isdn_3/isdn_3.c index 3d85578..78615de 100644 --- a/isdn_3/isdn_3.c +++ b/isdn_3/isdn_3.c @@ -23,15 +23,27 @@ #include "isdn_3.h" #include "isdn_34.h" #include "lap.h" +#ifdef _tei_ #include "tei.h" +#endif +#ifdef _fixed_ #include "fixed.h" +#endif +#ifdef _phone_ #include "phone.h" +#endif +#ifdef _capi_ #include "capi.h" +#endif #include "isdn_limits.h" #include "isdn_proto.h" #ifndef KERNEL #include #endif +#include "sapi.h" + +ushort_t hdrseq = 2; + /* * Global data. These should be allocated dynamically. They are not because * most kernels don't have a way to find out how much kernel memory is left, @@ -105,7 +117,7 @@ static void later_conn (isdn3_conn conn); #if 0 /* def CONFIG_DEBUG_ISDN */ void l3chk(void) { int i; for(i=1;ifminor != 0) { m_putsx (mb, ARG_FMINOR); m_puti (mb, conn->fminor); - CHK } - CHK } + } + } if (conn->minorstate & MS_SENTINFO) return; if (conn->card != NULL) { m_putsx (mb, ARG_CARD); m_putlx (mb, conn->card->id); - CHK } + } if (conn->minorstate & (MS_INCOMING | MS_OUTGOING)) m_putsx (mb, (conn->minorstate & MS_INCOMING) ? PROTO_INCOMING : PROTO_OUTGOING); if (conn->stack[0] != 0) { m_putsx (mb, ARG_STACK); m_putsz (mb, conn->stack); - CHK } + } if (conn->talk != NULL) { m_putsx (mb, ARG_PROTOCOL); m_puti (mb, conn->talk->hndl->SAPI); m_putsx (mb, ARG_SUBPROT); m_puti (mb, conn->subprotocol); - CHK } + } if (conn->call_ref != 0) { m_putsx (mb, ARG_CALLREF); m_puti (mb, conn->call_ref); - CHK } + } if (conn->minorstate & MS_INITPROTO) { m_putsx (mb, ARG_MODE); m_puti (mb, conn->mode); - CHK } + } if (conn->minorstate & MS_BCHAN) { m_putsx (mb, ARG_CHANNEL); m_puti (mb, conn->bchan); - CHK } + } if(conn->talk != NULL && conn->talk->hndl->report != NULL) (*conn->talk->hndl->report) (conn, mb); -CHK } +} /* * Disconnect timeout procedure. Implements the delay between sending @@ -197,9 +209,9 @@ timeout_disc (isdn3_conn conn) if (conn->minorstate & MS_END_TIMER) { conn->minorstate &= ~MS_END_TIMER; isdn3_killconn (conn, 3); - CHK } + } return 0; -CHK } +} /* --> isdn_3.h */ #ifdef CONFIG_DEBUG_ISDN @@ -220,15 +232,16 @@ isdn3_killconn (isdn3_conn conn, char force) conn->id = 0; if ((conn->delay > 0) && (conn->minorstate & MS_DELAYING)) { + printf("** Kill DELAYING %p\n",conn); #ifdef NEW_TIMEOUT untimeout (conn->later_timer); #else untimeout (later_conn, conn); #endif - CHK } else if (conn->delay == 0 && force == 0 && (conn->minorstate & MS_DELAYING)) { + } else if (conn->delay == 0 && force == 0 && (conn->minorstate & MS_DELAYING)) { splx (ms); return; - CHK } + } conn->delay = 0; conn->minorstate |= MS_DELAYING; @@ -239,7 +252,7 @@ isdn3_killconn (isdn3_conn conn, char force) #else untimeout (delay_conn, conn); #endif - CHK } + } if (conn->minorstate & MS_CONN_TIMER) { /* Kill connection startup * timer if it's running */ conn->minorstate &= ~MS_CONN_TIMER; @@ -248,7 +261,7 @@ isdn3_killconn (isdn3_conn conn, char force) #else untimeout (timeout_conn, conn); #endif - CHK } + } if (conn->hupdelay && ((minorflags[conn->minor] & MINOR_STATE_MASK) == MINOR_CONN_SENT || (minorflags[conn->minor] & MINOR_STATE_MASK) == MINOR_LISTEN_SENT) @@ -259,7 +272,7 @@ isdn3_killconn (isdn3_conn conn, char force) if (conn->minorstate & MS_END_TIMER) { /* Already did that */ splx (ms); return; - CHK } + } if (isdn3_setup_conn (conn, (force & 2) ? EST_WILL_INTERRUPT : EST_WILL_DISCONNECT) == 0) { #ifdef NEW_TIMEOUT conn->disc_timer = @@ -270,10 +283,10 @@ isdn3_killconn (isdn3_conn conn, char force) conn->hupdelay = 0; splx (ms); return; - CHK } else { /* Unable. Kill it immediately. */ + } else { /* Unable. Kill it immediately. */ force = 1; - CHK } - CHK } + } + } if (conn->minorstate & MS_END_TIMER) { /* Timer running? */ if (!(force & 1)) { /* Need to kill the connection now? */ conn->minorstate &= ~MS_END_TIMER; @@ -282,11 +295,11 @@ isdn3_killconn (isdn3_conn conn, char force) #else untimeout (timeout_disc, conn); #endif - CHK } else { + } else { splx (ms); return; - CHK } - CHK } + } + } if (conn->minor != 0 && conn->fminor != 0 && conn->minor != conn->fminor && (minorflags[conn->minor] & (MINOR_OPEN | MINOR_INT) == MINOR_OPEN)) { /* * The minor is open and it's not the control channel. Tell the lower @@ -298,18 +311,19 @@ isdn3_killconn (isdn3_conn conn, char force) if (mb != NULL) { hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif hdr->key = HDR_CLOSE|HDR_NOERROR; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_close.minor = conn->minor; hdr->hdr_close.error = 0; if (isdn3_sendhdr (mb) != 0) freeb (mb); - CHK } - CHK } + } + } if (conn->minor != 0 && isdn3_findminor (conn->minor) == conn) { isdn3_setup_conn (conn, (force & 2) ? EST_INTERRUPT : EST_DISCONNECT); - CHK } + } if(!(force & 1)) force = 0; if (talk != NULL) { @@ -318,7 +332,7 @@ isdn3_killconn (isdn3_conn conn, char force) * connection down. */ if (force) conn->state = 0; - CHK } else + } else conn->state = 0; if(0)printf ("\n\n*** KillConn: State %d, Force %d\n", conn->state, force); @@ -326,36 +340,36 @@ isdn3_killconn (isdn3_conn conn, char force) * unlink from talk->conn->next chain. */ if (conn->minor != 0 && isdn3_findminor (conn->minor) == conn) { minor2conn[conn->minor] = NULL; - CHK } + } if(conn->lockit > 0) return; if (conn->minor != 0 && conn->fminor != 0) { if (conn->fminor != conn->minor) minor2conn[conn->fminor] = 0; - CHK } + } if (talk == NULL) ; else if (talk->conn == NULL) talk = NULL; else if (talk->conn == conn) { talk->conn = conn->next; - CHK } else { + } else { isdn3_conn nconn; for (nconn = talk->conn; nconn != NULL; nconn = nconn->next) { if (nconn->next == conn) { nconn->next = conn->next; break; - CHK } - CHK } + } + } if (nconn == NULL) conn = NULL; - CHK } + } if (conn == NULL && talk != NULL) { splx (ms); printf ("PANIC Conn not in talk chain\n"); return; - CHK } else { + } else { if (talk != NULL && talk->hndl->kill != NULL) (*talk->hndl->kill) (talk, 0); if(conn != NULL) { @@ -365,23 +379,23 @@ isdn3_killconn (isdn3_conn conn, char force) conn->minor = 0; conn->fminor = 0; /* minorflags[conn->minor] &= MINOR_OPEN; */ - CHK } + } { int i; for(i=0;iminor); minor2conn[i]=NULL; } } if(conn->id_msg != NULL) freemsg(conn->id_msg); - for(i=0;iv[i] != NULL) - free(conn->v[i]); + for(i=0;i < NSCONN; i++) { + if(conn->conns[i] != NULL) + free(conn->conns[i]); } free(conn); - CHK } - CHK } - CHK } + } + } + } splx (ms); -CHK } +} /* * Watchdog timer. If a connection isn't fully established within two minutes, @@ -394,9 +408,9 @@ timeout_conn (isdn3_conn conn) if (conn->minorstate & MS_CONN_TIMER) { conn->minorstate &= ~MS_CONN_TIMER; isdn3_killconn (conn, 0); - CHK } + } return 0; -CHK } +} /* * Delay timer. Often, a connection it established in one direction only for @@ -409,9 +423,9 @@ delay_conn (isdn3_conn conn) if (conn->minorstate & MS_CONNDELAY_TIMER) { conn->minorstate &= ~MS_CONNDELAY_TIMER; isdn3_setup_conn (conn, EST_NO_CHANGE); - CHK } + } return 0; -CHK } +} /* * Delay establishing the connection -- wait for someone else to pick it up @@ -420,11 +434,11 @@ CHK } static void later_conn (isdn3_conn conn) { - if(0)printf ("*Unset DELAYING\n"); + if(1)printf ("**Hit DELAYING %p\n",conn); conn->minorstate &= ~MS_DELAYING; conn->delay = 0; isdn3_setup_conn (conn, EST_NO_CHANGE); -CHK } +} /* --> isdn_3.h */ @@ -445,11 +459,11 @@ isdn3_repeat (isdn3_conn conn, ushort_t id, mblk_t * data) linkb (mb, conn->id_msg); if (isdn3_at_send (conn, mb, 0) != 0) freemsg (mb); - CHK } - CHK } + } + } conn->id = id; conn->id_msg = data; -CHK } +} /* --> isdn_3.h */ int @@ -458,7 +472,6 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi int err = 0; mblk_t *mb; - /** ** State (Flags) ** -1 B channel (MS_BCHAN) @@ -477,10 +490,10 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi conn->lockit++; #ifdef REPORT - printf ("ConnAttach%p %d(%d/%d) %lo/%o %d %s:%d: ", conn, conn->conn_id, conn->minor, - conn->fminor, conn->minorstate, - (conn->minor > 0) ? minorflags[conn->minor]: 0, established, - deb_file, deb_line); + printf ("ConnAttach %p Delay%d %d(%d/%d) %lo/%o %d %s:%d: ", + conn, conn->delay, conn->conn_id, conn->minor, conn->fminor, + conn->minorstate, (conn->minor > 0) ? minorflags[conn->minor]: 0, + established, deb_file, deb_line); #endif if((conn->minor > 0) && (minorflags[conn->minor] & MINOR_PROTO)) conn->minorstate |= MS_PROTO; @@ -491,18 +504,20 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi */ if (conn->delay > 0) { if (conn->minorstate & MS_DELAYING) { + if(1)printf("** Clear DELAYING %p\n",conn); #ifdef NEW_TIMEOUT untimeout (conn->later_timer); #else untimeout (later_conn, conn); #endif - CHK } + } + printf("** Set DELAYING %p\n",conn); #ifdef NEW_TIMEOUT conn->later_timer = #endif timeout (later_conn, conn, conn->delay * HZ); conn->minorstate |= MS_DELAYING; - CHK } + } /* * Initiate setting up the protocol stack. This is done via L4. */ @@ -514,14 +529,14 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi && (conn->minorstate & MS_WANTCONN) && canput (isdn3_q->q_next)) { if ((mb = allocb (128, BPRI_HI)) == NULL) { - err = ENOMEM; + err = -ENOMEM; goto exitme; } m_putid (mb, (minorflags[conn->minor] & MINOR_INITPROTO_SENT2) ? IND_PROTO_AGAIN : IND_PROTO); conn_info (conn, mb); putnext (isdn3_q, mb); minorflags[conn->minor] |= MINOR_INITPROTO_SENT | MINOR_INITPROTO_SENT2; - CHK } + } #ifdef REPORT else if (!(minorflags[conn->minor] & MINOR_INITPROTO_SENT)) { printf ("-InitProto: "); @@ -535,7 +550,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi printf ("Stack zero; "); if (conn->minorstate & MS_DETACHED) printf ("Detached; "); - CHK } + } #endif /* @@ -548,14 +563,14 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi && (conn->minorstate & MS_WANTCONN) && canput (isdn3_q->q_next)) { if ((mb = allocb (128, BPRI_HI)) == NULL) { - err = ENOMEM; + err = -ENOMEM; goto exitme; } m_putid (mb, IND_CARDPROTO); conn_info (conn, mb); putnext (isdn3_q, mb); conn->minorstate |= MS_INITPROTO_SENT; - CHK } + } #ifdef REPORT else if (!(conn->minorstate & MS_INITPROTO_SENT)) { printf ("-InitCard: "); @@ -571,7 +586,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi printf ("Detached; "); if (conn->minorstate & MS_INITPROTO_SENT) printf ("DidInitProto; "); - CHK } + } #endif /* If detached and connecting, clear detached flag */ @@ -592,14 +607,15 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) { - err = EAGAIN; + err = -EAGAIN; goto exitme; } hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif hdr->key = HDR_ATTACH; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_attach.minor = conn->minor; hdr->hdr_attach.card = conn->card->nr; hdr->hdr_attach.chan = conn->bchan; @@ -608,10 +624,10 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi if ((err = isdn3_sendhdr (mb)) != 0) { freeb (mb); goto exitme; - CHK } + } conn->minorstate |= MS_SETUP_SENT; conn->minorstate &=~ MS_DETACHED; - CHK } + } #ifdef REPORT else if (!(conn->minorstate & MS_SETUP_SENT)) { printf ("-SentAttach: "); @@ -636,7 +652,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi printf ("Card mode not set; "); if (!(minorflags[conn->minor] & MINOR_PROTO)) printf ("Protocol stack not set; "); - CHK } + } #endif /* @@ -647,7 +663,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi && !(conn->minorstate & MS_DIR_SENT)) { mb = allocb (3, BPRI_HI); if (mb == NULL) { - err = ENOMEM; + err = -ENOMEM; goto exitme; } m_putid(mb,(conn->minorstate & MS_INCOMING) ? PROTO_INCOMING : PROTO_OUTGOING); @@ -657,14 +673,14 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi return err; mb = allocb (10,BPRI_HI); if (mb == NULL) { - err = ENOMEM; + err = -ENOMEM; goto exitme; } m_putid(mb,PROTO_OFFSET); m_puti(mb,0); if ((err = isdn3_send_conn (conn->minor, AS_PROTO, mb)) != 0) goto exitme; - CHK } + } #ifdef REPORT else if (!(conn->minorstate & MS_DIR_SENT)) { printf ("-SentDir: "); @@ -674,7 +690,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi printf ("Unknown; "); if (!(minorflags[conn->minor] & MINOR_PROTO)) printf ("Protocol stack not set; "); - CHK } + } #endif /* @@ -686,14 +702,14 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi if ((conn->minor != 0) && (minorflags[conn->minor] & MINOR_PROTO)) { mb = allocb (3, BPRI_HI); if (mb == NULL) - err = ENOMEM; + err = -ENOMEM; else { m_putid (mb, (established == EST_WILL_INTERRUPT) ? PROTO_WILL_INTERRUPT : PROTO_WILL_DISCONNECT); if ((err = isdn3_send_conn (conn->minor, AS_PROTO, mb)) != 0) freemsg (mb); - CHK } + } break; - CHK } else + } else established = EST_DISCONNECT; case EST_DISCONNECT: conn->minorstate &= ~MS_CONN_MASK; @@ -705,7 +721,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi #else untimeout (timeout_conn, conn); #endif - CHK } + } if (conn->minorstate & MS_CONNDELAY_TIMER) { conn->minorstate &= ~MS_CONNDELAY_TIMER; #ifdef NEW_TIMEOUT @@ -713,7 +729,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi #else untimeout (delay_conn, conn); #endif - CHK } + } break; case EST_INTERRUPT: conn->minorstate &= ~MS_CONN_MASK; @@ -725,7 +741,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi #else untimeout (timeout_conn, conn); #endif - CHK } + } if (conn->minorstate & MS_CONNDELAY_TIMER) { conn->minorstate &= ~MS_CONNDELAY_TIMER; #ifdef NEW_TIMEOUT @@ -733,7 +749,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi #else untimeout (delay_conn, conn); #endif - CHK } + } break; case EST_LISTEN: conn->minorstate &= ~MS_CONN_MASK; @@ -744,7 +760,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi conn->start_timer = #endif timeout (timeout_conn, conn, HZ * 120); - CHK } + } break; case EST_CONNECT: { @@ -758,8 +774,8 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi conn->delay_timer = #endif timeout (delay_conn, conn, (HZ * (flags & FL_UPDELAY)) >> FL_UPDELAY_SHIFT); - CHK } - CHK } + } + } conn->minorstate &= ~MS_CONN_MASK; conn->minorstate |= MS_CONN; if ((minorflags[conn->minor] & MINOR_STATE_MASK) != MINOR_CONN_SENT) { @@ -769,10 +785,10 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi conn->start_timer = #endif timeout (timeout_conn, conn, HZ * 120); - CHK } - CHK } + } + } break; - CHK } + } /* * If the protocol stack is set up, tell it about the change. */ @@ -782,52 +798,52 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi if ((minorflags[conn->minor] & MINOR_STATE_MASK) != MINOR_STATE_NONE) { mb = allocb (3, BPRI_HI); if (mb == NULL) - err = ENOMEM; + err = -ENOMEM; else { m_putid (mb, PROTO_DISCONNECT); if ((err = isdn3_send_conn (conn->minor, AS_PROTO, mb)) == 0) { minorflags[conn->minor] &= ~MINOR_STATE_MASK; minorflags[conn->minor] |= MINOR_STATE_NONE; - CHK } else + } else freeb (mb); - CHK } - CHK } + } + } break; case MS_CONN_INTERRUPT: if ((minorflags[conn->minor] & MINOR_STATE_MASK) != MINOR_INTERRUPT_SENT) { mb = allocb (3, BPRI_HI); if (mb == NULL) - err = ENOMEM; + err = -ENOMEM; else { m_putid (mb, PROTO_INTERRUPT); if ((err = isdn3_send_conn (conn->minor, AS_PROTO, mb)) == 0) { minorflags[conn->minor] &= ~MINOR_STATE_MASK; minorflags[conn->minor] |= MINOR_INTERRUPT_SENT; - CHK } else + } else freeb (mb); - CHK } - CHK } + } + } break; case MS_CONN_LISTEN: if ((minorflags[conn->minor] & MINOR_STATE_MASK) != MINOR_LISTEN_SENT) { mb = allocb (3, BPRI_HI); if (mb == NULL) - err = ENOMEM; + err = -ENOMEM; else { m_putid (mb, PROTO_LISTEN); if ((err = isdn3_send_conn (conn->minor, AS_PROTO, mb)) == 0) { minorflags[conn->minor] &= ~MINOR_STATE_MASK; minorflags[conn->minor] |= MINOR_LISTEN_SENT; - CHK } else + } else freeb (mb); - CHK } - CHK } + } + } break; case MS_CONN: if (((minorflags[conn->minor] & MINOR_STATE_MASK) != MINOR_CONN_SENT) && !(conn->minorstate & MS_CONNDELAY_TIMER)) { mb = allocb (3, BPRI_HI); if (mb == NULL) - err = ENOMEM; + err = -ENOMEM; else { m_putid (mb, PROTO_CONNECTED); if ((err = isdn3_send_conn (conn->minor, AS_PROTO, mb)) == 0) { @@ -841,14 +857,14 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi #else untimeout (timeout_conn, conn); #endif - CHK } - CHK } else + } + } else freeb (mb); - CHK } - CHK } + } + } break; - CHK } - CHK } + } + } /* * If taking down the connection, detach it. */ @@ -867,7 +883,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi #else untimeout (delay_conn, conn); #endif - CHK } + } if (conn->minorstate & MS_CONN_TIMER) { conn->minorstate &= ~MS_CONN_TIMER; #if NEW_TIMEOUT @@ -875,32 +891,33 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi #else untimeout (timeout_conn, conn); #endif - CHK } + } if ((conn->minorstate && MS_SETUP_SENT) && !(conn->minorstate & (MS_NOMINOR | MS_DETACHED)) && (minor2conn[conn->minor] == conn || minor2conn[conn->minor] == NULL) && ((mp = allocb (sizeof (struct _isdn23_hdr), BPRI_MED)) != NULL)) { hdr = ((isdn23_hdr) mp->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif hdr->key = HDR_DETACH; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_detach.minor = conn->minor; hdr->hdr_detach.error = 0; hdr->hdr_detach.perm = 0; if ((err = isdn3_sendhdr (mp)) != 0) { freeb (mp); - CHK } - CHK } + } + } conn->minorstate &= ~MS_SETUP_SENT; conn->minorstate |= MS_DETACHED; if ((established < EST_INTERRUPT) && !(minorflags[conn->minor] & MINOR_INT)) { minorflags[conn->minor] &= ~MINOR_INITPROTO_SENT; - CHK } + } conn->minorstate &=~ MS_INITPROTO; #ifdef REPORT printf (" SentDetach %d ",conn->minor); #endif - CHK } + } #ifdef REPORT else { printf (" -Detach: "); @@ -912,7 +929,7 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi printf ("MS %lx ", conn->minorstate); if (!(minorflags[conn->minor] & (MINOR_PROTO | MINOR_INITPROTO_SENT))) printf ("MF %x ", minorflags[conn->minor]); - CHK } + } printf ("\n"); #endif if (conn->talk == NULL) @@ -924,16 +941,16 @@ Xisdn3_setup_conn (isdn3_conn conn, char established, const char *deb_file, unsi conn->id = 0; conn->id_msg = NULL; (*conn->talk->hndl->sendcmd) (conn, id, msg); - CHK } + } if (conn->talk->hndl->hook != NULL) { (*conn->talk->hndl->hook) (conn); - CHK } + } exitme: conn->lockit--; if (conn->lockit == 0 && conn->state==0) isdn3_killconn(conn,0); return err; -CHK } +} /* --> isdn_3.h */ isdn3_conn @@ -946,11 +963,11 @@ isdn3_new_conn (isdn3_talk talk) if (talk == NULL) { printf ("PANIC: isdn3_new_conn(talk NULL)\n"); return NULL; - CHK } + } conn = malloc(sizeof(*conn)); if(conn == NULL) return NULL; - bzero ((caddr_t) conn, sizeof (*conn)); + memset(conn,0,sizeof (*conn)); ms = splstr(); conn->conn_id = conn_id; @@ -962,7 +979,7 @@ isdn3_new_conn (isdn3_talk talk) conn_id += 2; splx (ms); return conn; -CHK } +} /* --> isdn_3.h */ int @@ -976,9 +993,9 @@ isdn3_new_callref (isdn3_talk talk) for (conn = talk->conn; conn != NULL; conn = conn->next) if (cref == conn->call_ref) break; - CHK } while (conn != NULL); + } while (conn != NULL); return cref; -CHK } +} /* --> isdn_3.h */ void @@ -986,6 +1003,7 @@ isdn3_killtalk (isdn3_talk talk) { int ms = splstr (); isdn3_card card = talk->card; + int i; (void) isdn3_chstate (talk, 0, 0, CH_CLOSEPROT); @@ -994,32 +1012,36 @@ isdn3_killtalk (isdn3_talk talk) talk = NULL; else if (card->talk == talk) { card->talk = talk->next; - CHK } else { + } else { isdn3_talk ntalk; for (ntalk = card->talk; ntalk != NULL; ntalk = ntalk->next) { if (ntalk->next == talk) { ntalk->next = talk->next; break; - CHK } - CHK } + } + } if (ntalk == NULL) talk = NULL; - CHK } + } if (talk == NULL) { splx (ms); printf ("PANIC Talk not in card chain\n"); return; - CHK } + } /* Force disconnect and removal of all connections. */ while (talk->conn != NULL) isdn3_killconn (talk->conn, 1); if (talk->hndl->kill != NULL) (*talk->hndl->kill) (talk, 1); + for(i=0;i < NSTALK; i++) { + if(talk->talks[i] != NULL) + free(talk->talks[i]); + } free(talk); splx (ms); -CHK } +} /* --> isdn_3.h */ int @@ -1028,9 +1050,9 @@ isdn3_sendhdr (mblk_t * mb) if (isdn3_q != NULL) { putnext (WR (isdn3_q), mb); return 0; - CHK } else - return ENXIO; -CHK } + } else + return -ENXIO; +} /* --> isdn_3.h */ int @@ -1042,19 +1064,20 @@ isdn3_send_conn (SUBDEV minor, char what, mblk_t * data) if (minor == 0 || minor >= NMINOR) { printf("ErX l\n"); - return EINVAL; + return -EINVAL; } mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) - return ENOMEM; + return -ENOMEM; hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif switch (what) { case AS_XDATA: hdr->key = HDR_XDATA; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_xdata.minor = minor; hdr->hdr_xdata.len = dsize (data); break; @@ -1064,19 +1087,20 @@ printf("ErX l\n"); case AS_PROTO_NOERR: hdr->key = HDR_PROTOCMD|HDR_NOERROR; cont_proto: + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_protocmd.minor = minor; hdr->hdr_protocmd.len = dsize (data); break; default: freeb (mb); printf("ErX b\n"); - return EINVAL; - CHK } + return -EINVAL; + } linkb (mb, data); if ((err = isdn3_sendhdr (mb)) != 0) freeb (mb); return err; -CHK } +} /* --> isdn_3.h */ int @@ -1089,15 +1113,16 @@ isdn3_send (isdn3_talk talk, char what, mblk_t * data) mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) - return ENOMEM; + return -ENOMEM; hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif switch (what) { case AS_UIDATA: case AS_UIBROADCAST: hdr->key = HDR_UIDATA; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_uidata.card = talk->card->nr; hdr->hdr_uidata.SAPI = talk->hndl->SAPI; hdr->hdr_uidata.broadcast = (what == AS_UIBROADCAST); @@ -1105,6 +1130,7 @@ isdn3_send (isdn3_talk talk, char what, mblk_t * data) break; case AS_DATA: hdr->key = HDR_DATA; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_data.card = talk->card->nr; hdr->hdr_data.SAPI = talk->hndl->SAPI; hdr->hdr_data.len = dsize (data); @@ -1112,13 +1138,13 @@ isdn3_send (isdn3_talk talk, char what, mblk_t * data) default: freeb (mb); printf("ErX c\n"); - return EINVAL; - CHK } + return -EINVAL; + } linkb (mb, data); if ((err = isdn3_sendhdr (mb)) != 0) freeb (mb); return err; -CHK } +} /* --> isdn_3.h */ int @@ -1138,13 +1164,13 @@ isdn3_at_send (isdn3_conn conn, mblk_t * data, char bypass) if (minor == 0) { putnext (isdn3_q, data); return 0; - CHK } + } if (!bypass) { mblk_t *mm = allocb (32, BPRI_MED); ushort_t ind; if (mm == NULL) - return ENOMEM; + return -ENOMEM; #if 0 m_putid (mm, IND_ATRESP); m_putsx (mm, ARG_FMINOR); @@ -1155,7 +1181,7 @@ isdn3_at_send (isdn3_conn conn, mblk_t * data, char bypass) if(ind == IND_INFO) { m_putid(mm,ind); m_getid(data,&ind); - CHK } + } m_putid(mm,ind); m_putsx (mm, ARG_FMINOR); m_puti (mm, minor); @@ -1165,23 +1191,24 @@ isdn3_at_send (isdn3_conn conn, mblk_t * data, char bypass) linkb (mm, data); putnext (isdn3_q, mm); return 0; - CHK } + } mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) - return EAGAIN; + return -EAGAIN; hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif hdr->key = HDR_ATCMD; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_atcmd.minor = minor; hdr->hdr_atcmd.len = dsize (data); linkb (mb, data); if ((err = isdn3_sendhdr (mb)) != 0) freeb (mb); return err; -CHK } +} /* --> isdn_3.h */ int @@ -1194,14 +1221,15 @@ isdn3_chstate (isdn3_talk talk, uchar_t ind, short add, char what) mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) - return EAGAIN; + return -EAGAIN; hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif switch (what) { case CH_MSG: hdr->key = HDR_NOTIFY; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_notify.card = talk->card->nr; hdr->hdr_notify.SAPI = talk->hndl->SAPI; hdr->hdr_notify.ind = ind; @@ -1209,6 +1237,7 @@ isdn3_chstate (isdn3_talk talk, uchar_t ind, short add, char what) break; case CH_OPENPROT: hdr->key = HDR_OPENPROT; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_openprot.card = talk->card->nr; hdr->hdr_openprot.SAPI = talk->hndl->SAPI; hdr->hdr_openprot.ind = ind; @@ -1216,6 +1245,7 @@ isdn3_chstate (isdn3_talk talk, uchar_t ind, short add, char what) break; case CH_CLOSEPROT: hdr->key = HDR_CLOSEPROT|HDR_NOERROR; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_closeprot.card = talk->card->nr; hdr->hdr_closeprot.SAPI = talk->hndl->SAPI; hdr->hdr_closeprot.ind = ind; @@ -1223,12 +1253,12 @@ isdn3_chstate (isdn3_talk talk, uchar_t ind, short add, char what) default: freeb (mb); printf("ErX d\n"); - return EINVAL; - CHK } + return -EINVAL; + } if ((err = isdn3_sendhdr (mb)) != 0) freeb (mb); return err; -CHK } +} /* --> isdn_3.h */ @@ -1245,14 +1275,14 @@ isdn3_free_b (isdn3_card card) if (conn->bchan == bc) { bc = 0; break; - CHK } - CHK } - CHK } + } + } + } if (bc > 0) return bc; - CHK } + } return 0; -CHK } +} /* * Scans and interprets a command string. Unknown commands are redirected to @@ -1292,7 +1322,7 @@ scan_at (SUBDEV fminor, mblk_t * mx) mx = pullupm (mx, -1); if (mx == NULL) - return ENOMEM; /* We have not clobbered the original + return -ENOMEM; /* We have not clobbered the original * argument! */ /* @@ -1334,7 +1364,7 @@ scan_at (SUBDEV fminor, mblk_t * mx) putnext (isdn3_q, mm); mx = NULL; goto ok_out; - CHK } + } break; #endif case ARG_FMINOR: @@ -1342,22 +1372,22 @@ scan_at (SUBDEV fminor, mblk_t * mx) long nm; if (fminor != 0) { - err = EPERM; + err = -EPERM; goto err_out; - CHK } + } if ((err = m_geti (mx, &nm)) != 0) goto err_out; if (nm <= 0 || nm >= NMINOR) { - err = ENXIO; + err = -ENXIO; goto err_out; - CHK } + } if (conn != NULL && conn->minor != 0 && conn->fminor != 0 && conn->fminor != nm) { printf("ErX e\n"); - err = EINVAL; + err = -EINVAL; goto err_out; - CHK } + } fminor = nm; - CHK } + } break; case ARG_CONNREF: { @@ -1366,7 +1396,7 @@ printf("ErX e\n"); if ((err = m_geti (mx, &nm)) != 0) goto err_out; conn_id = nm; - CHK } + } break; case ARG_SEQNUM: { @@ -1375,7 +1405,7 @@ printf("ErX e\n"); if ((err = m_geti (mx, &nm)) != 0) goto err_out; seqnum = nm; - CHK } + } break; case ARG_OFFSET: { @@ -1384,7 +1414,7 @@ printf("ErX e\n"); if ((err = m_geti (mx, &nm)) != 0) goto err_out; foffset = nm; - CHK } + } break; case ARG_CARD: { @@ -1394,14 +1424,14 @@ printf("ErX e\n"); goto err_out; card = isdn3_findcardid(nm); if (card == NULL) { - err = ENXIO; + err = -ENXIO; goto err_out; - CHK } + } if (conn != NULL && conn->card != NULL && conn->card != card) { printf("ErX f\n"); - err = EINVAL; + err = -EINVAL; goto err_out; - CHK } + } if (card->info != NULL && subprotocol == -1) { mblk_t *mi = card->info; streamchar *sta = mi->b_rptr; @@ -1422,13 +1452,13 @@ printf(" Grab SP %ld; ",subprotocol); } mi->b_rptr = sta; } - CHK } + } break; case ARG_STACK: { if ((err = m_getstr (mx, stack, sizeof(stack)-1)) != 0) goto err_out; - CHK } + } break; case ARG_CHANNEL: { @@ -1438,15 +1468,15 @@ printf(" Grab SP %ld; ",subprotocol); goto err_out; if (nm < 0) { printf("ErX g\n"); - err = EINVAL; + err = -EINVAL; goto err_out; - CHK } + } if (card != NULL && nm > card->bchans) { - err = ENXIO; + err = -ENXIO; goto err_out; - CHK } + } chan = nm; - CHK } + } break; case ARG_DELAY: if ((err = m_geti (mx, &delay)) != 0) @@ -1457,9 +1487,9 @@ printf("ErX g\n"); goto err_out; if (call_ref == 0 || call_ref < -128 || call_ref > 127) { printf("ErX h\n"); - err = EINVAL; + err = -EINVAL; goto err_out; - CHK } + } break; case ARG_INT: do_int = 1; @@ -1483,16 +1513,16 @@ printf("ErX h\n"); if ((err = m_geti (mx, &nm)) != 0) goto err_out; if (nm <= 0 || nm >= NMINOR) { - err = ENXIO; + err = -ENXIO; goto err_out; - CHK } + } if (conn != NULL && conn->minor != 0 && conn->minor != nm) { printf("ErX i\n"); - err = EINVAL; + err = -EINVAL; goto err_out; - CHK } + } minor = nm; - CHK } + } break; case ARG_ERRNO: { @@ -1501,7 +1531,7 @@ printf("ErX i\n"); if ((err = m_geti (mx, &nm)) != 0) goto err_out; err = nm; - CHK } + } break; #if 0 case ARG_LISTWHAT: @@ -1511,7 +1541,7 @@ printf("ErX i\n"); if ((err = m_getid (mx, &nm)) != 0) goto err_out; what = nm; - CHK } + } break; #endif case ARG_PROTOCOL: @@ -1522,14 +1552,14 @@ printf("ErX i\n"); goto err_out; if ((hndl = isdn3_findhndl (nm)) == NULL) { printf("ErX j\n"); - err = EINVAL; + err = -EINVAL; goto err_out; - CHK } + } if(nm >= 64 && subprotocol == -1) { subprotocol = 0; printf(" Faked SP %ld; ",subprotocol); } - CHK } + } break; case ARG_FORCE: force = 1; @@ -1540,8 +1570,8 @@ printf(" Faked SP %ld; ",subprotocol); printf(" Got SP %ld; ",subprotocol); break; default:; - CHK } - CHK } + } + } /*** Inferring missing arguents ***/ /* mx->b_rptr = oldpos; ** do not do this here */ @@ -1549,28 +1579,28 @@ printf(" Got SP %ld; ",subprotocol); /* Find an appropriate card. */ if (card == NULL && hndl != NULL) { if (subprotocol == -1) { - err = ENXIO; + err = -ENXIO; printf ("ErrOut 3\n"); goto err_out; - CHK } + } for (card = isdn_card; card != NULL; card = card->next) { if ((modes & card->modes) == 0) continue; if (isdn3_free_b (card) != 0) break; - CHK } + } if (card == NULL) { - err = EBUSY; + err = -EBUSY; printf ("ErrOut 4\n"); goto err_out; - CHK } + } if ((talk = isdn3_findtalk (card, hndl, mx, do_talk)) == NULL) { - err = ENOMEM; + err = -ENOMEM; printf ("ErrOut 5\n"); goto err_out; - CHK } + } modes &= card->modes; - CHK } + } /* If we have card and handler, get the talker. */ if (card != NULL && hndl != NULL && talk == NULL) @@ -1582,32 +1612,32 @@ printf(" Got SP %ld; ",subprotocol); for (conn = talk->conn; conn != NULL; conn = conn->next) { if (conn->conn_id == conn_id) break; - CHK } - CHK } else if (card != NULL) { + } + } else if (card != NULL) { for (talk = card->talk; talk != NULL; talk = talk->next) { for (conn = talk->conn; conn != NULL; conn = conn->next) { if (conn->conn_id == conn_id) goto found_cid; - CHK } - CHK } - CHK } - CHK } + } + } + } + } found_cid:; if (conn == NULL && call_ref != 0 && !noconn) { if (talk != NULL) { for (conn = talk->conn; conn != NULL; conn = conn->next) { if (conn->call_ref == call_ref) break; - CHK } - CHK } else if (card != NULL) { + } + } else if (card != NULL) { for (talk = card->talk; talk != NULL; talk = talk->next) { for (conn = talk->conn; conn != NULL; conn = conn->next) { if (conn->call_ref == call_ref) goto found_ref; - CHK } - CHK } - CHK } - CHK } + } + } + } + } found_ref:; if (conn == NULL && minor != 0 && (minorflags[minor] & (MINOR_OPEN|MINOR_WILL_OPEN)) && !noconn) { @@ -1616,7 +1646,7 @@ printf(" Got SP %ld; ",subprotocol); printf(": Flags %o, 2conn %p",minorflags[minor], minor2conn[minor]); printf("\n"); conn = minor2conn[minor]; - CHK } + } if (conn == NULL && fminor != 0 && (minorflags[fminor] & (MINOR_OPEN | MINOR_WILL_OPEN)) && !noconn) conn = minor2conn[fminor]; @@ -1633,8 +1663,8 @@ printf(" Got SP %ld; ",subprotocol); if (conn->talk != NULL) { talk = conn->talk; hndl = talk->hndl; - CHK } - CHK } + } + } /* If we have card and handler, get the talker. */ if (card != NULL && hndl != NULL && talk == NULL) talk = isdn3_findtalk (card, hndl, mx, do_talk); @@ -1642,15 +1672,15 @@ printf(" Got SP %ld; ",subprotocol); /* Setup variables if we have a connection. */ if (conn != NULL) { if (conn->conn_id != 0 && conn_id != 0 && conn->conn_id != conn_id) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut 6\n"); goto err_out; - CHK } + } if (conn->call_ref != 0 && call_ref != 0 && conn->call_ref != call_ref) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut 6a\n"); goto err_out; - CHK } + } if (chan == -1) chan = conn->bchan; if (card == NULL) @@ -1661,29 +1691,29 @@ printf(" Got SP %ld; ",subprotocol); if (fminor != 0 && conn->minor != 0) { if (fminor != minor) { if (conn->fminor != 0 && conn->fminor != fminor) { - err = EPERM; + err = -EPERM; printf ("ErrOut 1 at %d; min %d nmin %d\n", conn->fminor, fminor, minor); goto err_out; - CHK } else if (conn->fminor != fminor) { + } else if (conn->fminor != fminor) { conn->fminor = fminor; /* minor2conn[fminor] = minor2conn[minor]; */ - CHK } - CHK } - CHK } else if (minor == 0 || !(minorflags[minor] & (MINOR_OPEN | MINOR_WILL_OPEN))) { + } + } + } else if (minor == 0 || !(minorflags[minor] & (MINOR_OPEN | MINOR_WILL_OPEN))) { if (minor != 0) { if (theID == CMD_FAKEOPEN && fminor == 0) { goto after_fake; - CHK } - err = EINVAL; + } + err = -EINVAL; printf ("ErrOut 2 %d %o\n",minor,minorflags[minor]); goto err_out; - CHK } + } if (fminor != 0 && (minorflags[fminor] & (MINOR_OPEN | MINOR_WILL_OPEN)) && minor2conn[minor] != NULL) { conn = minor2conn[fminor]; - CHK } - CHK } - CHK } + } + } + } after_fake: if (conn != NULL) { if(delay > 0) @@ -1693,7 +1723,7 @@ printf(" Got SP %ld; ",subprotocol); minorflags[conn->minor] |= MINOR_INT; else minorflags[conn->minor] &=~ MINOR_INT; - CHK } + } if(call_ref != 0) conn->call_ref = call_ref; if(conn_id != 0 && conn->conn_id != conn_id) { @@ -1705,17 +1735,17 @@ conn->fminor, conn->minorstate, (conn->minor > 0) ? minorflags[conn->minor]: 0); conn = NULL; } } - CHK } + } /* * Now find out what to do with all of this. */ switch (theID) { case CMD_FAKEOPEN: if ((fminor != 0 && fminor != minor) || minor == 0) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut n2 %d %d\n", fminor, minor); goto err_out; - CHK }; + }; if (minorflags[minor] & MINOR_OPEN) break; minorflags[minor] |= MINOR_WILL_OPEN; @@ -1751,43 +1781,45 @@ conn->fminor, conn->minorstate, (conn->minor > 0) ? minorflags[conn->minor]: 0); (*hndl->newcard) (card); } } - CHK } + } break; case CMD_INFO: { m_getskip (mx); if(conn == NULL) { printf("ErX k\n"); - err = EINVAL; + err = -EINVAL; goto err_out; - CHK } + } if ((err = isdn3_at_send (conn, mx, 1)) != 0) { fminor = 0; printf ("ErrOut 7 %d\n", err); goto err_out; - CHK } + } mx = NULL; - CHK } + } break; case CMD_LOADFILE: { mblk_t *mb; if(card == NULL || seqnum == -1 || foffset == -1) { - err = EINVAL; + err = -EINVAL; goto err_out; } mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) { - err = ENOMEM; + err = -ENOMEM; printf ("ErrOut 9l\n"); goto err_out; - CHK } + } hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif hdr->key = HDR_LOAD; + hdr->seqnum = hdrseq; hdrseq += 2; + hdr->hdr_load.len = msgdsize(mx); hdr->hdr_load.card = card->nr; hdr->hdr_load.seqnum = seqnum; hdr->hdr_load.foffset = foffset; @@ -1798,7 +1830,7 @@ printf("ErX k\n"); freeb (mb); printf ("ErrOut al\n"); goto err_out; - CHK } + } } break; #if 0 @@ -1818,7 +1850,7 @@ printf("ErX k\n"); m_putid (mb, id); if (isdn3_at_send (conn, mb, 1) != 0) freemsg (mb); - CHK } + } break; case LISTARG_CONN: { @@ -1830,15 +1862,15 @@ printf("ErX k\n"); m_putid (mb, IND_ERR); m_putsx (mb, ARG_CARD); m_putsx (mb, IND_INFO); - CHK } else { + } else { if ((mb = allocb (128, BPRI_LO)) == NULL) break; m_putid (mb, IND_INFO); conn_info (conn, mb); - CHK } + } if (isdn3_at_send (conn, mb, 1) != NULL) freemsg (mb); - CHK } + } break; case LISTARG_CARD: { @@ -1859,39 +1891,76 @@ printf("ErX k\n"); m_puti (mb, card->bchans); m_putsx (mb, ARG_MODEMASK); m_putx (mb, card->modes); - CHK } - CHK } + } + } if (isdn3_at_send (conn, mb, 1) != 0) freemsg (mb); - CHK } + } break; - CHK } - CHK } + } + } break; #endif + case CMD_NOCARD: + { + mblk_t *mb; + + if(card == NULL) { + err = -ESRCH; + printf("ErrOut NCa"); + goto err_out; + } + mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); + + if (mb == NULL) { + err = -ENOMEM; + printf ("ErrOut 9\n"); + goto err_out; + } + hdr = ((isdn23_hdr) mb->b_wptr)++; +#ifdef __CHECKER__ + memset(hdr,0,sizeof (*hdr)); +#endif + hdr->key = HDR_NOCARD; + if(no_error) + hdr->key |= HDR_NOERROR; + hdr->seqnum = hdrseq; hdrseq += 2; + hdr->hdr_nocard.card = card->nr; + linkb (mb, mx); + if ((err = isdn3_sendhdr (mb)) == 0) + mx = NULL; + else { + freeb (mb); + printf ("ErrOut a\n"); + goto err_out; + } + } + + break; case CMD_CARDPROT: { mblk_t *mb; if (card == NULL || chan == -1) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut 8\n"); goto err_out; - CHK } + } mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) { - err = ENOMEM; + err = -ENOMEM; printf ("ErrOut 9\n"); goto err_out; - CHK } + } hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif hdr->key = HDR_PROTOCMD; if(no_error) hdr->key |= HDR_NOERROR; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_protocmd.card = card->nr; hdr->hdr_protocmd.channel = chan; hdr->hdr_protocmd.minor = 0; @@ -1903,40 +1972,41 @@ printf("ErX k\n"); freeb (mb); printf ("ErrOut a\n"); goto err_out; - CHK } - CHK } + } + } break; case CMD_CLOSE: { mblk_t *mb; if (fminor == 0 && minor == 0) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut 88\n"); goto err_out; - CHK } + } mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) { - err = ENOMEM; + err = -ENOMEM; printf ("ErrOut 99\n"); goto err_out; - CHK } + } hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif hdr->key = HDR_CLOSE; if(no_error) hdr->key |= HDR_NOERROR; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_close.minor = minor ? minor : fminor; - hdr->hdr_close.error = err; + hdr->hdr_close.error = (err < 0) ? -err : err; if ((err = isdn3_sendhdr (mb)) != 0) { freeb (mb); printf ("ErrOut a\n"); goto err_out; - CHK } - CHK } + } + } break; case CMD_PROT: m_getskip (mx); @@ -1945,10 +2015,10 @@ printf("ErX k\n"); printf ("Proto SetMode\n"); /* Protocol setup completed. Or so it seems. */ if (minorflags[minor] & MINOR_PROTO) { - err = EBUSY; + err = -EBUSY; printf ("ErrOut d\n"); goto err_out_x; - CHK } + } mx->b_rptr++; m_getskip (mx); minorflags[minor] |= MINOR_PROTO|MINOR_INITPROTO_SENT|MINOR_INITPROTO_SENT2; @@ -1957,17 +2027,18 @@ printf("ErX k\n"); isdn3_setup_conn (conn, EST_NO_CHANGE); conn->lockit--; if(conn->state == 0) { + isdn3_killconn(conn,0); } } - CHK } else { + } else { if (minor == 0) { if (fminor == 0) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut s2\n"); goto err_out; - CHK } else + } else minor = fminor; - CHK } + } if (conn != NULL) { switch (*(ushort_t *) mx->b_rptr) { case PROTO_DISCONNECT: /* force */ @@ -1984,27 +2055,36 @@ printf("ErX k\n"); mx = NULL; break; #endif - CHK } - CHK } + } + } if (mx == NULL || *(ushort_t *) mx->b_rptr != PROTO_AT) conn = NULL; #if 0 else if (conn == NULL) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut s3\n"); goto err_out; - CHK } + } #endif if (mx != NULL) { + if(talk != NULL && conn != NULL && talk->hndl->proto != NULL) { + err = (*talk->hndl->proto)(conn,&mx,1); + if(err < 0) { + printf ("ErrOut hx %d nm %d\n", err, minor); + goto err_out; + } + if(mx == NULL) /* skip */ + break; + } if ((err = isdn3_send_conn (minor, AS_PROTO, mx)) == 0) { /* minorflags[minor] |= MINOR_INITPROTO_SENT; */ mx = NULL; - CHK } else { + } else { printf ("ErrOut h %d nm %d\n", err, minor); goto err_out; - CHK } - CHK } - CHK } + } + } + } break; case CMD_CARDSETUP: m_getskip (mx); @@ -2012,29 +2092,29 @@ printf("ErX k\n"); long nm; if (conn == NULL) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut sdc\n"); goto err_out; - CHK } + } if (0) printf ("Proto SetMode\n"); /* Protocol setup completed. Or so it seems. */ if ((conn->minorstate & MS_INITPROTO) || !(conn->minorstate & MS_INITPROTO_SENT)) { - err = EBUSY; + err = -EBUSY; printf ("ErrOut dc\n"); goto err_out; - CHK } + } mx->b_rptr++; m_getskip (mx); if ((err = m_geti (mx, &nm)) != 0) { printf ("ErrOut fc\n"); goto err_out; - CHK } + } if (nm < 1 || nm > 31) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut g\n"); goto err_out; - CHK } + } conn->minorstate |= MS_INITPROTO; conn->mode = nm; if ((m_geti (mx, &nm) == 0) && (nm >= 0) && (nm <= 255)) @@ -2047,20 +2127,20 @@ printf("ErX k\n"); if(conn->state == 0) { /* XXX */ } - CHK } else { + } else { #if 1 printf("ErrOut 2c"); - err = ENOENT; + err = -ENOENT; goto err_out; #else if (minor == 0) { if (fminor == 0) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut s2\n"); goto err_out; - CHK } else + } else minor = fminor; - CHK } + } if (conn != NULL) { switch (*(ushort_t *) mx->b_rptr) { case PROTO_DISCONNECT: @@ -2069,29 +2149,29 @@ printf("ErX k\n"); case PROTO_INTERRUPT: err = isdn3_setup_conn (conn, EST_INTERRUPT); break; - CHK } - CHK } + } + } if (*(ushort_t *) mx->b_rptr != PROTO_AT) conn = NULL; #if 0 else if (conn == NULL) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut s3\n"); goto err_out; - CHK } + } #endif if (mx != NULL) { if ((err = isdn3_send_conn (minor, AS_PROTO, mx)) == 0) { if (conn != NULL) minorflags[conn->minor] |= MINOR_INITPROTO_SENT; mx = NULL; - CHK } else { + } else { printf ("ErrOut h %d nm %d\n", err, minor); goto err_out; - CHK } - CHK } + } + } #endif - CHK } + } break; case CMD_NOPROT: { @@ -2101,27 +2181,28 @@ printf("ErX k\n"); if(fminor == 0 && conn != NULL) fminor = conn->minor; if (fminor == 0) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut j\n"); goto err_out; - CHK } + } if ((mp = allocb (sizeof (struct _isdn23_hdr), BPRI_MED)) != NULL) { hdr = ((isdn23_hdr) mp->b_wptr)++; #ifdef __CHECKER__ - bzero(hdr,sizeof(*hdr)); + memset(hdr,0,sizeof (*hdr)); #endif hdr->key = HDR_DETACH; if(no_error) hdr->key |= HDR_NOERROR; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_detach.minor = fminor; hdr->hdr_detach.error = 0xFF; hdr->hdr_detach.perm = 1; if ((err = isdn3_sendhdr (mp)) != 0) { freeb (mp); - CHK } + } if(conn != NULL) conn->minorstate |= MS_DETACHED; - CHK } + } if(conn != NULL) { minorflags[conn->minor] &= ~(MINOR_INITPROTO_SENT|MINOR_INITPROTO_SENT2); conn->lockit++; @@ -2147,7 +2228,7 @@ printf("ErX k\n"); if (conn != NULL && !force) { isdn3_killconn (conn, 0); break; - CHK } + } #endif if(minor != 0 && do_int < 0) { minorflags[minor] &= ~(MINOR_PROTO|MINOR_INITPROTO_SENT); @@ -2162,26 +2243,26 @@ printf("ErX k\n"); if(theID == CMD_OFF && noconn) break; if (conn == NULL && talk == NULL) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut o\n"); goto err_out; - CHK } + } if (conn == NULL) { /* If no appropriate connection, create one. */ if (subprotocol == -1) { - err = EINVAL; + err = -EINVAL; printf ("ErrOut i\n"); goto err_out; - CHK } + } if (chan < -1 || chan > (char)talk->card->bchans) { - err = ENXIO; + err = -ENXIO; printf ("ErrOut u\n"); goto err_out; - CHK } + } if ((conn = isdn3_new_conn (talk)) == NULL) { - err = ENXIO; + err = -ENXIO; printf ("ErrOut z\n"); goto err_out; - CHK } + } conn->subprotocol = subprotocol; if(chan != -1) { conn->minorstate |= MS_BCHAN; @@ -2193,7 +2274,7 @@ printf("ErX k\n"); conn->conn_id = conn_id; if(call_ref != 0) conn->call_ref = call_ref; - CHK } + } if(theID == CMD_OFF) printf(" D1 "); printf ("* Conn%p: min %d at %d; minor %d min %d; callref %ld connref %d \n", conn, conn->minor, conn->fminor, @@ -2202,7 +2283,7 @@ if(theID == CMD_OFF) printf(" D1 "); conn->minor = (minor ? minor : fminor); if (conn->minor != 0) minor2conn[conn->minor] = conn; - CHK } + } else printf(" D4 "); if (do_talk) conn->minorstate |= MS_FORCING; @@ -2211,7 +2292,7 @@ if(theID == CMD_OFF) printf(" D5 "); if (conn->fminor == 0) conn->fminor = fminor; minor2conn[conn->minor] = conn; - CHK } + } if (conn->call_ref == 0) conn->call_ref = ((call_ref != 0) ? call_ref : isdn3_new_callref (talk)); if (conn->stack[0] == 0) @@ -2224,7 +2305,7 @@ if(theID == CMD_OFF) printf(" D6 "); minorflags[conn->minor] |= MINOR_INT; else minorflags[conn->minor] &=~ MINOR_INT; - CHK } + } if(theID == CMD_OFF) printf(" D7 "); conn->lockit++; isdn3_setup_conn (conn, EST_NO_CHANGE); @@ -2234,15 +2315,15 @@ if(theID == CMD_OFF) printf(" D8 "); /* XXX */ } if ((err = (*talk->hndl->sendcmd) (conn, theID, mx)) == 0 || - err == EBUSY) + err == -EBUSY) mx = NULL; else { printf ("ErrOut t of %d is %d\n", talk->hndl->SAPI, err); goto err_out; - CHK } + } if(theID == CMD_OFF) printf(" D9 "); break; - CHK } + } /* ok_out: */ if (mx != NULL) freemsg (mx); @@ -2345,7 +2426,7 @@ isdn3_findminor (ushort_t minor) conn = minor2conn[minor]; printf (".FindMinor%p %d gets C %d:%d\n", conn, minor, conn->minor, conn->fminor); return conn; -CHK } +} /* --> isdn_3.h */ @@ -2357,9 +2438,9 @@ isdn3_findhndl (uchar_t SAPI) for (hndl = isdn_hndl; hndl != NULL; hndl = hndl->next) { if (hndl->SAPI == SAPI) return hndl; - CHK } + } return NULL; -CHK } +} /* --> isdn_3.h */ isdn3_talk @@ -2377,8 +2458,7 @@ isdn3_findtalk (isdn3_card card, isdn3_hndl hndl, mblk_t *info, int create) int i; int err; -char systr[100]; -strcpy(systr,"with card "); +char systr[100] = ""; if(card->info != NULL) sprintf(systr+strlen(systr),"'%-*s'",card->info->b_wptr-card->info->b_rptr,card->info->b_rptr); else strcat(systr,"NULL"); @@ -2386,7 +2466,7 @@ strcat(systr," and info "); if(info != NULL) sprintf(systr+strlen(systr),"'%-*s'",info->b_wptr-info->b_rptr,info->b_rptr); else strcat(systr,"NULL"); -syslog(LOG_DEBUG,"====== Create 0x%02x with %s",hndl->SAPI,systr); +syslog(LOG_DEBUG,"====== Create 0x%02x with card %s",hndl->SAPI,systr); if(card->info != NULL) { mblk_t *mi = card->info; streamchar *sta = mi->b_rptr; @@ -2432,7 +2512,7 @@ syslog(LOG_DEBUG,"====== Create 0x%02x with %s",hndl->SAPI,systr); if (talk == NULL) { splx (ms); return NULL; - CHK } + } memset(talk,0,sizeof(*talk)); talk->hndl = hndl; @@ -2444,12 +2524,12 @@ syslog(LOG_DEBUG,"====== Create 0x%02x with %s",hndl->SAPI,systr); talk->card = NULL; splx (ms); return NULL; - CHK } + } splx (ms); return talk; - CHK } + } return NULL; -CHK } +} /* --> isdn_3.h */ long @@ -2552,7 +2632,7 @@ isdn3_findconn (isdn3_talk talk, long protocol, long call_ref) return conn; } return NULL; -CHK } +} /* --> isdn_3.h */ @@ -2565,9 +2645,9 @@ isdn3_attach_hndl (isdn3_hndl hndl) for (nhndl = isdn_hndl; nhndl != NULL; nhndl = nhndl->next) { if (nhndl->SAPI == hndl->SAPI) { splx (ms); - return EEXIST; - CHK } - CHK } + return -EEXIST; + } + } hndl->next = isdn_hndl; isdn_hndl = hndl; @@ -2577,7 +2657,7 @@ isdn3_attach_hndl (isdn3_hndl hndl) splx (ms); return 0; -CHK } +} @@ -2587,18 +2667,26 @@ CHK } void isdn3_init (void) { - bzero ((caddr_t) minor2conn, sizeof minor2conn); - bzero ((caddr_t) minorflags, sizeof minorflags); + memset(minor2conn,0,sizeof (minor2conn)); + memset(minorflags,0,sizeof (minorflags)); /* Mark everything as free. */ isdn_hndl = NULL; /* Attach default handlers */ +#ifdef _phone_ isdn3_attach_hndl (&PHONE_hndl); +#endif +#ifdef _fixed_ isdn3_attach_hndl (&FIXED_hndl); +#endif +#ifdef _capi_ isdn3_attach_hndl (&CAPI_hndl); +#endif +#ifdef _tei_ isdn3_attach_hndl (&TEI_hndl); -CHK } +#endif +} /* Streams code to open the module. */ static int @@ -2609,7 +2697,7 @@ isdn3_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) if (isdn3_q != NULL) { /* Another ioctl(I_PUSH). */ ERR_RETURN(-EALREADY); - CHK } + } isdn3_q = q; WR (q)->q_ptr = (caddr_t) & isdn3_q; q->q_ptr = (caddr_t) isdn3_q; @@ -2617,7 +2705,7 @@ isdn3_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) printf ("ISDN Master driver %d opened.\n", dev); return 0; -CHK } +} /* Streams code to close the module. */ static void @@ -2628,7 +2716,7 @@ isdn3_close (queue_t *q, int dummy) printf ("ISDN Master driver closed.\n"); isdn3_q = NULL; return; -CHK } +} /* Streams code to write data. */ @@ -2647,10 +2735,10 @@ isdn3_wput (queue_t * q, mblk_t * mp) default:{ putnext (q, mp); break; - CHK } - CHK } + } + } return; -CHK } +} /* Streams code to scan the write queue. */ static void @@ -2671,10 +2759,10 @@ isdn3_wsrv (queue_t * q) default: putnext (q, mp); continue; - CHK } - CHK } + } + } return; -CHK } +} /* Streams code to read data. */ static void @@ -2685,7 +2773,7 @@ isdn3_rput (queue_t * q, mblk_t * mp) case M_FLUSH: if (*mp->b_rptr & FLUSHR) { flushq (q, FLUSHDATA); - CHK } + } putnext (q, mp); /* send it along too */ break; case CASE_DATA: @@ -2694,9 +2782,9 @@ isdn3_rput (queue_t * q, mblk_t * mp) default: putnext (q, mp); - CHK } + } return; -CHK } +} /* Streams code to scan the read queue. */ static void @@ -2712,7 +2800,7 @@ isdn3_rsrv (queue_t * q) if (mp->b_wptr - mp->b_rptr < sizeof (struct _isdn23_hdr)) { printf ("isdn3_rsrv: small msg recv\n"); break; - CHK } + } hdr = *((isdn23_hdr) mp->b_rptr)++; mp = pullupm (mp, 1); @@ -2725,7 +2813,7 @@ isdn3_rsrv (queue_t * q) if (scan_at (hdr.hdr_atcmd.minor, mp) == 0) mp = NULL; break; - CHK } + } if ((mx = allocb (16, BPRI_MED)) == NULL) break; m_putid (mx, IND_ATCMD); @@ -2735,13 +2823,20 @@ isdn3_rsrv (queue_t * q) linkb (mx, mp); mp = NULL; putnext (isdn3_q, mx); - CHK } + } break; case HDR_PROTOCMD: { mblk_t *mx; + int err; isdn3_conn conn = isdn3_findminor (hdr.hdr_protocmd.minor); + if(conn != NULL && conn->talk != NULL && conn->talk->hndl->proto != NULL) { + err = (*conn->talk->hndl->proto)(conn,&mp,0); + if((mp == NULL) || (err < 0)) + break; + } + m_getskip (mp); if (conn != NULL) { switch (*(ushort_t *) mp->b_rptr) { @@ -2769,8 +2864,8 @@ isdn3_rsrv (queue_t * q) minorflags[conn->minor] |= MINOR_CONN_SENT; break; #endif - CHK } - CHK } + } + } if ((mx = allocb (64, BPRI_MED)) == NULL) break; { @@ -2783,11 +2878,11 @@ isdn3_rsrv (queue_t * q) if (conn != NULL && conn->fminor != 0) { m_putsx (mx, ARG_FMINOR); m_puti (mx, conn->fminor); - CHK } + } if(hdr.hdr_protocmd.minor != 0) { m_putsx (mx, ARG_MINOR); m_puti (mx, hdr.hdr_protocmd.minor); - CHK } + } if(conn != NULL && conn->conn_id != 0) { m_putsx (mx, ARG_CONNREF); m_puti (mx, conn->conn_id); @@ -2806,7 +2901,7 @@ isdn3_rsrv (queue_t * q) sdrop: freemsg (mp); mp = NULL; - CHK } + } break; case HDR_XDATA: { @@ -2817,20 +2912,21 @@ isdn3_rsrv (queue_t * q) if (0) printf ("XData: Conn for minor %d nf\n", hdr.hdr_detach.minor); break; - CHK } + } if ((talk = conn->talk) == NULL) { printf ("XData m %d: No Talker\n", hdr.hdr_detach.minor); break; - CHK } + } if (talk->hndl->send != NULL && (*talk->hndl->send) (conn, mp) == 0) mp = NULL; - CHK } + } break; case HDR_DATA: { isdn3_card card; isdn3_hndl hndl; isdn3_talk talk; + mblk_t *m2; card = isdn3_findcard(hdr.hdr_data.card); if (card == NULL) @@ -2839,15 +2935,23 @@ isdn3_rsrv (queue_t * q) break; if ((talk = isdn3_findtalk (card, hndl, NULL, 0)) == NULL) break; + + m2 = pullupm(mp,-1); + if(m2 == NULL) { + printf("ISDN_3 error: no memory\n"); + break; + } else + mp = m2; if ((*talk->hndl->recv) (talk, 0, mp) == 0) mp = NULL; - CHK } + } break; case HDR_UIDATA: { isdn3_card card; isdn3_hndl hndl; isdn3_talk talk; + mblk_t *m2; card = isdn3_findcard(hdr.hdr_uidata.card); if (card == NULL) @@ -2856,9 +2960,16 @@ isdn3_rsrv (queue_t * q) break; if ((talk = isdn3_findtalk (card, hndl, NULL, 0)) == NULL) break; + + m2 = pullupm(mp,-1); + if(m2 == NULL) { + printf("ISDN_3 error: no memory\n"); + break; + } else + mp = m2; if ((*talk->hndl->recv) (talk, hdr.hdr_uidata.broadcast ? 3 : 1, mp) == 0) mp = NULL; - CHK } + } break; case HDR_RAWDATA: log_printmsg (NULL, "RAWDATA", mp, KERN_INFO); @@ -2871,11 +2982,11 @@ isdn3_rsrv (queue_t * q) if (hdr.hdr_open.minor > NMINOR) { printf ("Open: Minor %d out of range\n", hdr.hdr_open.minor); break; - CHK } + } if (minorflags[hdr.hdr_open.minor] & MINOR_OPEN) { printf ("Open: Minor %d open\n", hdr.hdr_open.minor); break; - CHK } + } minorflags[hdr.hdr_open.minor] |= MINOR_OPEN; if (!(minorflags[hdr.hdr_open.minor] & MINOR_WILL_OPEN) && ((mx = allocb (32, BPRI_MED)) != NULL)) { @@ -2891,11 +3002,11 @@ isdn3_rsrv (queue_t * q) m_puti (mx, hdr.hdr_open.gid); #endif putnext (q, mx); - CHK } + } minorflags[hdr.hdr_open.minor] &= ~MINOR_WILL_OPEN; if ((conn = isdn3_findminor (hdr.hdr_open.minor)) != NULL) isdn3_setup_conn (conn, EST_NO_CHANGE); - CHK } + } break; case HDR_CLOSE: { @@ -2912,24 +3023,24 @@ isdn3_rsrv (queue_t * q) printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); conn->minor = conn->fminor; conn->fminor = 0; - CHK } - CHK } + } + } while ((conn = isdn3_findatcmd(hdr.hdr_close.minor)) != NULL) { conn->fminor = 0; isdn3_killconn (conn, 0); - CHK } + } if ((mx = allocb (32, BPRI_MED)) != NULL) { m_putid (mx, IND_CLOSE); m_putsx (mx, ARG_MINOR); m_puti (mx, hdr.hdr_close.minor); putnext (q, mx); - CHK } - CHK } + } + } break; case HDR_ATTACH: { printf ("Attach coming up ??\n"); - CHK } + } break; case HDR_DETACH: { @@ -2939,9 +3050,9 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); if (0) printf ("Detach: Conn for minor %d nf\n", hdr.hdr_detach.minor); break; - CHK } + } isdn3_killconn (conn, 0); - CHK } + } break; case HDR_CARD: { @@ -2952,11 +3063,11 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); if (card != NULL) { printf ("Hdr_Card: Card %d busy\n", hdr.hdr_card.card); break; - CHK } + } if (hdr.hdr_card.id == 0) { printf ("Hdr_Card: BadID Card %d\n", hdr.hdr_card.card); break; - CHK } + } card = malloc(sizeof(*card)); if (card == NULL) { } @@ -2974,9 +3085,9 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); m_puti (mx, hdr.hdr_card.bchans); m_putx (mx, hdr.hdr_card.modes); putnext (q, mx); - CHK } else + } else printf ("Hdr_Card: No mem to reply\n"); - CHK } + } break; case HDR_NOCARD: { @@ -2988,14 +3099,14 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); if (card == NULL) { printf ("Hdr_NoCard: Card %d not busy\n", hdr.hdr_nocard.card); break; - CHK } + } while ((talk = card->talk) != NULL) isdn3_killtalk (talk); if ((mx = allocb (32, BPRI_MED)) != 0) { m_putid (mx, IND_NOCARD); m_putlx (mx, card->id); putnext (q, mx); - CHK } + } if(isdn_card == card) isdn_card = card->next; else { @@ -3008,7 +3119,7 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); } } free(card); - CHK } + } break; case HDR_TEI: { @@ -3018,10 +3129,10 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); if (card == NULL) { printf ("Hdr_TEI: Card %d not busy\n", hdr.hdr_tei.card); break; - CHK } + } if (hdr.hdr_tei.TEI == TEI_BROADCAST) tei_getid (card); - CHK } + } break; case HDR_OPENPROT: { @@ -3037,9 +3148,9 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); if ((talk = isdn3_findtalk (card, hndl, NULL, 0)) == NULL) { printf ("OpenProt: NotFound %d:%02x\n", hdr.hdr_openprot.card, hdr.hdr_openprot.SAPI); break; - CHK } + } (*talk->hndl->chstate) (talk, hdr.hdr_openprot.ind, 1); - CHK } + } break; case HDR_CLOSEPROT: { @@ -3053,9 +3164,9 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); if ((talk = isdn3_findtalk (card, hndl, NULL, 0)) == NULL) { printf ("CloseProt: NotFound %d:%02x\n", hdr.hdr_closeprot.card, hdr.hdr_closeprot.SAPI); break; - CHK } + } (*talk->hndl->chstate) (talk, hdr.hdr_closeprot.ind, 1); - CHK } + } break; case HDR_NOTIFY: { @@ -3068,36 +3179,36 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); break; if (hdr.hdr_notify.SAPI == SAPI_INVALID) { - for (talk = card->talk; talk != NULL; talk = talk->next) + for (talk = card->talk; talk != NULL; talk = talk->next) { + printf("chstate for SAPI %x\n",talk->hndl->SAPI); (*talk->hndl->chstate) (talk, hdr.hdr_notify.ind, hdr.hdr_notify.add); - #if 0 + } switch (hdr.hdr_notify.ind) { case PH_ACTIVATE_IND: case PH_ACTIVATE_CONF: + card->is_up = 1; break; case PH_DEACTIVATE_IND: case PH_DEACTIVATE_CONF: case PH_DISCONNECT_IND: + card->is_up = 0; break; - CHK } - #endif - CHK } else { + } + } else { if ((hndl = isdn3_findhndl (hdr.hdr_notify.SAPI)) == NULL) break; if ((talk = isdn3_findtalk (card, hndl, NULL, 0)) == NULL) { printf ("Notify: NotFound %d:%02x\n", hdr.hdr_notify.card, hdr.hdr_notify.SAPI); break; - CHK } + } (*talk->hndl->chstate) (talk, hdr.hdr_notify.ind, hdr.hdr_notify.add); - CHK } - CHK } + } + } break; case HDR_INVAL: { mblk_t *mx; - printf ("Inval Err %d: ", hdr.hdr_inval.error); - log_printmsg (NULL, "Inval", mp, KERN_DEBUG); - if ((mp != NULL) && (mx = allocb (32, BPRI_MED)) != 0) { + if ((mp != NULL) && (mx = allocb (64, BPRI_MED)) != 0) { mblk_t *mq; if(hdr.hdr_inval.error != 0) { m_putid (mx, IND_ERR); @@ -3115,17 +3226,138 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); m_puti(mx,hdr.key); switch(hdr.key) { + case HDR_UIDATA: + { + isdn3_card card = isdn3_findcard(hdr.hdr_uidata.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + } + } + m_putsx(mx,ARG_PROTOCOL); + m_puti(mx,hdr.hdr_uidata.SAPI); + m_putsx(mx,ARG_LENGTH); + m_puti(mx,hdr.hdr_uidata.len); + break; + case HDR_DATA: + { + isdn3_card card = isdn3_findcard(hdr.hdr_data.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + } + } + m_putsx(mx,ARG_PROTOCOL); + m_puti(mx,hdr.hdr_data.SAPI); + m_putsx(mx,ARG_LENGTH); + m_puti(mx,hdr.hdr_data.len); + break; + case HDR_OPENPROT: + { + isdn3_card card = isdn3_findcard(hdr.hdr_openprot.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + m_putsx(mx,ARG_PROTOCOL); + m_puti(mx,hdr.hdr_openprot.SAPI); + } + } + break; + case HDR_CLOSEPROT: + { + isdn3_card card = isdn3_findcard(hdr.hdr_closeprot.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + m_putsx(mx,ARG_PROTOCOL); + m_puti(mx,hdr.hdr_closeprot.SAPI); + } + } + break; + case HDR_NOTIFY: + { + isdn3_card card = isdn3_findcard(hdr.hdr_notify.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + m_putsx(mx,ARG_PROTOCOL); + m_puti(mx,hdr.hdr_notify.SAPI); + } + } + break; + case HDR_TEI: + { + isdn3_card card = isdn3_findcard(hdr.hdr_tei.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + } + } + break; + case HDR_LOAD: + { + isdn3_card card = isdn3_findcard(hdr.hdr_load.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + m_putsx(mx,ARG_SEQNUM); + m_puti(mx,hdr.hdr_load.seqnum); + m_putsx(mx,ARG_OFFSET); + m_puti(mx,hdr.hdr_load.foffset); + m_putsx(mx,ARG_LENGTH); + m_puti(mx,hdr.hdr_load.len); + } + } + break; + case HDR_CARD: + { + isdn3_card card = isdn3_findcard(hdr.hdr_card.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + m_putsx(mx,ARG_CHANNEL); + m_puti(mx,hdr.hdr_card.bchans); + } + } + break; case HDR_ATCMD: m_putsx(mx,ARG_MINOR); m_puti(mx,hdr.hdr_atcmd.minor); + m_putsx(mx,ARG_LENGTH); + m_puti(mx,hdr.hdr_atcmd.len); break; case HDR_PROTOCMD: + if(hdr.hdr_protocmd.minor == 0) { + isdn3_card card = isdn3_findcard(hdr.hdr_protocmd.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + m_putsx(mx,ARG_CHANNEL); + m_puti(mx,hdr.hdr_protocmd.channel); + } + } else { m_putsx(mx,ARG_MINOR); m_puti(mx,hdr.hdr_protocmd.minor); + } + m_putsx(mx,ARG_LENGTH); + m_puti(mx,hdr.hdr_protocmd.len); + break; + case HDR_RAWDATA: + { + isdn3_card card = isdn3_findcard(hdr.hdr_rawdata.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + } + } + m_putsx(mx,ARG_LENGTH); + m_puti(mx,hdr.hdr_rawdata.len); break; case HDR_XDATA: m_putsx(mx,ARG_MINOR); m_puti(mx,hdr.hdr_xdata.minor); + m_putsx(mx,ARG_LENGTH); + m_puti(mx,hdr.hdr_xdata.len); break; case HDR_OPEN: m_putsx(mx,ARG_MINOR); @@ -3138,6 +3370,15 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); case HDR_ATTACH: m_putsx(mx,ARG_MINOR); m_puti(mx,hdr.hdr_attach.minor); + { + isdn3_card card = isdn3_findcard(hdr.hdr_attach.card); + if(card != NULL) { + m_putsx(mx,ARG_CARD); + m_putlx(mx,card->id); + m_putsx(mx,ARG_CHANNEL); + m_puti(mx,hdr.hdr_attach.chan); + } + } break; case HDR_DETACH: m_putsx(mx,ARG_MINOR); @@ -3147,22 +3388,22 @@ printf(" *SM %d: %d %d.%d\n",__LINE__,conn->conn_id,conn->minor,conn->fminor); } putnext (q, mx); } - CHK } + } break; default: break; - CHK } + } if (mp != NULL) freemsg (mp); - CHK } + } break; default: putnext (q, mp); continue; - CHK } + } } return; -CHK } +} @@ -3180,7 +3421,7 @@ static struct vdldrv vd = VDMAGIC_PSEUDO, "isdn_3", NULL, NULL, NULL, 0, 0, NULL, NULL, 0, 0, -CHK }; +}; static struct fmodsw *isdn3_fmod; @@ -3198,14 +3439,14 @@ isdn3_load (fc, vdp, vdi, vds) for (dev = 0; dev < fmodcnt; dev++) { if (fmodsw[dev].f_str == NULL) break; - CHK } + } if (dev == fmodcnt) return (ENODEV); isdn3_fmod = &fmodsw[dev]; for (i = 0; i <= FMNAMESZ; i++) isdn3_fmod->f_name[i] = isdn3_minfo.mi_idname[i]; isdn3_fmod->f_str = &isdn3_l3info; - CHK } + } vdp->vdd_vdtab = (struct vdlinkage *) & vd; return 0; case VDUNLOAD: @@ -3215,15 +3456,15 @@ isdn3_load (fc, vdp, vdi, vds) for (dev = 0; dev < NISDN3; dev++) if (isdn3_q != NULL) return (EIO); - CHK } + } isdn3_fmod->f_name[0] = '\0'; isdn3_fmod->f_str = NULL; return 0; case VDSTAT: return 0; default: - return EIO; - CHK } -CHK } + return -EIO; + } +} #endif diff --git a/isdn_3/phone.c b/isdn_3/phone.c index df27d47..3a38fd7 100644 --- a/isdn_3/phone.c +++ b/isdn_3/phone.c @@ -13,48 +13,10 @@ #include "prot_1TR6_0.h" #include "prot_1TR6_1.h" #include "prot_ETS.h" +#include "sapi.h" -int -phone_get_vector (isdn3_conn conn, uchar_t * data, int len, int vnr, uchar_t dict, uchar_t key) -{ - int qd_len; - uchar_t *qd_data; - int *vec; - qd_data = qd_find (data, len, dict,key, &qd_len); - if (qd_data == NULL) - return 0; - if (qd_len < 1) - return 0; - if(conn->v[vnr] != NULL) - free(conn->v[vnr]); - conn->v[vnr] = vec = malloc(sizeof(int)+qd_len); - if (vec == NULL) - return 0; - *vec++ = qd_len; - memcpy(vec,qd_data,qd_len); - return 1; -} - -int -phone_put_vector (isdn3_conn conn, uchar_t * data, int len, int vnr, uchar_t dict, uchar_t key) -{ - int qd_len; - uchar_t *qd_data; - int *vec; - - vec = conn->v[vnr]; - if(vec == NULL) - return 0; - qd_len = *vec++; - if (qd_len < 1) - return 0; - qd_data = qd_insert (data, &len, dict,key, qd_len, 0); - if (qd_data == NULL) - return 0; - memcpy(qd_data,vec,qd_len); - return 1; -} +static isdn3_prot isdn3_findprot (mblk_t *info, uchar_t protocol); int phone_sendback (isdn3_conn conn, uchar_t msgtype, mblk_t * data) @@ -74,14 +36,14 @@ phone_sendback (isdn3_conn conn, uchar_t msgtype, mblk_t * data) creflen++; } while (cref != 0); if ((mb = allocb (creflen + 3, BPRI_MED)) == NULL) - return ENOMEM; + return -ENOMEM; if (data != NULL) linkb (mb, data); *mb->b_wptr++ = conn->subprotocol; *mb->b_wptr++ = creflen; - if (conn->subprotocol == PD_Q931) { + if (conn->subprotocol == SAPI_PHONE_DSS1) { if(conn->card == NULL || conn->card->bchans <= 2) { if (creflen < 1) creflen = 1; @@ -266,7 +228,7 @@ send (isdn3_conn conn, mblk_t * data) return (*prot->send) (conn, data); else { isdn3_killconn (conn, 1); - return EINVAL; + return -EINVAL; } } @@ -281,7 +243,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) printf("\n !*!*! ProtNull / %ld::%s !*!*!\n",conn->subprotocol, conn->card->info ? (char *)conn->card->info->b_rptr : "none"); isdn3_killconn (conn, 1); - return EINVAL; + return -EINVAL; } } @@ -375,8 +337,12 @@ init (void) isdn_prot = NULL; if(0) isdn3_attach_prot (&prot_1TR6_0); +#ifdef _german_ isdn3_attach_prot (&prot_1TR6_1); +#endif +#ifdef _euro_ isdn3_attach_prot (&prot_ETSI); +#endif } int @@ -388,7 +354,7 @@ isdn3_attach_prot (isdn3_prot prot) for (nprot = isdn_prot; nprot != NULL; nprot = nprot->next) { if (nprot->protocol == prot->protocol) { splx (ms); - return EEXIST; + return -EEXIST; } } @@ -401,7 +367,7 @@ isdn3_attach_prot (isdn3_prot prot) return 0; } -isdn3_prot +static isdn3_prot isdn3_findprot (mblk_t *info, uchar_t protocol) { isdn3_prot prot; @@ -446,5 +412,5 @@ struct _isdn3_hndl PHONE_hndl = { NULL, SAPI_PHONE,0, &init, &newcard, &modeflags, &chstate, &report, &recv, &send, - &sendcmd, &ckill, &killconn, &hook, + &sendcmd, &ckill, &killconn, &hook, NULL, }; diff --git a/isdn_3/prot_1TR6_0.c b/isdn_3/prot_1TR6_0.c index f4507d4..5b3d167 100644 --- a/isdn_3/prot_1TR6_0.c +++ b/isdn_3/prot_1TR6_0.c @@ -9,6 +9,7 @@ #include #include "prot_1TR6_0.h" #include "prot_1TR6_common.h" +#include "sapi.h" #define RUN_N0_T308 01 #define RUN_N0_T3D1 02 @@ -83,7 +84,7 @@ recv (isdn3_conn conn, uchar_t msgtype, char isUI, uchar_t * data, ushort_t len) #if 0 QD_INIT (data, len) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } #endif switch (msgtype) { @@ -221,6 +222,6 @@ killconn (isdn3_conn conn, char force) struct _isdn3_prot prot_1TR6_0 = { - NULL, PD_N0, + NULL, SAPI_PHONE_1TR6_0, NULL, &chstate, NULL, &recv, NULL, &sendcmd, &killconn, NULL, }; diff --git a/isdn_3/prot_1TR6_1.c b/isdn_3/prot_1TR6_1.c index f45e93c..06e304e 100644 --- a/isdn_3/prot_1TR6_1.c +++ b/isdn_3/prot_1TR6_1.c @@ -10,6 +10,7 @@ #include #include "prot_1TR6_1.h" #include "prot_1TR6_common.h" +#include "sapi.h" #undef HAS_SUSPEND @@ -323,11 +324,11 @@ report_n1_setup (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INCOMING); conn_info (conn, mb); @@ -347,11 +348,11 @@ report_n1_setup_ack (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_N1_SETUP_ACK); @@ -372,11 +373,11 @@ report_n1_call_sent (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_N1_CALL_SENT); @@ -397,11 +398,11 @@ report_n1_alert (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_N1_ALERT); @@ -426,11 +427,11 @@ report_n1_user_info (isdn3_conn conn, uchar_t * data, int len) int qd_len; uchar_t *qd_data; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_N1_ALERT); @@ -459,11 +460,11 @@ report_n1_conn (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_CONN); conn_info (conn, mb); @@ -485,11 +486,11 @@ report_n1_conn_ack (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_N1_CONN_ACK); @@ -512,11 +513,11 @@ report_n1_info (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_N1_INFO); @@ -540,11 +541,11 @@ report_n1_stat (isdn3_conn conn, uchar_t * data, int len) int err = 0; char cval; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_N1_STAT); @@ -589,7 +590,7 @@ report_n1_terminate (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); @@ -1904,7 +1905,7 @@ send_N1_disc (isdn3_conn conn, char release, mblk_t * data) if (release) { goto common_off_noconn; } else - return EBUSY; + return -EBUSY; case 1: case 2: case 3: @@ -1957,7 +1958,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (data == NULL) { printf("DataNull: "); conn->lockit--; - return EINVAL; + return -EINVAL; } while ((err = m_getsx (data, &typ)) == 0) { switch (typ) { @@ -1981,7 +1982,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) data->b_rptr = oldpos; printf("GetX EAZ: "); conn->lockit--; - return EINVAL; + return -EINVAL; } ((struct t_info *)conn->p_data)->eaz = data->b_rptr[1]; } break; @@ -2000,7 +2001,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (service == ~0) { printf("No Service: "); conn->lockit--; - return EINVAL; + return -EINVAL; } conn->minorstate |= MS_OUTGOING | MS_WANTCONN; @@ -2020,24 +2021,24 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (conn->minor == 0) { printf("ConnMinorZero: "); conn->lockit--; - return ENOENT; + return -ENOENT; } if (conn->mode == 0) - err = ENOEXEC; + err = -ENOEXEC; { - mblk_t *asn = allocb (128, BPRI_MED); + mblk_t *asn = allocb (256, BPRI_MED); int qd_len = 0; uchar_t *qd_d; if (asn == NULL) { conn->lockit--; - return ENOMEM; + return -ENOMEM; } if (suppress) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_netSpecFac, 4, 1)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *(uchar_t *) qd_d++ = 0; *(uchar_t *) qd_d++ = N1_FAC_Unterdruecke; @@ -2046,14 +2047,14 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (svc) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_netSpecFac, 4, 1)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *(uchar_t *) qd_d++ = 0; *(uchar_t *) qd_d++ = N1_FAC_SVC; *(ushort_t *) qd_d = 0; if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_netSpecFac, 4, 1)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *(uchar_t *) qd_d++ = 0; *(uchar_t *) qd_d++ = N1_FAC_Activate; @@ -2061,14 +2062,14 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) } if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 6, PT_N6_serviceInd, 2, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *((uchar_t *) qd_d) = service >> 8; *(((uchar_t *) qd_d)+1) = service & 0xFF; if (((struct t_info *)conn->p_data)->eaz != 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_origAddr, 2, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *qd_d++ = 0x81; *qd_d++ = ((struct t_info *)conn->p_data)->eaz; @@ -2081,7 +2082,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_destAddr, i + 1, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *qd_d++ = 0x81; while (i--) @@ -2090,7 +2091,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (conn->bchan != 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_chanID, (conn->bchan <= 2) ? 1 : 3, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } if (conn->bchan <= 2) { *qd_d = 0x80 | conn->bchan; @@ -2116,7 +2117,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) default: printf("Default %d: ", conn->state); conn->lockit--; - return EBUSY; + return -EBUSY; } } break; @@ -2146,7 +2147,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) } break; default: printf("BadState1: "); - err = EINVAL; + err = -EINVAL; } break; case CMD_ANSWER: @@ -2169,7 +2170,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) data->b_rptr = oldpos; printf("GetEAZAns "); conn->lockit--; - return EINVAL; + return -EINVAL; } ((struct t_info *)conn->p_data)->eaz = data->b_rptr[1]; } break; @@ -2181,14 +2182,14 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if ((asn = allocb (32, BPRI_MED)) == NULL) { conn->lockit--; - return ENOMEM; + return -ENOMEM; } if (((struct t_info *)conn->p_data)->flags & SVC_PENDING) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_netSpecFac, 4, 1)) == NULL) { freeb(asn); conn->lockit--; - return EIO; + return -EIO; } *(uchar_t *) qd_d++ = 0; *(uchar_t *) qd_d++ = N1_FAC_SVC; @@ -2196,7 +2197,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_netSpecFac, 4, 1)) == NULL) { freeb(asn); conn->lockit--; - return EIO; + return -EIO; } *(uchar_t *) qd_d++ = 0; *(uchar_t *) qd_d++ = N1_FAC_Activate; @@ -2206,14 +2207,14 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 6, PT_N6_serviceInd, 2, 0)) == NULL) { freeb (asn); conn->lockit--; - return EIO; + return -EIO; } *((uchar_t *) qd_d) = service >> 8; *(((uchar_t *) qd_d)+1) = service & 0xFF; if (((struct t_info *)conn->p_data)->eaz != 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_origAddr, 2, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *qd_d++ = 0x81; *qd_d++ = ((struct t_info *)conn->p_data)->eaz; @@ -2246,7 +2247,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; default: printf("BadState2 "); - err = EINVAL; + err = -EINVAL; break; } if (asn != NULL) @@ -2267,7 +2268,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (data == NULL) { conn->lockit--; - return ENOENT; + return -ENOENT; } while (m_getsx (data, &typ) == 0) { switch (typ) { @@ -2297,7 +2298,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) data->b_rptr = oldpos; printf("EAZ3 "); conn->lockit--; - return EINVAL; + return -EINVAL; } eaz = data->b_rptr[1]; eaz2= data->b_rptr[0]; @@ -2319,7 +2320,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if ((conn->minorstate & MS_CONN_MASK) == MS_CONN_NONE) { printf("NoConnThere "); conn->lockit--; - return EINVAL; + return -EINVAL; } if ((conn->minorstate & MS_CONN_MASK) != MS_CONN_INTERRUPT) { isdn3_setup_conn (conn, EST_WILL_INTERRUPT); @@ -2333,13 +2334,13 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if ((asn = allocb (32, BPRI_MED)) == NULL) { conn->lockit--; - return ENOMEM; + return -ENOMEM; } if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_netSpecFac, (gotservice || eaz2 != 0) ? ((eaz != 0 || eaz2 != 0) ? 6 : 4) : (eaz != 0) ? 5 : 4, 0)) == NULL) { freeb (asn); conn->lockit--; - return EIO; + return -EIO; } qd_d[0] = 0; qd_d[1] = (eaz2 > 0) ? N1_FAC_Dienstwechsel2 : N1_FAC_Dienstwechsel1; @@ -2377,7 +2378,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; default: printf("BadState4 "); - err = EINVAL; + err = -EINVAL; break; } if (asn != NULL) @@ -2446,7 +2447,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; default: printf("UnknownCmd "); - err = EINVAL; + err = -EINVAL; break; } if (data != NULL && err == 0) @@ -2515,6 +2516,6 @@ static void report (isdn3_conn conn, mblk_t *mb) struct _isdn3_prot prot_1TR6_1 = { - NULL, PD_N1, + NULL, SAPI_PHONE_1TR6_1, NULL, &chstate, &report, &recv, NULL, &sendcmd, &killconn, NULL, }; diff --git a/isdn_3/prot_ETS.c b/isdn_3/prot_ETS.c index d84a3fa..4389eea 100644 --- a/isdn_3/prot_ETS.c +++ b/isdn_3/prot_ETS.c @@ -11,6 +11,7 @@ #include #include "q_data.h" #include "phone_ETSI.h" +#include "sapi.h" #undef HAS_SUSPEND @@ -306,10 +307,10 @@ Xpr_setstate (isdn3_conn conn, uchar_t state, int deb_line) timer (ET_T310, conn); break; case 6: - timer (ET_TALERT, conn); + ftimer (ET_TALERT, conn); /* FALL THRU */ case 7: - timer (ET_TCONN, conn); + ftimer (ET_TCONN, conn); break; case 8: timer (ET_T313, conn); @@ -445,7 +446,7 @@ printf("FooL" ##s " is %d,%d\n",nlen,ilen); \ } \ nlen -= ilen+2; \ if((*qd_data & 0xFF) == (a)) { \ - int nlen = ilen; \ + int nlen __attribute__((unused)) = ilen; \ qd_data += 2; \ b; \ } else { \ @@ -747,11 +748,11 @@ report_ET_setup (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INCOMING); conn_info (conn, mb); @@ -772,11 +773,11 @@ report_ET_generic (isdn3_conn conn, uchar_t * data, int len, ushort_t id) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, id); @@ -803,11 +804,11 @@ report_ET_user_info (isdn3_conn conn, uchar_t * data, int len) int qd_len; uchar_t *qd_data; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_ET_USER_INFO); @@ -856,11 +857,11 @@ report_ET_conn (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_CONN); conn_info (conn, mb); @@ -884,11 +885,11 @@ report_ET_conn_ack (isdn3_conn conn, uchar_t * data, int len) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_ET_CONN_ACK); @@ -913,11 +914,11 @@ report_ET_stat (isdn3_conn conn, uchar_t * data, int len) int err = 0; char cval; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); if (mb == NULL) { pr_setstate (conn, 0); - return ENOMEM; + return -ENOMEM; } m_putid (mb, IND_INFO); m_putid (mb, ID_ET_STAT); @@ -961,7 +962,7 @@ Xreport_ET_terminate (isdn3_conn conn, uchar_t * data, int len, int deb_line) { int err = 0; - mblk_t *mb = allocb (128, BPRI_MED); + mblk_t *mb = allocb (256, BPRI_MED); printf("\nET Terminate at %d.\n",deb_line); if (mb == NULL) { @@ -1056,7 +1057,7 @@ ET_T304 (isdn3_conn conn) data = NULL; } else { *qd_d++ = 0x80; - *qd_d++ = 0x90; /* normal call clearing */ + *qd_d++ = 0x80 | ET_TimerRecovery; data->b_wptr += qd_len; } } @@ -1089,8 +1090,25 @@ ET_T308 (isdn3_conn conn) conn->timerflags &= ~RUN_ET_T308; switch (conn->state) { case 19: - /* DSS1: Retry! */ + { + mblk_t *data; + data = allocb(16,BPRI_MED); + if(data != NULL) { + unsigned char * qd_d; + int qd_len = 0; + if ((qd_d = qd_insert ((uchar_t *) data->b_rptr, &qd_len, 0, PT_E0_cause, 2, 0)) == NULL) { + freemsg(data); + } else { + *qd_d++ = 0x80; + *qd_d++ = 0x80 | ET_TimerRecovery; + data->b_wptr += qd_len; + if (phone_sendback (conn, MT_ET_DISC, data) < 0) + freemsg(data); + } + } + } pr_setstate(conn,0); + break; } et_checkterm (conn, NULL, 0); } @@ -1124,7 +1142,7 @@ ET_T310 (isdn3_conn conn) data = NULL; } else { *qd_d++ = 0x80; - *qd_d++ = 0x90; /* normal call clearing */ + *qd_d++ = 0x80 | ET_TimerRecovery; data->b_wptr += qd_len; } } @@ -1155,7 +1173,7 @@ ET_T313 (isdn3_conn conn) data = NULL; } else { *qd_d++ = 0x80; - *qd_d++ = 0x90; /* normal call clearing */ + *qd_d++ = 0x80 | ET_TimerRecovery; data->b_wptr += qd_len; } } @@ -1350,7 +1368,7 @@ release_postET (isdn3_conn conn, uchar_t minor, char force) data = NULL; } else { *qd_d++ = 0x80; - *qd_d++ = 0x90; /* normal call clearing */ + *qd_d++ = 0x80 | ET_TimerRecovery; data->b_wptr += qd_len; } } @@ -1487,6 +1505,10 @@ printf (" ET: Recv %x in state %d\n", msgtype, conn->state); report_ET_generic (conn, data, len, ID_ET_INFO); break; + case MT_ET_FAC: + report_ET_generic (conn, data, len, ID_ET_FAC); + break; + case MT_ET_STAT: { int qd_len; @@ -1509,7 +1531,8 @@ printf (" ET: Recv %x in state %d\n", msgtype, conn->state); goto do_continue; isdn3_setup_conn (conn, EST_DISCONNECT); report_ET_terminate (conn, data, len); - if(conn->state == 6 || conn->state == 7) + ComEx: + if(conn->state == 6 || conn->state == 7 || conn->state == 99) pr_setstate (conn, 99); else pr_setstate (conn, 0); @@ -1523,8 +1546,7 @@ printf (" ET: Recv %x in state %d\n", msgtype, conn->state); phone_sendback (conn, MT_ET_REL_COM, NULL); isdn3_setup_conn (conn, EST_DISCONNECT); report_ET_terminate (conn, data, len); - pr_setstate (conn, 0); - break; + goto ComEx; case MT_ET_DISC: if (conn->state == 0 || conn->state == 1 || conn->state == 6 || conn->state == 11 || conn->state == 12 @@ -2113,7 +2135,7 @@ chstate (isdn3_conn conn, uchar_t ind, short add) data = NULL; } else { *qd_d++ = 0x80; - *qd_d++ = 0x90; /* normal call clearing */ + *qd_d++ = 0x80 | ET_TempFailure; data->b_wptr += qd_len; } } @@ -2136,7 +2158,7 @@ chstate (isdn3_conn conn, uchar_t ind, short add) data = NULL; } else { *qd_d++ = 0x80; - *qd_d++ = 0x90; /* normal call clearing */ + *qd_d++ = 0x80 | ET_TempFailure; data->b_wptr += qd_len; } } @@ -2178,7 +2200,7 @@ send_ET_disc (isdn3_conn conn, char release, mblk_t * data) #ifdef HAS_SUSPEND case 15: case 17: - return EBUSY; + return -EBUSY; #endif case 12: if (((err = phone_sendback (conn, MT_ET_REL, data)) != 0) && (data != NULL)) @@ -2189,7 +2211,7 @@ send_ET_disc (isdn3_conn conn, char release, mblk_t * data) if (release) { goto common_off_noconn; /* Is this confirming? */ } else - return EBUSY; + return -EBUSY; case 1: case 2: case 3: @@ -2209,7 +2231,7 @@ send_ET_disc (isdn3_conn conn, char release, mblk_t * data) freemsg(owndata); } else { *qd_d++ = 0x80; - *qd_d++ = 0x90; /* normal call clearing */ + *qd_d++ = 0x80 | ET_NormalClear; data->b_wptr += qd_len; } } @@ -2224,7 +2246,7 @@ send_ET_disc (isdn3_conn conn, char release, mblk_t * data) goto common_off; /* XXX experimental */ if ((err = phone_sendback (conn, MT_ET_REL_COM, data)) != 0 && data != NULL) freemsg(data); - pr_setstate (conn, 19); + pr_setstate (conn, 99); /* was 19 -- mistake */ break; case 19: case 99: @@ -2311,7 +2333,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) data->b_rptr = oldpos; printf("GetX EAZ: "); conn->lockit--; - return EINVAL; + return -EINVAL; } conn->eaz = *data->b_rptr++; } break; @@ -2344,7 +2366,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (data == NULL) { printf("DataNull: "); conn->lockit--; - return EINVAL; + return -EINVAL; } conn->minorstate |= MS_OUTGOING | MS_WANTCONN; @@ -2363,38 +2385,38 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (conn->minor == 0) { printf("ConnMinorZero: "); conn->lockit--; - return ENOENT; + return -ENOENT; } if (conn->mode == 0) - err = ENOEXEC; + err = -ENOEXEC; { - mblk_t *asn = allocb (128, BPRI_MED); + mblk_t *asn = allocb (256, BPRI_MED); int qd_len = 0; uchar_t *qd_d; if (asn == NULL) { conn->lockit--; - return ENOMEM; + return -ENOMEM; } if (info->bearer_len > 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_E0_bearer_cap, info->bearer_len, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } bcopy(info->bearer,qd_d,info->bearer_len); } if (info->llc_len > 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_E0_compatLo, info->llc_len, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } bcopy(info->llc,qd_d,info->llc_len); } if (info->ulc_len > 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_E0_compatLo, info->ulc_len, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } bcopy(info->ulc,qd_d,info->ulc_len); } @@ -2424,7 +2446,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_E0_destAddr, j - i + 1, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *qd_d++ = nrtype | 0x80; qd_d -= i; /* compensate for i-offset of the number */ @@ -2459,7 +2481,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_E0_origAddr, j - i + 1, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } *qd_d++ = nrtype | 0x80; qd_d -= i; /* compensate for i-offset of the number */ @@ -2470,7 +2492,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) int basic = (conn->card ? conn->card->bchans <= 2 : 1); if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_E0_chanID, basic ? 1 : 3, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } if (basic) { *qd_d = 0x80 | conn->bchan; @@ -2496,7 +2518,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) default: printf("Default %d: ", conn->state); conn->lockit--; - return EBUSY; + return -EBUSY; } } break; @@ -2530,7 +2552,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; default: printf("BadState1: "); - err = EINVAL; + err = -EINVAL; } break; case CMD_ANSWER: @@ -2542,14 +2564,14 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) int qd_len = 0; uchar_t *qd_d; - if ((asn = allocb (128, BPRI_MED)) == NULL) { + if ((asn = allocb (256, BPRI_MED)) == NULL) { conn->lockit--; - return ENOMEM; + return -ENOMEM; } if (info->llc_len > 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 6, PT_E0_compatLo, info->llc_len, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } bcopy(info->llc,qd_d,info->llc_len); } @@ -2557,14 +2579,14 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (info->ulc_len > 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 6, PT_E0_compatLo, info->ulc_len, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } bcopy(info->ulc,qd_d,info->ulc_len); } if (info->bearer_len > 0) { if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 6, PT_E0_bearer_cap, info->bearer_len, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } bcopy(info->bearer,qd_d,info->bearer_len); } @@ -2575,7 +2597,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) int basic = (conn->card ? conn->card->bchans <= 2 : 1); if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_E0_chanID, basic ? 1 : 3, 0)) == NULL) { conn->lockit--; - return EIO; + return -EIO; } if (basic) { *qd_d = 0x80 | conn->bchan; @@ -2625,7 +2647,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; default: printf("BadState2 "); - err = EINVAL; + err = -EINVAL; break; } if (asn != NULL) @@ -2647,7 +2669,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if (data == NULL) { conn->lockit--; - return ENOENT; + return -ENOENT; } while (m_getsx (data, &typ) == 0) { switch (typ) { @@ -2676,7 +2698,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) data->b_rptr = oldpos; printf("EAZ3 "); conn->lockit--; - return EINVAL; + return -EINVAL; } eaz = *data->b_rptr++; } break; @@ -2686,7 +2708,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) data->b_rptr = oldpos; printf("EAZ4 "); conn->lockit--; - return EINVAL; + return -EINVAL; } eaz2 = *data->b_rptr++; } break; @@ -2707,7 +2729,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if ((conn->minorstate & MS_CONN_MASK) == MS_CONN_NONE) { printf("NoConnThere "); conn->lockit--; - return EINVAL; + return -EINVAL; } if ((conn->minorstate & MS_CONN_MASK) != MS_CONN_INTERRUPT) { isdn3_setup_conn (conn, EST_WILL_INTERRUPT); @@ -2722,13 +2744,13 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) if ((asn = allocb (32, BPRI_MED)) == NULL) { conn->lockit--; - return ENOMEM; + return -ENOMEM; } if ((qd_d = qd_insert ((uchar_t *) asn->b_rptr, &qd_len, 0, PT_N0_netSpecFac, (gotservice || eaz2 != 0) ? ((eaz != 0 || eaz2 != 0) ? 6 : 4) : (eaz != 0) ? 5 : 4, 0)) == NULL) { freeb (asn); conn->lockit--; - return EIO; + return -EIO; } qd_d[0] = 0; qd_d[1] = (eaz2 > 0) ? ET_FAC_Dienstwechsel2 : ET_FAC_Dienstwechsel1; @@ -2767,7 +2789,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; default: printf("BadState4 "); - err = EINVAL; + err = -EINVAL; break; } if (asn != NULL) @@ -2835,7 +2857,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) break; default: printf("UnknownCmd "); - err = EINVAL; + err = -EINVAL; break; } if (data != NULL && err == 0) @@ -2911,7 +2933,7 @@ static void report (isdn3_conn conn, mblk_t *mb) struct _isdn3_prot prot_ETSI = { - NULL, PD_Q931, + NULL, SAPI_PHONE_DSS1, NULL, &chstate, &report, &recv, NULL, &sendcmd, &killconn, NULL, }; diff --git a/isdn_3/tei.c b/isdn_3/tei.c index 29988e9..b049f14 100644 --- a/isdn_3/tei.c +++ b/isdn_3/tei.c @@ -8,8 +8,7 @@ #include #include #include - -#define SAPI_TEI 63 +#include "sapi.h" #define TEI_IDREQ 1 #define TEI_IDASS 2 @@ -19,10 +18,13 @@ #define TEI_IDREMOVE 6 #define TEI_IDVERIFY 7 -#define NR talk_a -#define TEI_id talk_b +#if NITALK <= 2 +#error "Need NITALK > 2" +#endif +#define NR talki[0] +#define TEI_id talki[1] #ifdef NEW_TIMEOUT -#define timer talk_c +#define timer talki[2] #endif #define N201 2 #define T201 2 @@ -40,16 +42,18 @@ tei_send_id (isdn3_card card, uchar_t TEI) mblk_t *mb; isdn23_hdr hdr; int err; + extern int hdrseq; mb = allocb (sizeof (struct _isdn23_hdr), BPRI_MED); if (mb == NULL) - return EAGAIN; + return -EAGAIN; hdr = ((isdn23_hdr) mb->b_wptr)++; #ifdef __CHECKER__ bzero(hdr,sizeof(*hdr)); #endif hdr->key = HDR_TEI; + hdr->seqnum = hdrseq; hdrseq += 2; hdr->hdr_tei.card = card->nr; hdr->hdr_tei.TEI = TEI; if ((err = isdn3_sendhdr (mb)) != 0) @@ -183,14 +187,14 @@ tei_verify (isdn3_talk talk) static void tei_T201 (isdn3_talk talk) { - printf ("Timer TEI T201 %d\n", talk->NR); + printf ("Timer TEI T201 %ld\n", talk->NR); if (talk->state & ST_T201) { talk->state &= ~ST_T201; if (!(talk->state & ST_up)) { talk->state |= ST_want_T202; return; } - if (talk->NR >= N201 && tei_send_id (talk->card, TEI_BROADCAST) != EAGAIN) { + if (talk->NR >= N201 && tei_send_id (talk->card, TEI_BROADCAST) != -EAGAIN) { tei_enquiry(talk); } else { talk->NR++; @@ -203,7 +207,7 @@ tei_T201 (isdn3_talk talk) static void tei_T202 (isdn3_talk talk) { - printf ("Timer TEI T202 %d\n", talk->NR); + printf ("Timer TEI T202 %ld\n", talk->NR); if (talk->state & ST_T202) { talk->state &= ~ST_T202; if (!(talk->state & ST_up)) { @@ -211,7 +215,7 @@ tei_T202 (isdn3_talk talk) return; } if (talk->NR >= N202) { - if (tei_send_id (talk->card, TEI_BROADCAST) == EAGAIN) { + if (tei_send_id (talk->card, TEI_BROADCAST) == -EAGAIN) { talk->state |= ST_T202; talk->state &=~ ST_want_T202; #ifdef NEW_TIMEOUT @@ -306,11 +310,11 @@ tei_recv (isdn3_talk talk, char isUI, mblk_t * data) } if (!(isUI & 2)) { /* got to be a broadcast */ printf("TEI RejNoBroadcast\n"); - return EINVAL; + return -EINVAL; } mb = pullupm (data, 4); if (mb == NULL) - return ENOMEM; + return -ENOMEM; /* Do not return nonzero after this point */ if (*mb->b_rptr++ != 0x0F) { @@ -455,13 +459,13 @@ static int tei_sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) { printf("TEI SendCmd Foo "); - return EINVAL; + return -EINVAL; } static int tei_send (isdn3_conn conn, mblk_t * data) { - return EINVAL; + return -EINVAL; } static void @@ -511,9 +515,9 @@ tei_getid (isdn3_card card) isdn3_talk talk; if ((hndl = isdn3_findhndl (SAPI_TEI)) == NULL) - return ENXIO; + return -ENXIO; if ((talk = isdn3_findtalk (card, hndl, NULL, 0)) == NULL) - return ENXIO; + return -ENXIO; if (!talk->state & ST_inited) tei_init (talk); @@ -529,5 +533,6 @@ tei_getid (isdn3_card card) struct _isdn3_hndl TEI_hndl = { NULL, SAPI_TEI,1, - NULL, &tei_newcard, &tei_modeflags, &tei_chstate, NULL, &tei_recv, &tei_send, &tei_sendcmd, &tei_kill, NULL, NULL, + NULL, &tei_newcard, &tei_modeflags, &tei_chstate, NULL, &tei_recv, + &tei_send, &tei_sendcmd, &tei_kill, NULL, NULL, NULL, }; diff --git a/isdn_4/Makefile b/isdn_4/Makefile index ba02897..96da6cf 100644 --- a/isdn_4/Makefile +++ b/isdn_4/Makefile @@ -1,47 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = - -## =()@>()= -CC = gcc -## =()@ @@ -DLEVEL=@@ -I../include >()= -DEFS = -DDUMB -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -DLEVEL=3 -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@>()= -LDFLAGS = -static -v -## =()@>()= -LEVEL = 3 -## =()@>()= -LIBS = -lbsd - -SOURCES = cf.c conn.c devs.c info.c malldebug.c master.c match.c nr.c \ - stream.c texts.c util.c work.c loader.c -OBJ = cf.o conn.o devs.o info.o malldebug.o master.o match.o nr.o \ - stream.o texts.o util.o work.o loader.o -ALL = master - -all prog: $(OBJ) $(ALL) - -install update: all - -master: $(P) $(OBJ) ../support.a ../isdn_3.a - $(CC) $(LDFLAGS) -o $@ $(OBJ) `./libs.sh $(LEVEL)` $(LIBS) -lib: - -clean: - rm -f $(OBJ) $(ALL) master.old - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +PROGRAM = master +EXTRA_LIBS=../isdn_3.a ../support.a +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/isdn_4/cf.c b/isdn_4/cf.c index 1a711f0..d8263a8 100644 --- a/isdn_4/cf.c +++ b/isdn_4/cf.c @@ -9,6 +9,7 @@ static int seqnum; +/* Read a line, handle empty lines and continuations. */ struct _cf * read_line (FILE * ffile, int *theLine) { @@ -36,7 +37,7 @@ read_line (FILE * ffile, int *theLine) break; } } - if (*line == '#') { + if (*line == '#' || *line == '\n') { sofar = line; *line = '\0'; remain = MAXLINE; @@ -47,15 +48,13 @@ read_line (FILE * ffile, int *theLine) *sofar = '\0'; out = (struct _cf *)malloc (sizeof (struct _cf) + (now = sofar - line + 1)); - chkone(out); bcopy (line, (char *) (out + 1), now); - chkone(out); bzero ((char *) out, sizeof (struct _cf)); - chkone(out); return out; } -void +/* Append a config entry to a list of config entries. */ +static void app (cf * where, cf who) { char *x = (char *) who + 1; @@ -74,7 +73,8 @@ app (cf * where, cf who) #endif } -int +/* Skip spaces */ +static int skipsp (char **li) { char *x = *li; @@ -91,7 +91,7 @@ skipsp (char **li) } #ifdef unused -void +static void skipword (char **li) { char *x = *li; @@ -102,6 +102,7 @@ skipword (char **li) } #endif +/* Read a config file */ void read_file (FILE * ffile, char *errf) { @@ -122,7 +123,7 @@ read_file (FILE * ffile, char *errf) if (skipsp (&li)) break; c->cclass = li; if (skipsp (&li)) break; c->card = li; if (skipsp (&li)) break; c->type = li; - if (skipsp (&li)) break; c->args = li; + if (skipsp (&li)) c->args = ""; else c->args = li; chkone(c); c->protocol = str_enter(c->protocol); c->site = str_enter(c->site); @@ -198,11 +199,13 @@ read_file (FILE * ffile, char *errf) app (&cf_D, c); continue; case CHAR2 ('D', 'L'): - /* DL */ + /* DL */ + if (skipsp (&li)) break; c->cclass = li; if (skipsp (&li)) break; c->card = li; if (skipsp (&li)) break; c->arg = li; - if (skipsp (&li)) break; c->args = li; + if (skipsp (&li)) c->args = ""; else c->args = li; chkone(c); + c->cclass = str_enter(c->cclass); c->card = str_enter(c->card); c->arg = str_enter(c->arg); c->args = str_enter(c->args); @@ -298,12 +301,14 @@ read_file (FILE * ffile, char *errf) continue; case CHAR2 ('C', 'L'): if (skipsp (&li)) break; c->card = li; + if (skipsp (&li)) break; c->cclass = li; if (skipsp (&li)) break; if ((c->num = atoi (li)) == 0 && li[0] != '0') break;; if (!skipsp (&li)) c->args = li; chkone(c); c->site = str_enter(c->site); + c->cclass = str_enter(c->cclass); c->args = str_enter(c->args); app (&cf_CL, c); continue; @@ -316,6 +321,7 @@ read_file (FILE * ffile, char *errf) char **fileargs; +/* Read all the files. */ void read_args (void *nix) { @@ -357,6 +363,7 @@ read_args (void *nix) } } +/* Read all the files and kick off the programs. */ void read_args_run(void *nix) { diff --git a/isdn_4/conn.c b/isdn_4/conn.c index 763fff3..65f5273 100644 --- a/isdn_4/conn.c +++ b/isdn_4/conn.c @@ -8,6 +8,9 @@ #include "master.h" +/* Clone a connection info record ("conngrab" because I use it to collect + all pertinent information to grab data out of the configuration files + with), or create a new one. */ conngrab Xnewgrab(conngrab master, int lin) { conngrab slave; @@ -15,9 +18,10 @@ conngrab Xnewgrab(conngrab master, int lin) slave = malloc(sizeof(*slave)); if(slave == NULL) return NULL; - if(master == NULL) + if(master == NULL) { bzero(slave,sizeof(*slave)); - else { + slave->cclass = str_enter("*"); + } else { if(master->refs == 0 || master->protocol == (char *)0xdeadbeef) panic("FreeGrab"); *slave = *master; @@ -26,12 +30,11 @@ conngrab Xnewgrab(conngrab master, int lin) if(slave->par_in != NULL) slave->par_in = dupmsg(slave->par_in); } -if(0)printf("\nNG + %p %d\n",slave,lin); slave->refs = 1; return slave; } -#define dropgrab(x) Xdropgrab((x),__LINE__) +/* Forget one... */ void Xdropgrab(conngrab cg,int lin) { if(cg == NULL) @@ -53,18 +56,18 @@ void Xdropgrab(conngrab cg,int lin) cg->card = (void *)0xdeadbeef; chkone(cg); free(cg); -if(0)printf("\nNG - %p %d\n",cg,lin); return; } -if(0)printf("\nNG ? %p %d %d\n",cg,lin,cg->refs); } +/* Set the reference number. For debugging. */ void Xsetconnref(const char *deb_file, unsigned int deb_line, conninfo conn, int connref) { - printf("-%s:%d: SetConnRef.%p %d/%d/%ld -> %d\n",deb_file,deb_line,conn,conn->minor,conn->fminor,conn->connref,connref); + if(0)printf("-%s:%d: SetConnRef.%p %d/%d/%ld -> %d\n",deb_file,deb_line,conn,conn->minor,conn->fminor,conn->connref,connref); conn->connref = connref; } +/* Print the text foo onto all ATL/ channels. */ void connreport(char *foo) { conninfo conn; @@ -101,6 +104,7 @@ void connreport(char *foo) } } +/* Print the state of this connection with connreport(). */ void ReportConn(conninfo conn) { char sp[200], *spf = sp; @@ -130,6 +134,8 @@ void ReportConn(conninfo conn) connreport(sp); } +/* Sets the state of a connection; does all the housekeeping associated + with the change. */ void Xsetconnstate(const char *deb_file, unsigned int deb_line,conninfo conn, CState state) { chkone(conn); @@ -239,19 +245,19 @@ void Xsetconnstate(const char *deb_file, unsigned int deb_line,conninfo conn, CS } } - +/* "rdrop" means "really drop". */ void rdropconn (struct conninfo *conn, int deb_line) { conn->ignore=2; dropconn(conn); } void -Xdropconn (struct conninfo *conn, int deb_line) +Xdropconn (struct conninfo *conn, const char *deb_file, unsigned int deb_line) { chkone(conn); if(conn->locked) { - printf ("DropConn %d: LOCK %d/%d/%ld\n", deb_line, conn->minor, conn->fminor, conn->connref); + if(1)printf ("DropConn %s:%d: LOCK %d/%d/%ld\n", deb_file,deb_line, conn->minor, conn->fminor, conn->connref); return; } - printf ("DropConn %d: %d/%d/%ld\n", deb_line, conn->minor, conn->fminor, conn->connref); + if(1)printf ("DropConn %s:%d: %d/%d/%ld\n", deb_file,deb_line, conn->minor, conn->fminor, conn->connref); if(!conn->ignore) { conn->ignore=1; setconnstate(conn,c_forceoff); @@ -261,24 +267,25 @@ Xdropconn (struct conninfo *conn, int deb_line) else ReportConn(conn); #endif - timeout(rdropconn,conn,HZ*60*5); + timeout(rdropconn,conn,HZ*60*5); /* Drop the record after five minutes */ return; - } else if(conn->ignore == 1) { + } else if(conn->ignore == 1) { /* already going to drop it */ setconnstate(conn,c_forceoff); return; } else setconnstate(conn,c_forceoff); - if (theconn == conn) - theconn = conn->next; - else { - struct conninfo *sconn; - for (sconn = theconn; sconn != NULL; sconn = sconn->next) { - if (sconn->next == conn) { - sconn->next = conn->next; + { /* unchain the conn from the list */ + /* Could use a doubly-linked list here, but what the ... */ + struct conninfo **pconn = &theconn; + while(*pconn != NULL) { + if(*pconn == conn) { + *pconn = conn->next; break; } + pconn = &(*pconn)->next; } + } { struct proginfo *run; @@ -289,7 +296,7 @@ Xdropconn (struct conninfo *conn, int deb_line) run->master = NULL; } } - { + { /* Say that we forgot the thing. */ char xs[10]; sprintf(xs,"-%d",conn->seqnum); connreport(xs); @@ -315,7 +322,7 @@ void retime(struct conninfo *conn) m_putid (mb, PROTO_ENABLE); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); freemsg(mb); } } @@ -335,6 +342,7 @@ void time_reconn(struct conninfo *conn) } } +/* Reestablish a connection, eg. because data are to be transmitted. */ void try_reconn(struct conninfo *conn) { mblk_t *md; @@ -412,7 +420,7 @@ void try_reconn(struct conninfo *conn) m_putid (mb, PROTO_DISABLE); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); freeb(mb); } } else { @@ -434,7 +442,7 @@ printf("DropThis, %s\n",ret); xlen=md->b_wptr-md->b_rptr; DUMPW (md->b_rptr, xlen); - (void) strwrite (xs_mon, md->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, md->b_rptr, xlen, 1); freeb(md); } else setconnstate(conn,c_off); diff --git a/isdn_4/devs.c b/isdn_4/devs.c index 9568be5..e24bca8 100644 --- a/isdn_4/devs.c +++ b/isdn_4/devs.c @@ -58,7 +58,6 @@ idevname (short minor) /* Check a lock file. */ - void checkdev(int dev) { @@ -84,7 +83,7 @@ checkdev(int dev) else sbuf[len]='\0'; pid = atoi(sbuf); - if(pid <= 0 || (kill(pid,0) == -1 && errno == ESRCH)) { + if(pid <= 0 || (kill(pid,0) == -1 && errno == -ESRCH)) { if(0)syslog(LOG_WARNING,"Checking %s: unkillable, pid %d, deleted, %m",permtt1, pid); unlink(permtt1); } @@ -105,7 +104,7 @@ checkdev(int dev) else sbuf[len]='\0'; pid = atoi(sbuf); - if(pid <= 0 || (kill(pid,0) == -1 && errno == ESRCH)) { + if(pid <= 0 || (kill(pid,0) == -1 && errno == -ESRCH)) { if(0)syslog(LOG_WARNING,"Checking %s: unkillable, pid %d, deleted, %m",permtt2, pid); unlink(permtt2); } @@ -116,7 +115,6 @@ checkdev(int dev) /* Lock a device. One failure, for externally-opened devices (cu), may be tolerated. */ - int lockdev(int dev, char onefailok) { @@ -173,7 +171,6 @@ lockdev(int dev, char onefailok) /* ... and unlock it. */ - void unlockdev(int dev) { diff --git a/isdn_4/info.c b/isdn_4/info.c index 83deb14..af91010 100644 --- a/isdn_4/info.c +++ b/isdn_4/info.c @@ -27,6 +27,9 @@ char *resp; long fminor; long minor; long callref; +long foffset; +long thelength; +long seqnum; struct conninfo *conn; char crd[5]; char prot[20]; @@ -42,7 +45,11 @@ int has_force; long bchan; long hdrval; char no_error; +struct loader *loader; +long errnum; + +/* Take the incoming arguments and put them into their variables. */ int parse_arg(void) { @@ -65,7 +72,7 @@ parse_arg(void) int err2; if ((err2 = m_getstr (&xx, nr, MAXNR)) != 0) { - if (err2 != ENOENT && err2 != ESRCH) { + if (err2 != -ENOENT && err2 != -ESRCH) { printf (" XErr 0\n"); return 2; } @@ -76,7 +83,7 @@ parse_arg(void) int err2; if ((err2 = m_getstr (&xx, lnr, MAXNR)) != 0) { - if (err2 != ENOENT && err2 != ESRCH) { + if (err2 != -ENOENT && err2 != -ESRCH) { printf (" XErr 02\n"); return 2; } @@ -87,6 +94,10 @@ parse_arg(void) printf (" XErr 1\n"); return 2; } + for(loader = isdn4_loader; loader != NULL; loader = loader->next) { + if(!strcmp(crd,loader->name)) + break; + } break; case PROTO_INCOMING: dialin = 1; @@ -104,12 +115,36 @@ parse_arg(void) return 2; } break; + case ARG_LENGTH: + if (m_geti (&xx, &thelength) != 0) { + printf (" XErr len\n"); + return 2; + } + break; + case ARG_OFFSET: + if (m_geti (&xx, &foffset) != 0) { + printf (" XErr off\n"); + return 2; + } + break; + case ARG_SEQNUM: + if (m_geti (&xx, &seqnum) != 0) { + printf (" XErr seq\n"); + return 2; + } + break; case ARG_UID: if (m_geti (&xx, &uid) != 0) { printf (" XErr u\n"); return 2; } break; + case ARG_ERRNO: + if (m_geti (&xx, &errnum) != 0) { + printf (" XErr en\n"); + if(0)return 2; + } + break; case ARG_ERRHDR: if (m_geti (&xx, &hdrval) != 0) { printf (" XErr 34\n"); @@ -161,6 +196,8 @@ parse_arg(void) return 0; } + +/* Get the best-matching connection for the arguments we found. */ void find_conn(void) { @@ -230,6 +267,7 @@ find_conn(void) } } +/* Self-explanatory... */ int init_vars (void) { @@ -252,6 +290,10 @@ init_vars (void) bchan = -1; hdrval = -1; no_error = 0; + seqnum = 0; + foffset = -1; + thelength = -1; + errnum = 0; *(ulong_t *) crd = 0; crd[4] = '\0'; @@ -271,14 +313,16 @@ init_vars (void) return 0; } +/* Incoming IND_CARD -- a new ISDN card is recognized, or somebody put the + ISDN cable back in. */ int do_card(void) { - short cpos; cf dl; long nbchan; long cardcap; int ret; + struct isdncard *card; if ((ret = m_getstr (&xx, crd, 4)) != 0) return ret; @@ -286,29 +330,45 @@ do_card(void) return ret; if ((ret = m_getx (&xx, &cardcap)) != 0) return ret; - for (cpos = 0; cpos < cardnum; cpos++) { - if (!strcmp(cardlist[cpos], crd)) + for(card = isdn4_card; card != NULL; card = card->next) { + if (!strcmp(card->name, crd)) return -EEXIST; } - if (cardnum >= NCARDS) - return -ENOSPC; - cardlist[cardnum] = str_enter(crd); - cardnrbchan[cardnum] = nbchan; - cardnum++; + card = malloc(sizeof(*card)); + if(card == NULL) + return -ENOMEM; + bzero(card,sizeof(*card)); + card->name = str_enter(crd); + card->nrbchan = nbchan; + card->cap = cardcap; + card->next = isdn4_card; + isdn4_card = card; + if(cardcap & CHM_INTELLIGENT) { struct loader *ld = malloc(sizeof(struct loader)); if(ld == NULL) return -errno; bzero(ld,sizeof(*ld)); - ld->card = str_enter(crd); + ld->card = card; + ld->name = str_enter(crd); + ld->next = isdn4_loader; + isdn4_loader = ld; + + card->name = str_enter("NULL"); + ld->card = card; card_load(ld); - } else for(dl = cf_DL; dl != NULL; dl = dl->next) { + } else { struct iovec io[3]; int len; + for(dl = cf_DL; dl != NULL; dl = dl->next) { + if(wildmatch(crd,dl->card)) + break; + } + if(dl == NULL) + return -ENXIO; + card->name = str_enter(crd); - if(!wildmatch(crd,dl->card)) - continue; xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); @@ -333,7 +393,6 @@ do_card(void) len++; } (void) strwritev (xs_mon, io,len, 1); - break; } do_run_now++; timeout(run_now,NULL,3*HZ); @@ -341,27 +400,28 @@ do_card(void) return 0; } +/* IND_NOCARD; an ISDN cable got pulled. */ int do_nocard(void) { - short cpos; int ret; + struct isdncard **pcard; if ((ret = m_getstr(&xx, crd, 4)) != 0) return ret; - for (cpos = 0; cpos < cardnum; cpos++) { - if (!strcmp(cardlist[cpos], crd)) { - --cardnum; - cardlist[cpos] = cardlist[cardnum]; - cardnrbchan[cpos] = cardnrbchan[cardnum]; - if(cardidx >= cardnum) - cardidx = 0; + for (pcard = &isdn4_card; *pcard != NULL; pcard = &(*pcard)->next) { + if (!strcmp((*pcard)->name, crd)) { + struct isdncard *card = *pcard; + *pcard = card->next; + free(card); return 0; } } return -ENOENT; } +/* IND_CARDPROTO: request to set the mode of a channel. */ +/* Maps to a call of pushcardprot(). */ int do_cardproto(void) { @@ -395,7 +455,7 @@ do_cardproto(void) xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); -printf("Dis10 "); + if(1)printf("Dis10 "); m_putid (&xx, CMD_OFF); if(minor > 0) { m_putsx (&xx, ARG_MINOR); @@ -416,7 +476,7 @@ printf("Dis10 "); xlen = xx.b_wptr - xx.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); return 2; } @@ -430,7 +490,7 @@ printf("Dis10 "); xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); -printf("Dis11 "); + if(1)printf("Dis11 "); m_putid (&xx, CMD_OFF); if(minor > 0) { m_putsx (&xx, ARG_MINOR); @@ -451,7 +511,7 @@ printf("Dis11 "); xlen = xx.b_wptr - xx.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); resp = "ERROR"; @@ -461,6 +521,8 @@ printf("Dis11 "); return 0; } +/* IND_PROTO: Request to set the connection information. + Maps to a call of pushprot(). */ int do_proto(void) { @@ -505,7 +567,7 @@ do_proto(void) xlen = xx.b_wptr - xx.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); return 2; } if (pushprot (cg, minor, ind == IND_PROTO_AGAIN) == 0) { @@ -525,7 +587,7 @@ do_proto(void) xlen = xx.b_wptr - xx.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); resp = "ERROR"; return 1; @@ -534,6 +596,7 @@ do_proto(void) return 0; } +/* IND_INCOMING: Incoming call processing. */ int do_incoming(void) { @@ -568,7 +631,8 @@ do_incoming(void) } { char *sit = NULL,*pro = NULL,*car = NULL,*cla = NULL; /* GCC */ -printf("Hunt for %s/%s/%s/%s/%o\n",cg->site,cg->protocol,cg->card,cg->cclass,cg->flags); + if(0)printf("Hunt for %s/%s/%s/%s/%o\n",cg->site,cg->protocol,cg->card,cg->cclass,cg->flags); + /* Figure out which program to run. */ for (cfr = cf_R; cfr != NULL; cfr = cfr->next) { if(cfr->got_err) continue; if (!matchflag(cg->flags,cfr->type)) continue; @@ -578,13 +642,18 @@ printf("Hunt for %s/%s/%s/%s/%o\n",cg->site,cg->protocol,cg->card,cg->cclass,cg- if ((cla =classmatch (cg->cclass, cfr->cclass)) == NULL) continue; break; } - if (cfr == NULL) { + if (cfr == NULL) { /* None. Sorry, won't do; ATA isn't implemented yet... */ resp = "NO PROGRAM"; goto inc_err; } cg->site = sit; cg->protocol = pro; cg->cclass = cla; cg->card = car; } + if((bchan < 0) && (cg->flags & F_CHANBUSY)) { + resp = "0BUSY other"; + goto inc_err; + } if(((conn = startconn(cg,fminor,connref,&resp)) != NULL) && (resp != NULL)) { + /* An existing connection feels responsible for this. */ mblk_t *mz; if(conn->state == c_forceoff) { goto cont; @@ -593,12 +662,12 @@ printf("Hunt for %s/%s/%s/%s/%o\n",cg->site,cg->protocol,cg->card,cg->cclass,cg- goto cont; } - printf("\n*** ConnRef Clash! old is %ld, new %ld\n",conn->connref,connref); + if(0)printf("\n*** ConnRef Clash! old is %ld, new %ld\n",conn->connref,connref); mz = allocb(40,BPRI_HI); if(mz == NULL) goto cont; - if(*resp != '+') { -printf("Dis1 "); + if(*resp != '+') { /* Throw away the incoming call */ + if(1)printf("Dis1 "); m_putid (mz, CMD_OFF); m_putsx (mz, ARG_NODISC); m_putsx (mz, ARG_FORCE); @@ -624,7 +693,7 @@ printf("Dis1 "); syslog (LOG_WARNING, "DropIn '??' for ???/%s", nr); xlen = mz->b_wptr - mz->b_rptr; DUMPW (mz->b_rptr, xlen); - (void) strwrite (xs_mon, mz->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, mz->b_rptr, xlen, 1); freeb(mz); if(*resp == '=') { @@ -647,11 +716,8 @@ printf("Dis1 "); dropconn(conn); } resp = NULL; - } else { -#if 0 - dropother: -#endif -printf("Dis2 "); + } else { /* Throw away the outgoing call */ + if(1)printf("Dis2 "); m_putid (mz, CMD_OFF); m_putsx (mz, ARG_NODISC); m_putsx (mz, ID_N0_cause); @@ -672,7 +738,7 @@ printf("Dis2 "); syslog (LOG_WARNING, "DropOut '??' for ??/??/%s", nr); xlen = mz->b_wptr - mz->b_rptr; DUMPW (mz->b_rptr, xlen); - (void) strwrite (xs_mon, mz->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, mz->b_rptr, xlen, 1); freeb(mz); resp = NULL; dropgrab(conn->cg); cg->refs++; conn->cg = cg; @@ -698,8 +764,11 @@ printf("Dis2 "); } } goto cont; - } else if(conn != NULL) + } else if(conn != NULL) /* existing connection record */ goto cont; + + /* At this point we don't have a connection. The call is valid, so + record the thing and start the program for it. */ conn = (struct conninfo *)malloc (sizeof (struct conninfo)); if (conn == NULL) { @@ -717,22 +786,23 @@ printf("Dis2 "); conn->cause = 999999; setconnstate(conn, c_down); ReportConn(conn); + conn->next = theconn; + theconn = conn; resp = runprog (cfr, &conn, &cg); - chkone(cg); chkone(conn); + if(resp != NULL) + dropconn(conn); + else + chkone(conn); + chkone(cg); cont: -#if 0 - if (conn != NULL) { - conn->cg->nr = str_enter(nr); - } -#endif - inc_err: if (resp != NULL) { + inc_err: xx.b_wptr = xx.b_rptr = ans; xx.b_datap = &db; db.db_base = ans; db.db_lim = ans + sizeof (ans); -printf("Dis3 "); + if(1)printf("Dis3 "); m_putid (&xx, CMD_OFF); if(connref != 0) { m_putsx (&xx, ARG_CONNREF); @@ -741,23 +811,29 @@ printf("Dis3 "); /* BUSY-if-no-channel is very ugly but unavoidable when sharing the bus with brain-damaged devices (there are - many out there) */ + many out there) which don't answer at all when they're busy. + Grr. The PBX should catch this case. */ + /* We send the BUSY fast if _we_re busy, else we have to send it slow + because somebody else might in fact answer... */ m_putsx (&xx, ARG_CAUSE); - if((bchan < 0) || !strcmp(resp,"0BUSY")) { + if((bchan < 0) || !strncmp(resp+1,"BUSY",4)) { m_putsx2 (&xx, ID_N1_UserBusy); + if(!strcmp(resp+1,"BUSY") || (cg->flags & F_FASTDROP)) + m_putsx(&xx,ARG_FASTDROP); if(conn != NULL && (conn->flags & F_BACKCALL)) { if(conn->want_reconn == 0) conn->want_reconn = MAX_RECONN - (MAX_RECONN >> 1); setconnstate(conn,conn->state); } - } - else if(cg->flags & F_NOREJECT) + } else { + if(cg->flags & F_NOREJECT) m_putsx2 (&xx, ID_N1_NoChans); else m_putsx2 (&xx, ID_N1_CallRejected); if(cg->flags & F_FASTDROP) m_putsx(&xx,ARG_FASTDROP); + } if(crd[0] != '\0') { m_putsx(&xx,ARG_CARD); m_putsz(&xx,crd); @@ -773,7 +849,7 @@ printf("Dis3 "); syslog (LOG_WARNING, "Got '%s' for ???,%s", resp, nr); xlen = xx.b_wptr - xx.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); conn = malloc(sizeof(*conn)); if(conn != NULL) { @@ -782,7 +858,7 @@ printf("Dis3 "); conn->cause = ID_priv_Print; conn->causeInfo = resp; cg->refs++; - /* dropgrab(conn->cg; ** is new anyway */ + /* dropgrab(conn->cg); ** is new anyway */ conn->cg = cg; conn->next = theconn; theconn = conn; @@ -794,6 +870,8 @@ printf("Dis3 "); return 0; } +/* IND_CONN: The B channel is connected, but the protocols may not be + synced yet. */ int do_conn(void) { @@ -816,7 +894,7 @@ do_conn(void) m_putsz (&xx, (uchar_t *) resp); xlen = xx.b_wptr - xx.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); } } #if 0 /* not yet */ @@ -834,11 +912,12 @@ do_conn(void) m_putsx (&xx, PROTO_ONLINE); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); #endif return 0; } +/* PROTO_ENABLE was successful -> mark a connection as DOWN. */ int do_hasenable(void) { @@ -857,6 +936,7 @@ do_hasenable(void) return 0; } +/* PROTO_ENABLE was successful -> mark a connection as OFF. */ int do_hasdisable(void) { @@ -869,21 +949,21 @@ do_hasdisable(void) return 0; } +/* IND_DISC: Connection broken. */ int do_disc(void) { if (conn != NULL) { conn->got_id = 1; + if(conn->cg->nr != NULL) conn->cg->oldnr = conn->cg->nr; + if(conn->cg->lnr != NULL) conn->cg->oldlnr = conn->cg->lnr; if(!conn->want_fast_reconn) conn->cg->nr = NULL; conn->cg->lnr = NULL; -#if 0 - after_ind: -#endif conn->fminor = 0; - if(conn->got_hd) { /* really down */ + if(conn->got_hd) { /* Protocol stack is down also */ switch(conn->state) { case c_offdown: case c_off: @@ -906,14 +986,14 @@ do_disc(void) m_putid (mb, PROTO_DISABLE); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); freemsg(mb); } } break; case c_going_up: - if(conn->charge > 0 || (++conn->retries > cardnum*2 && !(conn->flags & F_FASTREDIAL)) - || (conn->retries > cardnum*10 && (conn->flags & F_FASTREDIAL))) + if(conn->charge > 0 || (++conn->retries > 20 && !(conn->flags & F_FASTREDIAL)) + || (conn->retries > 10 && (conn->flags & F_FASTREDIAL))) goto conn_off; /* else FALL THRU */ case c_up: @@ -935,7 +1015,7 @@ do_disc(void) m_putid (mb, PROTO_DISABLE); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); freemsg(mb); } setconnstate(conn,c_off); @@ -952,28 +1032,28 @@ do_disc(void) m_putid (mb, PROTO_ENABLE); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); freemsg(mb); } } break; default:; } - } else { /* not wholly there yet */ + } else { /* protocol stack isn't yet down */ switch(conn->state) { case c_going_up: if((conn->flags & F_INCOMING) && !(conn->flags & F_PERMANENT)) { xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); -printf("Dis4d "); + if(1)printf("Dis4d "); m_putid (&xx, CMD_CLOSE); m_putsx (&xx, ARG_MINOR); m_puti (&xx, minor); m_putsx (&xx, ARG_NOCONN); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); if(conn->minor == minor) { conn->minor = 0; if(conn->pid == 0) @@ -983,10 +1063,11 @@ printf("Dis4d "); } } - if(conn->charge > 0 || ++conn->retries > 3) - goto conn_off; + if(conn->charge > 0 || ++conn->retries > 5) + goto conn_off; /* Disable, temporarily. */ else - goto hitme; + goto hitme; /* Reenable -- will get another WANT_CONN + if the data are still there. */ break; case c_up: setconnstate(conn,c_going_down); @@ -1016,7 +1097,7 @@ printf("Dis4d "); m_putsx (&xx, ARG_NOCONN); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); if(conn->minor == minor) { conn->minor = 0; if(conn->pid == 0) @@ -1036,14 +1117,14 @@ printf("Dis4d "); xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); -printf("Dis4 "); + if(1)printf("Dis4 "); m_putid (&xx, CMD_OFF); m_putsx (&xx, ARG_MINOR); m_puti (&xx, minor); m_putsx (&xx, ARG_NOCONN); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); } #endif #if 1 @@ -1055,6 +1136,7 @@ printf("Dis4 "); return 0; } +/* IND_CLOSE: a /dev/isdn/isdnXX or /dev/ttyiXX port got closed. */ int do_close(void) { @@ -1093,7 +1175,8 @@ do_close(void) } } unlockdev(minor); - { + + { /* Now update our UTMP record, if we have one. */ struct utmp ut; bzero (&ut, sizeof (ut)); @@ -1119,6 +1202,7 @@ do_close(void) return 0; } +/* IND_OPEN: a /dev/isdn/isdnXX device was openend. */ int do_open(void) { @@ -1132,6 +1216,7 @@ do_open(void) if(conn != NULL) return 0; + /* Configure the thing to be an AT command interpreter. */ xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); @@ -1154,15 +1239,15 @@ do_open(void) m_puti (&xx, 1); m_putsx (&xx, PROTO_BREAK); m_puti (&xx, 1); - printf("On2 %p %d\n",conn,dialin); m_putsx (&xx, ((conn != NULL) || (dialin > 0)) ? PROTO_ONLINE : PROTO_OFFLINE); len = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, len); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &len, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, len, 1); return 0; } +/* A connection has been fully established. */ int do_hasconnected(void) { @@ -1171,9 +1256,7 @@ do_hasconnected(void) conn->flags |= conn->cg->flags & F_MOVEFLAGS; setconnstate(conn,c_up); } -#if 1 resp = "CONNECT"; -#endif if(conn != NULL && conn->cg != NULL) syslog(LOG_INFO,"UP %s:%s",conn->cg->site,conn->cg->protocol); @@ -1193,9 +1276,10 @@ do_hasconnected(void) m_putsz (&xx, (uchar_t *) resp); xlen = xx.b_wptr - xx.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); } + /* Tell the command interpreter to be transparent. */ xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); @@ -1206,14 +1290,14 @@ do_hasconnected(void) m_putid (&xx, PROTO_MODULE); m_putsx (&xx, PROTO_MODULE); m_putsz (&xx, (uchar_t *) "proto"); - printf("On3\n"); m_putsx (&xx, PROTO_ONLINE); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); return 0; } +/* Disconnecting.. */ int do_disconnect(void) { @@ -1229,22 +1313,23 @@ do_disconnect(void) xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); -printf("Dis5 "); + if(1)printf("Dis5 "); m_putid (&xx, CMD_OFF); m_putsx (&xx, ARG_MINOR); m_puti (&xx, minor); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); #endif resp = NULL; return 0; } +/* ... disconnect complete. */ int do_hasdisconnect(void) { - if (minor == fminor) { + if (minor == fminor) { /* Tell the interpreter to revert to command line. */ xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); @@ -1259,14 +1344,14 @@ do_hasdisconnect(void) m_putsx (&xx, ((conn != NULL) || (dialin > 0)) ? PROTO_ONLINE : PROTO_OFFLINE); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); } #if 1 if(minor > 0) { xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); -printf("Dis6 "); + if(1)printf("Dis6 "); m_putid (&xx, CMD_OFF); m_putsx (&xx, ARG_MINOR); m_puti (&xx, minor); @@ -1274,7 +1359,7 @@ printf("Dis6 "); m_putsx (&xx, ARG_NOCONN); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); } #endif if(conn != NULL) { @@ -1315,6 +1400,7 @@ printf("Dis6 "); return 0; } +/* Some interface has data to transmit -> open a connection. */ int do_wantconnect(void) { @@ -1330,7 +1416,7 @@ do_wantconnect(void) m_putid (mb, PROTO_ENABLE); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); freemsg(mb); } } @@ -1338,28 +1424,29 @@ do_wantconnect(void) setconnref(conn,0); try_reconn(conn); } - } else { + } else { /* No way right now. Disable. */ if(minor > 0) { xx.b_rptr = xx.b_wptr = ans; db.db_base = ans; db.db_lim = ans + sizeof (ans); -printf("Dis7 "); + if(1)printf("Dis7 "); m_putid (&xx, CMD_OFF); m_putsx (&xx, ARG_MINOR); m_puti (&xx, minor); m_putsx (&xx, ARG_NOCONN); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); } } return 0; } +/* Somebody typed a command line. */ int do_atcmd(void) { - for (;;) { + for (;;) { /* Find the AT prefix. */ while (xx.b_rptr < xx.b_wptr && *xx.b_rptr != 'a' && *xx.b_rptr != 'A') xx.b_rptr++; if (xx.b_rptr == xx.b_wptr) @@ -1369,15 +1456,14 @@ do_atcmd(void) if (xx.b_rptr < xx.b_wptr && (*xx.b_rptr == 't' || *xx.b_rptr == 'T')) break; } - { + /* AT recognized */ + /* If we're AT/Listening, stop it. */ for(conn = theconn; conn != NULL; conn = conn->next) { if(conn->minor == minor && conn->ignore == 3) { dropconn(conn); break; } } - } - /* AT recognized */ xx.b_rptr++; resp = "OK"; while (1) { @@ -1387,15 +1473,14 @@ do_atcmd(void) m_getskip (&xx); if (xx.b_rptr >= xx.b_wptr) return 1; - printf ("AT %c\n", *xx.b_rptr); switch (*xx.b_rptr++) { - case '/': + case '/': /* AT/ */ m_getskip (&xx); switch (*xx.b_rptr++) { default: return 3; - case 'k': - case 'K': /* Kill running programs. Restart in half a minute. */ + case 'k': /* AT/K#, kill one program; AT/K, kill all programs */ + case 'K': /* Restart in half a minute. */ if(user[fminor] != 0) { resp = "NO PERMISSION"; return 1; @@ -1418,7 +1503,7 @@ do_atcmd(void) return 1; } break; - case 'r': + case 'r': /* AT/R */ case 'R': /* Reload database. */ if(user[fminor] != 0) { resp = "NO PERMISSION"; @@ -1428,16 +1513,17 @@ do_atcmd(void) do_run_now++; run_now(NULL); break; - case 'q': - case 'Q': /* Shutdown. */ + case 'q': /* AT/Q */ + case 'Q': /* Shutdown the ISDN system. */ if(user[fminor] != 0) { resp = "NO PERMISSION"; return 1; } do_quitnow(NULL); break; - case 'b': - case 'B': { /* Reenable a connection. */ + case 'b': /* AT&B# */ + case 'B': /* Reenable a connection. */ + { if(m_geti(&xx,&minor) != 0) { return 3; } @@ -1460,7 +1546,7 @@ do_atcmd(void) m_putid (mb, PROTO_ENABLE); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); freeb(mb); } conn->retries = conn->retiming = 0; @@ -1472,14 +1558,15 @@ do_atcmd(void) } resp = "NOT FOUND"; return 1; - } break; - case 'f': + } + break; + case 'f': /* AT/F# */ case 'F': /* freeze the connection, i.e. state = OFF */ dodrop = 1; /* FALL THRU */ - case 'x': - case 'X': - { /* Drop a connection. */ + case 'x': /* AT#X# */ + case 'X': /* Drop a connection, i.e. state = DOWN */ + { if(user[fminor] != 0) { resp = "NO PERMISSION"; return 1; @@ -1502,7 +1589,7 @@ do_atcmd(void) setconnstate(conn, c_forceoff); else setconnstate(conn, c_down); -printf("Dis8 "); + if(1)printf("Dis8 "); if(mb != NULL) { { @@ -1511,7 +1598,7 @@ printf("Dis8 "); m_puti (mb, minor); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); if(dodrop) { m_putid (mb, CMD_PROT); @@ -1521,7 +1608,7 @@ printf("Dis8 "); m_putid (mb, PROTO_DISABLE); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); mb->b_wptr=mb->b_rptr; } @@ -1538,9 +1625,9 @@ printf("Dis8 "); } } break; - case 'l': - case 'L': - { /* List connections. */ + case 'l': /* AT/L */ + case 'L': /* List connections and state changes. */ + { struct conninfo *fconn; char *sp; msgbuf = malloc(10240); @@ -1572,15 +1659,16 @@ printf("Dis8 "); conn->next = theconn; theconn = conn; } - sprintf(sp,"OK"); + /* sprintf(sp,"OK"); */ + *--sp = '\0'; *--sp = '\0'; /* Take off the CRLF at the end; the driver will put it back */ return 1; } break; - case 'i': - case 'I': - { /* List state. */ + case 'i': /* AT/I */ + case 'I': /* List of active cards, and Level 3 state. */ + { char *sp; #if LEVEL < 4 extern int l3print(char *); @@ -1592,10 +1680,9 @@ printf("Dis8 "); } sp = resp = msgbuf; { - int cd; - for(cd=0;cdnext) + sp += sprintf(sp,"%s(%d) ",card->name,card->nrbchan); *sp++ = '\r'; *sp++ = '\n'; } #if LEVEL < 4 @@ -1608,15 +1695,15 @@ printf("Dis8 "); } break; - case 'm': - case 'M': + case 'm': /* AT/M foo */ + case 'M': /* send "foo" to L3. */ { m_getskip (&xx); if (xx.b_rptr == xx.b_wptr) return 3; xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, xx.b_wptr, &xlen, 1); + (void) strwrite (xs_mon, xx.b_wptr, xlen, 1); return 0; } break; @@ -1645,15 +1732,15 @@ printf("Dis8 "); } xlen = yy.b_wptr - yy.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); resp = NULL; } break; #endif } break; - case 'o': - case 'O': + case 'o': /* ATO */ + case 'O': /* go online again */ { mblk_t yy; @@ -1676,7 +1763,7 @@ printf("Dis8 "); m_putsz (&yy, (uchar_t *) resp); xlen = yy.b_wptr - yy.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); yy.b_rptr = yy.b_wptr = ans; db.db_base = ans; @@ -1692,12 +1779,12 @@ printf("Dis8 "); m_putsx (&yy, PROTO_ONLINE); xlen = yy.b_wptr - yy.b_rptr; DUMPW (yy.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, xlen, 1); resp = NULL; } return 0; - case 'H': - case 'h': + case 'H': /* ATH */ + case 'h': /* hang up. */ { mblk_t yy; struct datab dbb; @@ -1706,18 +1793,18 @@ printf("Dis8 "); yy.b_rptr = yy.b_wptr = ans; dbb.db_base = ans; dbb.db_lim = ans + sizeof (ans); -printf("Dis9 "); + if(1)printf("Dis9 "); m_putid (&yy, CMD_OFF); m_putsx (&yy, ARG_MINOR); m_puti (&yy, minor); xlen = yy.b_wptr - yy.b_rptr; DUMPW (yy.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, xlen, 1); resp = NULL; } break; - case 'D': - case 'd': + case 'D': /* ATD###, ATD/site, .../protocol, .../card */ + case 'd': /* Dial out. */ { /* cf cfr; */ streamchar *m1, *m2, *m3; @@ -1751,7 +1838,7 @@ printf("Dis9 "); m_puti (md, fminor); xlen=md->b_wptr-md->b_rptr; DUMPW (md->b_rptr, xlen); - (void) strwrite (xs_mon, md->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, md->b_rptr, xlen, 1); md->b_wptr=md->b_rptr; } @@ -1851,8 +1938,8 @@ printf("Dis9 "); return 1; } break; - case 'A': - case 'a': + case 'A': /* ATA */ + case 'a': /* Sorry, no answer yet. */ return 3; default: return 3; @@ -1861,12 +1948,14 @@ printf("Dis9 "); return 0; } +/* IND_INFO -- informational message received */ int do_getinfo(void) { if(conn != NULL && conn-charge != 0 && (conn->charge % 10) == 0) syslog(LOG_INFO,"Cost %s:%s %ld",conn->cg->site,conn->cg->protocol,conn->charge); - { + if((charge > 0) && (conn->state >= c_going_up)) { + /* Send a TICK messge to the protocol stack to sync timers. */ mblk_t *mb = allocb(30,BPRI_MED); if(mb != NULL) { @@ -1877,7 +1966,7 @@ do_getinfo(void) m_putid (mb, PROTO_TICK); xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); freemsg(mb); } setconnstate(conn,conn->state); @@ -1885,12 +1974,27 @@ do_getinfo(void) return 0; } +/* IND_ERROR. An error has occurred. Oh no... */ int do_error(void) { printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrval)); - if(hdrval == HDR_CLOSE) /* Ignore? */ + if(hdrval == HDR_CLOSE) /* Ignore if uncloseable */ return 0; + if(hdrval == HDR_LOAD) { + if(loader != NULL) { + if ((foffset >= 0) && (errnum == -EAGAIN) && (seqnum == loader->nrfile)) { + loader->foffset = foffset; + if(loader->timer) + untimeout(card_load,loader); + loader->timer = 1; + timeout(card_load,loader,HZ*5); + return 0; + } + card_load_fail(loader,errnum); + } + return 0; + } if(conn == NULL && connref != 0) { for(conn = theconn; conn != NULL; conn = conn->next) { if(conn->connref == connref) @@ -1936,6 +2040,7 @@ printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrv db.db_lim = ans + sizeof (ans); *xx.b_wptr++ = PREF_NOERR; + if(1)printf("DisA "); m_putid (&xx, CMD_OFF); m_putsx(&xx,ARG_FORCE); if(minor > 0) { @@ -1953,7 +2058,7 @@ printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrv xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); } if((minor ? minor : fminor) != 0) { @@ -1968,7 +2073,7 @@ printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrv m_puti (&xx, (minor ? minor : fminor)); xlen = xx.b_wptr - xx.b_rptr; DUMPW (xx.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) xx.b_rptr, xlen, 1); if(conn != NULL && conn->minor == (minor ? minor : fminor)) { conn->minor = 0; if(conn->pid == 0) @@ -1983,6 +2088,27 @@ printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrv return 3; } + +/* No error. Wow... */ +int +do_noerror(void) +{ + if(hdrval == HDR_CLOSE) /* Ignore if uncloseable */ + return 0; + if((hdrval == HDR_LOAD) && (loader != NULL)) { + if(thelength == 0) { /* End of file. Do now if there's no timeout set. */ + if(!loader->timer) + card_load(loader); + } else { /* Continue file. Kick now. */ + if(loader->timer) + untimeout(card_load,loader); + card_load(loader); + } + } + return 0; +} + +/* Main code of do_info() follows. Finally... */ int ret; if(init_vars()) @@ -2015,6 +2141,8 @@ printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrv case PROTO_HAS_ENABLE: ret = do_hasenable(); break; case PROTO_HAS_DISABLE: ret = do_hasdisable(); break; case ID_N1_INFO: ret = do_getinfo(); break; + case ID_ET_FAC: ret = do_getinfo(); break; + /* for now */ case ID_N1_REL: case IND_DISC: ret = do_disc(); break; case IND_CLOSE: ret = do_close(); break; @@ -2025,18 +2153,19 @@ printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrv case PROTO_WANT_CONNECTED: ret = do_wantconnect(); break; case PROTO_AT: ret = do_atcmd(); break; case IND_ERR: ret = do_error(); break; + case IND_NOERR: ret = do_noerror(); break; - case IND_INFO: + case IND_INFO: /* Skip the INFO thing and parse what's beneach. */ if (m_getid (&xx, &ind) != 0) goto err; goto redo; - case ID_N1_FAC_ACK: + case ID_N1_FAC_ACK: /* Something or other... */ resp = "OK"; goto print; case ID_N1_FAC_REJ: resp = "ERROR"; goto print; - case ID_N1_ALERT: + case ID_N1_ALERT: /* Hey, there is somebody at the other end! */ resp = "RRING"; goto print; #if 0 @@ -2077,7 +2206,7 @@ printf("GotAnError: Minor %ld, connref %ld, hdr %s\n",minor,connref,HdrName(hdrv m_putsz (&xx, (uchar_t *) resp); xlen = xx.b_wptr - xx.b_rptr; DUMPW (ans, xlen); - (void) strwrite (xs_mon, ans, &xlen, 1); + (void) strwrite (xs_mon, ans, xlen, 1); } if(msgbuf != NULL && resp == msgbuf) free(msgbuf); diff --git a/isdn_4/libs.sh b/isdn_4/libs.sh deleted file mode 100644 index 199704c..0000000 --- a/isdn_4/libs.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -if [ "$1" = "2" ] ; then - echo ../isdn_3.a ../isdn_2.a ../support.a -elif [ "$1" = "3" ] ; then - echo ../isdn_3.a ../support.a -else - echo ../support.a -fi - diff --git a/isdn_4/loader.c b/isdn_4/loader.c index 217af97..ff8d31d 100644 --- a/isdn_4/loader.c +++ b/isdn_4/loader.c @@ -7,7 +7,7 @@ #include "master.h" -#if 0 +#if 0 /* master.h */ struct loader { char *card; FILE *file; @@ -18,15 +18,62 @@ struct loader { /* cf_LF: num2: sequence number; num: block size */ #endif -void card_load(struct loader *ld) +static void +card_load_close(struct loader *ld) +{ + if(ld->name != NULL) + ld->card->name = ld->name; + if(ld->file != NULL) + fclose(ld->file); + if(ld->timer) + untimeout(card_load,ld); + { + struct loader **ldp = &isdn4_loader; + while(*ldp != NULL) { + if(*ldp == ld) { + *ldp = ld->next; + break; + } + ldp = &(*ldp)->next; + } + } + free(ld); +} + +void +card_load_fail(struct loader *ld, int err) +{ + mblk_t *mj = allocb (32, BPRI_LO); + int len; + + syslog(LOG_ERR,"Card %s was not loaded: Error at file %d, pos %d\n",ld->card,ld->nrfile,ld->foffset); + + /* Tell lower layer to forget the thing */ + + if (mj != NULL) { + m_putid (mj, CMD_NOCARD); + m_putsx (mj, ARG_CARD); + m_putsz (mj, ld->name); + len = mj->b_wptr - mj->b_rptr; + DUMPW (mj->b_rptr, len); + (void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, len, 1); + freeb (mj); + } + + card_load_close(ld); +} + +void +card_load(struct loader *ld) { cf dl,lf; int do_again; + ld->timer = 0; again: do_again = 0; - for(lf = cf_LF; lf != NULL; lf++) { - if(!wildmatch(ld->card,lf->card)) + for(lf = cf_LF; lf != NULL; lf = lf->next) { + if(!wildmatch(ld->name,lf->card)) continue; if(ld->seqnum != 0 && ld->seqnum != lf->num2) { if(ld->seqnum < lf->num2 && (do_again == 0 || do_again > lf->num2)) @@ -37,7 +84,7 @@ void card_load(struct loader *ld) } if(lf == NULL) { if(ld->seqnum == 0) { - syslog(LOG_ERR, "Card loader for %s dropped us (seq %d)!\n",ld->card,ld->seqnum); + syslog(LOG_ERR, "Card loader for %s has a config problem (seq %d)!\n",ld->card,ld->seqnum); goto ex_load; } if(do_again) { @@ -52,7 +99,7 @@ void card_load(struct loader *ld) mblk_t xx; struct datab db; struct iovec io[3]; - streamchar ans[30]; + streamchar ans[50]; if(ld->file != NULL) { buf = malloc(lf->num); @@ -61,9 +108,8 @@ void card_load(struct loader *ld) goto ex_load; } - foffset = ftell(ld->file); - if(foffset < 0) { - syslog(LOG_ERR, "Card loader for %s: ftell returned %m\n",ld->card); + if(fseek(ld->file,ld->foffset,0) < 0) { + syslog(LOG_ERR, "Card loader for %s: fseek returned %m\n",ld->card); goto ex_load; } len = fread(buf,1,lf->num,ld->file); @@ -72,18 +118,24 @@ void card_load(struct loader *ld) free(buf); goto ex_load; } + foffset = ld->foffset; + ld->foffset += len; } else { len = 0; foffset = 0; + ld->foffset = 0; } + if(!do_again && (ld->file == NULL)) + ++ld->nrfile; /* last file; we're finished */ xx.b_rptr = xx.b_wptr = ans; + xx.b_datap = &db; db.db_base = ans; db.db_lim = ans + sizeof (ans); m_putid (&xx, CMD_LOADFILE); m_putsx(&xx,ARG_CARD); - m_putsz(&xx,ld->card); + m_putsz(&xx,ld->name); m_putsx(&xx,ARG_SEQNUM); - m_puti(&xx,ld->seqnum); + m_puti(&xx,ld->nrfile); m_putsx(&xx,ARG_OFFSET); m_puti(&xx,foffset); @@ -92,8 +144,8 @@ void card_load(struct loader *ld) DUMPW (ans, xlen); io[0].iov_base = ans; io[0].iov_len = xlen; - io[1].iov_base = ":: "; - io[1].iov_len = 3; + io[1].iov_base = "::"; + io[1].iov_len = 2; if(len > 0) { io[2].iov_base = buf; io[2].iov_len = len; @@ -103,23 +155,27 @@ void card_load(struct loader *ld) if(ld->file != NULL) { fclose(ld->file); ld->file = NULL; + ld->seqnum++; } } (void) strwritev (xs_mon, io,len, 1); free(buf); if(do_again) { - timeout(card_load,ld,HZ/5); + ld->timer = 1; + timeout(card_load,ld,ld->file ? HZ : HZ*(ld->nrfile+2)); return; } } else { ld->seqnum = lf->num2; ld->nrfile++; ld->file = fopen(lf->arg,"r"); + ld->foffset = 0; if(ld->file == NULL) { syslog(LOG_ERR, "Card loader for %s: file %s: %m\n",ld->card,lf->arg); goto ex_load; } - timeout(card_load,ld,HZ); + ld->timer = 1; + timeout(card_load,ld,HZ*2); return; } @@ -130,14 +186,15 @@ void card_load(struct loader *ld) struct datab db; streamchar ans[30]; - if(!wildmatch(dl->card,ld->card)) + if(!wildmatch(dl->card,ld->name)) continue; xx.b_rptr = xx.b_wptr = ans; + xx.b_datap = &db; db.db_base = ans; db.db_lim = ans + sizeof (ans); m_putid (&xx, CMD_DOCARD); m_putsx(&xx,ARG_CARD); - m_putsz(&xx,ld->card); + m_putsz(&xx,ld->name); *xx.b_wptr++ = ' '; len = xx.b_wptr - xx.b_rptr; @@ -147,8 +204,8 @@ void card_load(struct loader *ld) len = 1; if(dl->args != NULL) { printf ("+ "); - io[len].iov_base = ":: "; - io[len].iov_len = 3; + io[len].iov_base = "::"; + io[len].iov_len = 2; len++; io[len].iov_base = dl->args; io[len].iov_len = strlen(dl->args); @@ -156,12 +213,14 @@ void card_load(struct loader *ld) len++; } (void) strwritev (xs_mon, io,len, 1); - break; + card_load_close(ld); + + do_run_now++; + timeout(run_now,NULL,HZ/3); + return; } ex_load: - if(ld->file != NULL) - fclose(ld->file); - free(ld); + card_load_fail(ld,-EIO); return; } diff --git a/isdn_4/master.c b/isdn_4/master.c index ce2ade5..442c0c7 100644 --- a/isdn_4/master.c +++ b/isdn_4/master.c @@ -16,20 +16,20 @@ main (int argc, char *argv[]) extern int optind; char *devnam = "/dev/isdnmon"; - char *execf = NULL; int pushlog = 0; int debug = 0; int x; #ifdef linux reboot(0xfee1dead,0x17392634,1); /* Magic to make me nonswappable */ + /* TODO: 1.3.xx kernel / libc: use appropriate system call */ #endif #ifdef DO_DEBUG_MALLOC mcheck(NULL); mmtrace(); #endif chkall(); - setlinebuf(stdout); setlinebuf(stderr); + setlinebuf(stdout); setlinebuf(stderr); /* no(t much) buffering */ progname = strrchr (*argv, '/'); /* basename */ if (progname == NULL) @@ -37,8 +37,12 @@ main (int argc, char *argv[]) else progname++; - while ((x = getopt (argc, argv, "iItf:x:dlLwWqQ"))!= EOF) { + while ((x = getopt (argc, argv, "iIf:dlLwWqQ"))!= EOF) { switch (x) { + /* + * Logging. Small letters are usermode, capitals log in the kernel. + * 'l' is raw data, 'w' is interpreted data, 'q' is queue info. + */ case 'l': pushlog |= 1; break; @@ -57,43 +61,37 @@ main (int argc, char *argv[]) case 'Q': pushlog |= 32; break; - case 'd': + + case 'd': /* do not fork */ debug = 1; break; - case 't': - testonly = 1; - break; - case 'x': - if (execf != NULL) - goto usage; - execf = optarg; - break; - case 'I': + case 'I': /* for testing */ igstdin = 0; break; case 'i': igstdin = 1; break; - case 'f': + case 'f': /* alternate device to open */ if (getuid ()!= 0) goto usage; devnam = optarg; break; default: usage: - fprintf (stderr, "Usage: %s -t[est] -x Data -l[ogging] -F epromfile -f devfile\n" - "\t-M load+direct+Leo -m direct+Leo \n", progname); + fprintf (stderr, "Usage: %s -WQLwql[ogging] [ -f device ] \n" + "\t-d[ebug]", progname); exit (1); } } openlog (progname, debug ? LOG_PERROR : 0, LOG_LOCAL7); + /* Remember all files to scan */ fileargs = &argv[optind]; - read_args (NULL); + read_args (NULL); /* This also schedules starting all configured programs */ seteuid (getuid ()); - if (!debug) { + if (!debug) { /* Disassociate */ switch (fork ()){ case -1: xquit ("fork", NULL); @@ -118,7 +116,6 @@ main (int argc, char *argv[]) for (i=getdtablesize()-1;i>=0;i--) (void) close(i); } - igstdin=1; open("/dev/null",O_RDWR); dup(0); dup(0); #ifdef HAVE_SETPGRP_2 @@ -130,7 +127,7 @@ main (int argc, char *argv[]) } #ifdef linux - { + { /* (Re)Create all our device files */ FILE * fd; if((fd = fopen("/proc/devices","r")) == NULL) syslog(LOG_ERR,"Reading device numbers: %m"); @@ -184,60 +181,43 @@ main (int argc, char *argv[]) } #endif + /* Standard signal handling -- TODO: Use sigaction() instead. */ signal (SIGALRM, (sigfunc__t) alarmsig); signal (SIGPIPE, SIG_IGN); if(signal(SIGHUP,SIG_IGN) != SIG_IGN) signal (SIGHUP, SIG_DFL); if(signal(SIGINT,SIG_IGN) != SIG_IGN) - signal (SIGINT, do_quitnow); + signal (SIGINT, (void *)do_quitnow); /* Always these "incompatible" pointers... */ signal (SIGQUIT, (sigfunc__t) do_quitnow); signal (SIGUSR1, (sigfunc__t) kill_progs); signal (SIGCHLD, (sigfunc__t) deadkid); - chkall(); + /* Create a stream within the program */ xs_mon = stropen (0); if (xs_mon == NULL) xquit ("xs_mon = NULL", ""); - if (!testonly) { + /* Open the device and push kernel stream modules */ fd_mon = open (devnam, O_RDWR); if (fd_mon < 0) xquit ("Open Dev", devnam); - if (ioctl (fd_mon, I_SRDOPT, RMSGN) < 0) - if (errno != ENOTTY) + if (ioctl (fd_mon, I_SRDOPT, RMSGN) < 0) /* Message mode */ xquit ("SetStrOpt", ""); if (pushlog & 2) if (ioctl (fd_mon, I_PUSH, "strlog") < 0) - if (errno != ENOTTY) xquit ("Push", "strlog 1"); if (pushlog & 8) if (ioctl (fd_mon, I_PUSH, "logh") < 0) - if (errno != ENOTTY) xquit ("Push", "strlog 1"); if (pushlog & 32) if (ioctl (fd_mon, I_PUSH, "qinfo") < 0) - if (errno != ENOTTY) xquit ("Push", "strlog 1"); -#if LEVEL < 4 - if (xnkernel) { - if (ioctl (fd_mon, I_PUSH, "isdn_3") < 0) { - syslog (LOG_ERR, "No kernel ISDN module: %m"); - xnkernel = 0; - } else { - if (pushlog & 1) - if (ioctl (fd_mon, I_PUSH, "strlog") < 0) - xquit ("Push", "strlog 1"); - if (pushlog & 4) - if (ioctl (fd_mon, I_PUSH, "logh") < 0) - xquit ("Push", "strlog 1"); - if (pushlog & 16) - if (ioctl (fd_mon, I_PUSH, "qinfo") < 0) - xquit ("Push", "strlog 1"); - } - } +#if LEVEL > 3 + if (ioctl (fd_mon, I_PUSH, "isdn_3") < 0) + xquit ("ISDN_3 module"); #endif - } { + { /* Associate the kernel stream with the user stream */ typedef int (*F) (); extern void isdn3_init (void); extern void isdn_init (void); @@ -264,31 +244,25 @@ main (int argc, char *argv[]) #endif register_strmod (&strloginfo); register_strmod (&loghinfo); + #if LEVEL < 4 - if (!xnkernel || testonly) { + /* push user-mode streams modules */ if (pushlog & 1) - strioctl (xs_mon, I_PUSH, (long) "log"); + strioctl (xs_mon, I_PUSH, (long) "strlog"); if (pushlog & 4) strioctl (xs_mon, I_PUSH, (long) "logh"); if (pushlog & 16) strioctl (xs_mon, I_PUSH, (long) "qinfo"); strioctl (xs_mon, I_PUSH, (long) "isdn_3"); - } #endif } - if(0)callout_async (); - timeout (log_idle, NULL, 5 * HZ); - timeout (queue_idle, NULL, HZ); - if (execf != NULL) { - FILE *efile = fopen (execf, "r"); - - if (efile == NULL) - xquit ("Exec File", execf); - } - syspoll (); + if(0)callout_async (); /* We prefer to do everything synchronously */ + timeout (log_idle, NULL, 5 * HZ); /* Tell everybody that we're still alive */ + timeout (queue_idle, NULL, HZ/3); /* process the user-mode streams */ + syspoll (); /* Now go and do some work */ + /* Shut down. Ungracefully. Graceful shutdown of active cards TODO. */ strclose (xs_mon, 0); - exit (0); - return 0; + return 0; /* -> exit(0) */ } diff --git a/isdn_4/master.h b/isdn_4/master.h index 039256c..193b55c 100644 --- a/isdn_4/master.h +++ b/isdn_4/master.h @@ -167,11 +167,8 @@ EXTERN int isdnterm INIT(0); /* major number of the terminal driver */ EXTERN int isdnstd INIT(0); /* major number of the standard driver */ #endif -EXTERN char *cardlist[NCARDS]; /* List of available ISDN interfaces */ -EXTERN short cardnrbchan[NCARDS]; /* Nr of B channels */ -EXTERN short cardnum INIT(0); /* Number of registered interfaces */ EXTERN short cardidx INIT(0); /* Used to cycle among interfaces */ -EXTERN short numidx INIT(0); /* Ditto */ +EXTERN short numidx INIT(0); /* Used to cycle among numbers */ EXTERN void *locputchar INIT(NULL); /* Glue */ @@ -201,6 +198,7 @@ EXTERN struct string { char *str_enter(char *master); char *wildmatch(char *a, char *b); char *classmatch(char *a, char *b); +char *strippat(char *a); /* List of cards */ @@ -296,7 +294,7 @@ typedef struct conninfo { unsigned got_hd:2; /* disconnect... */ unsigned got_id:2; unsigned char locked; - unsigned ignore:3; + unsigned ignore:3; /* 0: normal; 1: did drop it; 2: kill it; 3: reporter */ } *conninfo; /* Special flags. */ @@ -308,7 +306,7 @@ typedef struct conninfo { #define F_FASTREDIAL 040 /* don't delay as much when a dialup attempt fails */ #define F_PERMANENT 0100 /* connection doesn't really die */ #define F_LEASED 0200 /* leased line */ -#define F_IGNOREBUSY 0400 +#define F_CHANBUSY 0400 /* busy if no free channel */ #define F_NRCOMPLETE 01000 /* remote number is complete */ #define F_LNRCOMPLETE 02000 /* local number is complete */ #define F_INCOMING 04000 /* incoming call */ @@ -442,15 +440,6 @@ void chkone(void *foo); void chkall(void); #endif /* DO_DEBUG_MALLOC */ -struct _cf * read_line (FILE * ffile, int *theLine); -void app (cf * where, cf who); - -int skipsp (char **li); - -#ifdef unused -static void skipword (char **li); -#endif - void read_file (FILE * ffile, char *errf); EXTERN char **fileargs; @@ -460,11 +449,9 @@ void read_args_run(void *nix); const char *CauseInfo(int cause, char *pri); -void Xdropconn (struct conninfo *conn, int deb_line); -#define dropconn(x) Xdropconn((x),__LINE__) - +void Xdropconn (struct conninfo *conn, const char *deb_file, unsigned int deb_line); +#define dropconn(x) Xdropconn((x),__FILE__,__LINE__) void rdropconn (struct conninfo *conn, int deb_line); -void Xdropconn (struct conninfo *conn, int deb_line); void deadkid (void); int matchflag(long flags, char *ts); @@ -517,11 +504,26 @@ void kill_progs(struct conninfo *xconn); struct loader { - char *card; + char *name; + struct isdncard *card; FILE *file; long seqnum; /* position in config file(s) */ int nrfile; /* loaded to card */ + long foffset; /* position in load file */ + struct loader *next; + int cardnum; + unsigned timer:1; }; void card_load(struct loader *ld); +void card_load_fail(struct loader *ld, int err); /* error */ +EXTERN struct loader *isdn4_loader INIT(NULL); + +struct isdncard { + struct isdncard *next; + char *name; + long cap; + ushort_t nrbchan; +}; +EXTERN struct isdncard *isdn4_card INIT(NULL); #endif diff --git a/isdn_4/match.c b/isdn_4/match.c index 6ea20b5..10b9726 100644 --- a/isdn_4/match.c +++ b/isdn_4/match.c @@ -6,9 +6,10 @@ */ #include "master.h" +#include "isdn_12.h" /* CHM_INTELLIGENT */ - +/* Verify that the connection mode matches the stated flags. */ int matchflag(long flags, char *ts) { @@ -36,7 +37,7 @@ matchflag(long flags, char *ts) return 0; } - +/* Check if this P-line matches a connection request */ char * pmatch1 (cf prot, conngrab *cgm) { @@ -45,16 +46,19 @@ pmatch1 (cf prot, conngrab *cgm) conngrab cg = *cgm; chkone(prot); chkone(cg); + /* Basic preprocessing */ sit = wildmatch(cg->site, prot->site); if(sit == NULL) return "7ERR Match SITE"; pro = wildmatch(cg->protocol,prot->protocol);if(pro == NULL) return "6ERR Match PROTOCOL"; car = wildmatch(cg->card, prot->card); if(car == NULL) return "6ERR Match CARD"; cla =classmatch(cg->cclass, prot->cclass); if(cla == NULL) return "6ERR Match CLASS"; + /* OK, that fits. Make a copy to assign the values to. */ cg = newgrab(cg); if(cg == NULL) return "0OUT OF MEMORY"; cg->site = sit; cg->protocol = pro; cg->card = car; cg->cclass = cla; + /* Now scan this line's, and all matching followup lines', flags. */ for (first = 1; prot != NULL; prot = prot->next, first = 0) { #define ARG_IN 01 #define ARG_OUT 02 @@ -66,12 +70,12 @@ pmatch1 (cf prot, conngrab *cgm) if(!matchflag(cg->flags,prot->type)) { if(first) { dropgrab(cg); return "5ERR BadFlag"; } else continue;} if (first) { - if (strchr (prot->type, 'M')) { + if (strchr (prot->type, 'M')) { /* First Match not allowed. */ dropgrab(cg); return "7ERR FIND NotFirst"; } } else { - if (strchr (prot->type, 'R')) + if (strchr (prot->type, 'R')) /* First Match only. */ goto Ex; sit = wildmatch(cg->site, prot->site); if(sit==NULL) continue; @@ -79,6 +83,8 @@ pmatch1 (cf prot, conngrab *cgm) car = wildmatch(cg->card, prot->card); if(car==NULL) continue; cla =classmatch(cg->cclass, prot->cclass); if(cla==NULL) continue; } + /* Now make another copy for the parameters. If they don't fit + we'll have to undo everything. */ cgc = newgrab(cg); if(cgc == NULL) { dropgrab(cg); @@ -87,7 +93,7 @@ pmatch1 (cf prot, conngrab *cgm) if(!first) { cgc->site = sit; cgc->protocol = pro; cgc->card = car; cgc->cclass = cla; } - if(cgc->par_out == NULL) { + if(cgc->par_out == NULL) { /* No outgoing parameter list? Yet! */ if ((cgc->par_out = allocb(256,BPRI_LO)) == NULL) { dropgrab(cgc); dropgrab(cg); return "0OUT of MEMORY"; @@ -95,14 +101,17 @@ pmatch1 (cf prot, conngrab *cgm) } #define DG(str) { if(first) { Xbreak(); dropgrab(cgc); dropgrab(cg); return str; } goto Ex; } + /* Remember pointers into the parameter strings. */ mbs_in = ((cgc->par_in !=NULL)? cgc->par_in->b_rptr : NULL); mbs_out= ((cgc->par_out!=NULL)? cgc->par_out->b_rptr: NULL); + /* Allocate a new candidate string for outgoing parameters. */ cand = allocsb (strlen (prot->args), (streamchar *)prot->args); if(cand == NULL) goto Ex; while (m_getsx (cand, &id) == 0) { + /* Check that an incoming parameter matches. */ #define CHKI(_what,_t) \ ({ __label__ ex; long xx,yy; ushort_t id2; \ yy = 0; \ @@ -116,11 +125,13 @@ pmatch1 (cf prot, conngrab *cgm) if(0)if(!strchr(prot->type,'F') && !first) break;\ cgc->par_in->b_rptr = mbs_in; \ freeb(cand); \ - if(1)printf("MatchI %x: %lx vs %lx\n",id,xx,yy); \ + if(0)printf("MatchI %x: %lx vs %lx\n",id,xx,yy); \ dropgrab(cgc); dropgrab(cg); return "3ERR FIND Match Arg"; \ } \ } \ ex:; }) /**/ + + /* Dto., outgoing parameter; if it's not there yet and we need it, add it. */ #define CHKO(_what,_t) \ ({ __label__ ex; long xx,yy; ushort_t id2; \ yy = 0; \ @@ -134,7 +145,7 @@ pmatch1 (cf prot, conngrab *cgm) if(0)if(!strchr(prot->type,'F') && !first) break;\ cgc->par_out->b_rptr = mbs_out; \ freeb(cand); \ - if(1)printf("MatchO %x: %lx vs %lx\n",id,xx,yy); \ + if(0)printf("MatchO %x: %lx vs %lx\n",id,xx,yy); \ dropgrab(cgc); dropgrab(cg); return "3ERR FIND Match Arg"; \ } \ if(!(cgc->flags & F_OUTCOMPLETE)) { \ @@ -143,10 +154,14 @@ pmatch1 (cf prot, conngrab *cgm) } \ } \ ex:; }) /**/ + + /* Put it all together. */ #define CHK(_what,_t) { \ if((nrt & ARG_OUT)&& (cgc->par_out!= NULL)) CHKO(_what,_t); \ if((nrt & ARG_IN) && (cgc->par_in != NULL)) CHKI(_what,_t); } break + /* Same as above, but for vectorized parameters with optional bitmasks. */ + /* You are not supposed to understand this code. */ #define CHKVI() \ ({ __label__ ex; int xx,yy,xm; streamchar *vx,*vy,*vm; ushort_t id2; \ yy = m_gethexlen(cand); \ @@ -171,7 +186,7 @@ pmatch1 (cf prot, conngrab *cgm) if(0)if(!strchr(prot->type,'F') && !first) continue; \ cgc->par_in->b_rptr = mbs_in; \ freeb(cand); \ - if(1)printf("MatchVI %x: %s vs %s\n",id,vx,vy); \ + if(0)printf("MatchVI %x: %s vs %s\n",id,vx,vy); \ free(vx); free(vy); if(xm>0)free(vm); \ dropgrab(cgc); dropgrab(cg); return "3ERR FIND Match Arg"; \ } \ @@ -201,7 +216,7 @@ pmatch1 (cf prot, conngrab *cgm) { free(vx); free(vy); if(xm>0)free(vm); goto ex; } \ if(0)if(!strchr(prot->type,'F') && !first) continue; \ cgc->par_out->b_rptr = mbs_out; \ - if(1)printf("MatchVO %x: %s vs %s\n",id,vx,vy); \ + if(0)printf("MatchVO %x: %s vs %s\n",id,vx,vy); \ freeb(cand); \ free(vx); free(vy); if(xm>0)free(vm); \ dropgrab(cgc); dropgrab(cg); return "3ERR FIND Match Arg"; \ @@ -217,6 +232,8 @@ pmatch1 (cf prot, conngrab *cgm) #define CHKV() { \ if((nrt & ARG_OUT)&& (cgc->par_out!= NULL)) CHKVO(); \ if((nrt & ARG_IN) && (cgc->par_in != NULL)) CHKVI(); } break + + /* Simple one-shot labels that can't be undone (and don't need to be). */ #define CHKX() \ ({ __label__ ex; ushort_t id2; \ if(cgc->par_out != NULL) { \ @@ -230,25 +247,32 @@ pmatch1 (cf prot, conngrab *cgm) ex:; }); break /**/ switch (id) { + /* Direction-specific arguments. */ case ARG_INNUMS : nrt=ARG_IN; break; case ARG_OUTNUMS : nrt=ARG_OUT; break; case ARG_BOTHNUMS: nrt=ARG_IN|ARG_OUT; break; + + /* Flags, ob lokale / entfernte Nummern präsent sein sollen + oder nicht. Logischerweise nur bei ankommenden Anrufen + interessant. */ case ARG_NEEDNOLOCAL: - if(cg->lnr != NULL) + if((cg->flags & F_INCOMING) && (cg->lnr != NULL)) DG("3LocalNrGiven"); break; case ARG_NEEDNOREMOTE: - if(cg->nr != NULL) + if((cg->flags & F_INCOMING) && (cg->nr != NULL)) DG("3RemoteNrGiven"); break; case ARG_NEEDLOCAL: - if(cg->lnr == NULL) + if((cg->flags & F_INCOMING) && (cg->lnr == NULL)) DG("3LocalNrRequired"); break; case ARG_NEEDREMOTE: - if(cg->nr == NULL) + if((cg->flags & F_INCOMING) && (cg->nr == NULL)) DG("3RemoteNrRequired"); break; + + /* Suffix fuer entfernte Nummer. */ case ARG_NUMBER: { char yy[MAXNR + 2]; @@ -272,6 +296,8 @@ pmatch1 (cf prot, conngrab *cgm) } } break; + + /* Suffix fuer lokale Nummer. */ case ARG_LNUMBER: { char yy[MAXNR + 2]; @@ -295,6 +321,8 @@ pmatch1 (cf prot, conngrab *cgm) } } break; + + /* Protokollkrempel... */ case ARG_LLC: CHKV (); case ARG_ULC: @@ -309,6 +337,9 @@ pmatch1 (cf prot, conngrab *cgm) CHK (i, long); case ARG_CHANNEL: CHK (i, long); + + /* Flags... */ + case ARG_CHANBUSY: cgc->flags |= F_CHANBUSY; goto argdup; case ARG_FASTREDIAL: cgc->flags |= F_FASTREDIAL; goto argdup; case ARG_FASTDROP: cgc->flags |= F_FASTDROP; break; case ARG_IGNORELIMIT:cgc->flags |= F_IGNORELIMIT;goto argdup; @@ -322,28 +353,33 @@ pmatch1 (cf prot, conngrab *cgm) argdup: CHKX(); } + /* Reset der Stringpointer. */ if(cgc->par_in != NULL) cgc->par_in->b_rptr = mbs_in; if(cgc->par_out!= NULL) cgc->par_out->b_rptr= mbs_out; } + /* At this point, everything fit (so far). Kill the intermediate copy. */ dropgrab(cg); cg = cgc; cgc = NULL; Ex: if(cand != NULL) freeb (cand); - if (strchr(prot->type,'X')) + if (strchr(prot->type,'X')) /* Cut off here. */ break; - if(cgc != NULL) { + if(cgc != NULL) { /* If we have an intermediate copy, toss it. */ if(cgc->par_in != NULL) cgc->par_in->b_rptr = mbs_in; if(cgc->par_out!= NULL) cgc->par_out->b_rptr= mbs_out; dropgrab(cgc); } } + + /* Done. Return the result. */ dropgrab(*cgm); *cgm = cg; return NULL; } +/* Scan all the P lines, search for a matching block of entries and incorporate into *cgm. */ char * pmatch (conngrab *cgm) { @@ -363,7 +399,7 @@ pmatch (conngrab *cgm) return errstr; } - +/* Scan the configuration, incorporate matching entries into *foo. */ char * findsite (conngrab *foo) { @@ -378,13 +414,17 @@ findsite (conngrab *foo) chkone(cg); cg->refs++; - for (dl = cf_DL; dl != NULL; dl = dl->next) { + for (dl = cf_DL; dl != NULL; dl = dl->next) { /* find a matching local number. */ char *matcrd; + char *matclass; -if(0)printf("%s.%s.!.",cg->site,cg->card); +if(0)printf("%s.%s.!.",cg->site,cg->card); /* I hate debugging. */ + + if ((matclass = classmatch (cg->cclass, dl->cclass)) == NULL) + continue; if ((matcrd = wildmatch (cg->card, dl->card)) == NULL) continue; - if(!(cg->flags & F_LEASED)) { + if(!(cg->flags & F_LEASED)) { /* ... and a working dial prefix. */ char *crd; for (dp = cf_DP; dp != NULL; dp = dp->next) { if ((crd = wildmatch (cg->card, dp->card)) != NULL) @@ -395,8 +435,17 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); continue; } matcrd = crd; - } - for (d = cf_D, numwrap = 1; d != NULL || numwrap > 0; d = (numwrap ? d->next : d)) { + } /* if everybody had DSS1, we could skip the prefix nonsense... */ + + /* Now find a site to call out to. */ + /* The numwrap stuff makes sure that we restart where we left off last + time, which ensures that calling a system with more than one + number does what it's supposed to. */ + /* Incoming calls start at the beginning and don't hit the + wraparound. */ + for (d = cf_D, numwrap = (cg->flags & F_INCOMING); + (d != NULL) || (numwrap > 0); + d = (numwrap ? d->next : d)) { char *matcla; char *matsit; char *matcar; @@ -411,8 +460,10 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); continue; else if(numwrap == 0) numwrap = -1; + if(!(cg->flags & F_INCOMING)) numidx++; + /* Yes, we did increment the refcount, above. */ dropgrab(cg); cg = *foo; cg->refs++; @@ -421,8 +472,10 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); if((matpro = wildmatch(cg->protocol,d->protocol)) == NULL) continue; if((matcar = wildmatch(matcrd,d->card)) == NULL) continue; if((matcla = classmatch(cg->cclass,d->cclass)) == NULL) continue; + if((matcla = classmatch(matcla,matclass)) == NULL) continue; if(!matchflag(cg->flags,d->type)) continue; + /* Preliminary match OK, remember the data so far. */ dropgrab(cg); cg = newgrab(*foo); if(cg == NULL) return "0OUT OF MEM"; @@ -432,9 +485,9 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); if(0)printf("%s...",matsit); if(!(cg->flags & F_LEASED)) { + /* Now figure out the numbers... */ if(cg->nr != NULL) { cg->nrsuf = match_nr(cg->nr,d->arg, ((cg->flags&F_INCOMING) && (dp->args != NULL)) ? dp->args : dp->arg); - if(0)printf("Match %s,%s,%s -> %s\n",cg->nr,d->arg, ((cg->flags&F_INCOMING) && (dp->args != NULL)) ? dp->args : dp->arg, cg->nrsuf); if(cg->nrsuf == NULL) { if(*errstr > '8') { dropgrab(errcg); errcg = cg; cg->refs++; @@ -444,7 +497,6 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); } } else if(!(cg->flags & F_INCOMING)) { cg->nr = build_nr(d->arg,dl->arg,((cg->flags&F_INCOMING) && (dp->args != NULL)) ? dp->args : dp->arg, 0); - if(0)printf("Build %s,%s,%s,%d -> %s\n",d->arg,dl->arg,((cg->flags&F_INCOMING) && (dp->args != NULL)) ? dp->args : dp->arg, 0, cg->nr); if(cg->nr == NULL) { if(*errstr > '8') { dropgrab(errcg); errcg = cg; cg->refs++; @@ -458,7 +510,6 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); } if(cg->lnr != NULL) { cg->lnrsuf = match_nr(cg->lnr,dl->arg, ((cg->flags&F_INCOMING) && (dp->args != NULL)) ? dp->args : dp->arg); - if(0)printf("MatchL %s,%s,%s -> %s\n",cg->lnr,dl->arg, ((cg->flags&F_INCOMING) && (dp->args != NULL)) ? dp->args : dp->arg, cg->lnrsuf); if(cg->lnrsuf == NULL) { if(*errstr > '3') { dropgrab(errcg); errcg = cg; cg->refs++; @@ -468,7 +519,6 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); } } else if(0) { /* Hmmm... */ cg->lnr = build_nr(dl->arg,dl->arg,((cg->flags&F_INCOMING) && (dp->args != NULL)) ? dp->args : dp->arg, 0); - if(0)printf("BuildL %s,%s,%s,%d -> %s\n",dl->arg,dl->arg,((cg->flags&F_INCOMING) && (dp->args != NULL)) ? dp->args : dp->arg, 0, cg->lnr); if(cg->lnr == NULL) { if(*errstr > '4') { dropgrab(errcg); errcg = cg; cg->refs++; @@ -479,45 +529,31 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); } } - if ((errstrx = pmatch (&cg)) == NULL) { - goto gotit; - } - if(*errstr > *errstrx) { - errstr = errstrx; - errcg = cg; cg->refs++; - } - /* p->b_rptr = olds; */ - } - dropgrab(cg); - if(errcg != NULL) { - dropgrab(*foo); *foo = errcg; - } - if(errstr != NULL) - printf("A>%s; ",errstr); - return errstr; - - gotit: - { + /* Do we have a matching P line? */ + if ((errstrx = pmatch (&cg)) == NULL) { /* We have what we need. Now figure out if we can use it. */ struct conninfo *conn; cf cl = NULL; int nrconn = 0, naconn = 0; int nrbchan = 0; + /* Check if there's a limiter. */ for(cl = cf_CL; cl != NULL; cl = cl->next) { + if(classmatch(cg->cclass,cl->cclass) == NULL) + continue; if(wildmatch(cg->card, cl->card)) break; } + /* Check if we know how many B channels the card has */ { - int ci; - for(ci=0; ci < cardnum; ci++) { - if(!strcmp(cg->card, cardlist[ci])) { - nrbchan = cardnrbchan[ci]; + struct isdncard *ca; + + for(ca = isdn4_card; ca != NULL; ca = ca->next) { + if(!strcmp(cg->card, ca->name)) { + nrbchan = ca->nrbchan; break; } } } - if(cl != NULL) { -printf("Limit for %s:%d:%d %s:%s:%s %s\n",cg->card,cl->num,nrbchan,cg->site,cg->protocol,cg->cclass,cg->nr ? cg->nr : "-"); for(conn = theconn; conn != NULL; conn = conn->next) { if(conn->ignore || !conn->cg) continue; @@ -525,36 +561,41 @@ printf("Limit for %s:%d:%d %s:%s:%s %s\n",cg->card,cl->num,nrbchan,cg->site,cg-> wildmatch(conn->cg->protocol,cg->protocol)) continue; if((conn->state >= c_going_up) && wildmatch(conn->cg->card, cg->card)) { -printf("Share line with %s:%d:%d %s:%s:%s %s\n",conn->cg->card,cl->num,nrbchan,conn->cg->site,conn->cg->protocol,conn->cg->cclass,conn->cg->nr ? conn->cg->nr : "-"); nrconn ++; if(!(conn->flags & F_IGNORELIMIT)) naconn++; } } - if(((nrbchan > 0) && (nrconn >= nrbchan)) || ((naconn >= cl->num) && !(cg->flags & F_IGNORELIMIT))) { -printf("BUSY: nrb %d, nrc %d, nac %d, num %d, flag %o ::",nrbchan,nrconn,naconn,cl->num,cg->flags); + if(((nrbchan > 0) && (nrconn >= nrbchan)) || ((cl != NULL) && (naconn >= cl->num) && !(cg->flags & F_IGNORELIMIT))) { errstr = "0BUSY"; dropgrab(errcg); errcg = cg; cg->refs++; continue; } - } if (cg->par_out != NULL && strchr(d->type, 'H') != NULL && !(cg->flags & F_OUTCOMPLETE)) m_putsx (cg->par_out, ARG_SUPPRESS); dropgrab(errcg); dropgrab(*foo); *foo = cg; return NULL; } + /* No go. Remember the error, if appropriate. */ + if(*errstr > *errstrx) { + errstr = errstrx; + errcg = cg; cg->refs++; + } + /* p->b_rptr = olds; */ } + } + /* Nothing matched. Grrr. */ dropgrab(cg); if(errcg != NULL) { dropgrab(*foo); *foo = errcg; } - if(errstr != NULL) - printf("B>%s; ",errstr); return errstr; } +/* Wrapper stuff. Take numbers out of the incoming argument vector, find + the card, et al. */ char * findit (conngrab *foo) { @@ -562,7 +603,7 @@ findit (conngrab *foo) mblk_t *p; char *errstr = "9NO CARD"; char *errstrx; - short c; + struct isdncard *c; char *card; conngrab cg = newgrab(*foo); conngrab errcg = NULL; @@ -606,25 +647,39 @@ findit (conngrab *foo) cg->site = str_enter("unknown"); } - cardlim = cardnum+cardidx; - for (c = cardidx; c < cardlim; c++) { + cardlim = 0; + + if(isdn4_card != NULL) { + for(c = isdn4_card; (c != NULL) || (cardlim < cardidx); c = c->next) { cf crd; - if(!wildmatch(card,cardlist[c % cardnum])) - continue; - cg->card = cardlist[c % cardnum]; - if(cg->flags & F_INCOMING) - numidx = 1; - if ((errstrx = findsite (&cg)) == NULL) { - cardidx = (c+1)%cardnum; + + cardlim++; + + if(c == NULL) { /* Wraparound */ + c = isdn4_card; + if(cardlim < cardidx) + cardidx %= cardlim; + } + if(!wildmatch(card,c->name)) + continue; + if(cg->flags & F_INCOMING) /* never skip */ + cardidx = 1; + if(cardlim < cardidx) + continue; + cg->card = c->name; + if ((errstrx = findsite (&cg)) == NULL) { /* Found it */ + cardidx++; dropgrab(*foo); *foo = cg; cg->flags |= F_OUTCOMPLETE; + if(c->cap & CHM_INTELLIGENT) + return NULL; for (crd = cf_CM; crd != NULL; crd = crd->next) { - if (!wildmatch (cardlist[c % cardnum], crd->card)) + if (!wildmatch (c->name, crd->card)) continue; return NULL; } - errstrx = "0CARDMATCH"; + errstrx = "0CM line missing"; } if(*errstrx < *errstr) { errstr = errstrx; @@ -632,6 +687,9 @@ findit (conngrab *foo) errcg->refs++; } } + } else + errstr = "0No card in the system"; + if(errcg != NULL) { dropgrab(*foo); *foo = errcg; @@ -639,3 +697,4 @@ findit (conngrab *foo) dropgrab(cg); return errstr; } + diff --git a/isdn_4/stream.c b/isdn_4/stream.c index 58fd7f0..3786c95 100644 --- a/isdn_4/stream.c +++ b/isdn_4/stream.c @@ -80,6 +80,9 @@ read_data () case HDR_UIDATA: xREAD (uidata); break; + case HDR_LOAD: + xREAD (load); + break; case HDR_RAWDATA: xREAD (rawdata); break; @@ -132,12 +135,15 @@ static void backtime(void *nix) { backtimeout = 1; } +/* Do something until fd becomes active or timeout */ +/* Also process alerts */ +/* fd==-1: one-shot */ +/* fd==-2: continuous loop */ int backrun (int fd, int timeo) { int err; fd_set rdx; - time_t tx = time(NULL); if(!testonly && !FD_ISSET(fd_mon,&rd)) xquit("RD fd_set cleared",NULL); @@ -182,7 +188,7 @@ backrun (int fd, int timeo) return backtimeout; } - +/* Main Program Loop */ void syspoll (void) { @@ -196,6 +202,7 @@ syspoll (void) } +/* Upper stream read */ void do_h (queue_t * q) { @@ -203,17 +210,18 @@ do_h (queue_t * q) int len = sizeof (data) - 1; int err; - while ((err = strread (xs_mon, (streamchar *) data, &len, 1)) == 0 && len > 0) { - do_info (data, len); + while ((err = strread (xs_mon, (streamchar *) data, len, 1)) > 0) { + do_info (data, err); len = sizeof (data) - 1; } - if (err != 0) { - errno = err; + if (err < 0) { + errno = -err; syslog (LOG_ERR, "Read H: %m"); } else q->q_flag |= QWANTR; } +/* Lower stream read */ void do_l (queue_t * q) { @@ -224,9 +232,8 @@ do_l (queue_t * q) while (1) { struct iovec io[3]; int iovlen = 1; - int len = sizeof (struct _isdn23_hdr); - if ((err = strread (xs_mon, (streamchar *) &h, &len, 0)) == 0 && len == sizeof (struct _isdn23_hdr)) ; + if ((err = strread (xs_mon, (streamchar *) &h, sizeof (struct _isdn23_hdr), 0)) == sizeof (struct _isdn23_hdr)) ; else break; @@ -243,21 +250,22 @@ do_l (queue_t * q) case HDR_DATA: case HDR_UIDATA: case HDR_PROTOCMD: + case HDR_LOAD: io[iovlen].iov_base = (caddr_t) data; - io[iovlen].iov_len = len = h.hdr_atcmd.len; - if ((err = strread (xs_mon, (streamchar *) data, &len, 0)) != 0 || len != h.hdr_atcmd.len) { - syslog (LOG_ERR, "do_l: Fault, %d, %m", len); + io[iovlen].iov_len = h.hdr_atcmd.len; + if ((err = strread (xs_mon, (streamchar *) data, h.hdr_atcmd.len, 0)) != h.hdr_atcmd.len) { + syslog (LOG_ERR, "do_l: Fault, %d, %m", err); return; } io[iovlen].iov_base = (caddr_t) data; - io[iovlen].iov_len = len; + io[iovlen].iov_len = err; iovlen++; break; case HDR_INVAL: io[iovlen].iov_base = (caddr_t) data; - io[iovlen].iov_len = len = sizeof (struct _isdn23_hdr); - if ((err = strread (xs_mon, (streamchar *) data, &len, 0)) != 0 || len != sizeof (struct _isdn23_hdr)) { - syslog (LOG_ERR, "do_l: Fault, %d, %m", len); + io[iovlen].iov_len = sizeof (struct _isdn23_hdr); + if ((err = strread (xs_mon, (streamchar *) data, sizeof (struct _isdn23_hdr), 0)) != sizeof (struct _isdn23_hdr)) { + syslog (LOG_ERR, "do_l: Fault, %m"); return; } iovlen++; @@ -277,7 +285,7 @@ do_l (queue_t * q) } } if (err != 0) { - errno = err; + errno = -err; syslog (LOG_ERR, "Read L: %m"); } else q->q_flag |= QWANTR; diff --git a/isdn_4/texts.c b/isdn_4/texts.c index ff5f621..f9524cc 100644 --- a/isdn_4/texts.c +++ b/isdn_4/texts.c @@ -7,7 +7,7 @@ #include "master.h" - +/* Textual representation of a connection state */ char *state2str(CState state) { switch(state) { case c_up: return "up"; @@ -21,7 +21,7 @@ char *state2str(CState state) { } } - +/* Textual representation of a L2<->3 information element */ char *HdrName (int hdr) { switch(hdr) { @@ -48,6 +48,7 @@ char *HdrName (int hdr) } } +/* Textual representation of flags */ char *FlagInfo(int flag) { static char fbuf[30]; @@ -62,7 +63,7 @@ char *FlagInfo(int flag) if (flag & F_FASTREDIAL) strcat(fbuf, ":fr"); if (flag & F_PERMANENT) strcat(fbuf, ":dP"); if (flag & F_LEASED) strcat(fbuf, ":dL"); - if (flag & F_IGNOREBUSY) strcat(fbuf, ":ib"); + if (flag & F_CHANBUSY) strcat(fbuf, ":ib"); if (flag & F_NRCOMPLETE) strcat(fbuf, ":nc"); if (flag & F_LNRCOMPLETE) strcat(fbuf, ":lc"); if (flag & F_INCOMING) strcat(fbuf, ":in"); @@ -78,6 +79,8 @@ char *FlagInfo(int flag) strcpy(fbuf,"-"); return fbuf; } + +/* Textual representation of ISDN causes */ const char *CauseInfo(int cause, char *pri) { if (cause == 999999) return "-"; diff --git a/isdn_4/util.c b/isdn_4/util.c index 68c775e..37710c1 100644 --- a/isdn_4/util.c +++ b/isdn_4/util.c @@ -7,7 +7,10 @@ #include "master.h" - +/* Too many strings to keep track of, no time for garbage collection. */ +/* Enter them in a binary tree... */ +/* str_enter MUST NOT be called while any string in the tree is temporarily + modified. No string in the tree may be permanently modified in ANY way. */ char *str_enter(char *master) { struct string **str = &stringdb; @@ -39,6 +42,10 @@ char *str_enter(char *master) return st->data; } +/* Simpleminded, bidirectional wildmat(). + If both strings are patterns, this doesn't work. Unfortunately, pattern + joining is obviously NP-complete, and I don't know any algorithms to do it + anyway. */ char *wildmatch(char *a, char *b) { if(a == NULL) @@ -53,27 +60,141 @@ char *wildmatch(char *a, char *b) return NULL; } -char *classmatch(char *a, char *b) +/* Given a string aaa+bbb, return aaa. */ +char * +strippat(char *a) +{ + char aa[30]; + char *aplus = strchr(a,'+'); + + if(aplus == NULL) + return a; + *aplus = '\0'; + strcpy(aa,a); + *aplus = '+'; + return str_enter(aa); +} + +/* Given strings +aaa+bbb and +ccc+aaa, return +aaa+bbb+ccc. */ +static char * +pluscat(char *a, char *b) { if(a == NULL) return b; - else if(b == NULL) + if(b == NULL) return a; - else if(*b == '*') - return a; - else if(*a == '*') + if(*a != '+') return b; - else { + if(*b != '+') + return a; + { + char classpat[50]; + char *classind = classpat; + strcpy(classpat,a); + while(*classind) { + if(*classind == '+') + *classind = '\0'; + classind++; + } + { + char *bnext = b; + do { + b = bnext + 1; + bnext = strchr(b,'+'); + if(bnext != NULL) *bnext = '\0'; + for(a = classpat+1; a < classind; a += strlen(a)+1) + if(strcmp(a,b) == 0) + break; + if(a >= classind) { + strcpy(classind+1,b); + classind += strlen(b)+1; + } + if(bnext != NULL) *bnext = '+'; + } while(bnext != NULL); + for(a = classpat; a < classind; a += strlen(a)) + *a++ = '+'; + *a = '\0'; + return str_enter(classpat); + } + } +} + +/* "abc" "bcd" -> "bc" */ +/* "abc+bc" "bcd+b" -> "bc+bc+b" */ +/* "abc+bc" "bcd+d" -> NULL */ +/* It is of course possible to optimize all of this, but it's not worth the + work. */ +char * +classmatch(char *a, char *b) +{ + if(a == NULL) + return NULL; + if(b == NULL) + return NULL; + if(*b == '*' || *b == '\0') + return a; + if(*a == '*' || *a == '\0') + return b; + if(*a == '+' || *b == '+') { + if(*a == '+' && *b == '+') { + char classpat[50]; + if(strcmp(a,b) == 0) + return a; + strcpy(classpat,a); + strcat(classpat,b); + return str_enter(classpat); + } else { + char *aorig,*bplus; + if(*a != '+') { + char *tmp = a; a = b; b = tmp; + } + if((bplus=strchr(b,'+')) != NULL) *bplus='\0'; + aorig = a; + if(strlen(a) == 2) { /* Obvious optimization */ + a = classmatch(b,a+1); + if(bplus != NULL) *bplus = '+'; + return a; + } + do { + while(*++a != '\0' && *a != '+') { + if(strchr(b,*a) != NULL) + break; + } + if(*a == '\0' || *a == '+') { + if(bplus != NULL) *bplus='+'; + return NULL; + } + } while((a = strchr(a,'+')) != NULL); + { + char classpat[50]; + strcpy(classpat,b); + if(bplus != NULL) + *bplus='+'; + strcat(classpat,pluscat(aorig,bplus)); + return str_enter(classpat); + } + } + } else { char classpat[30]; char *classind = classpat; + char *aplus, *bplus; + if((aplus=strchr(a,'+')) != NULL) *aplus='\0'; + if((bplus=strchr(b,'+')) != NULL) *bplus='\0'; while(*a != 0) { if(strchr(b,*a) != NULL) *classind++ = *a; a++; } + if(aplus != NULL) *aplus='+'; + if(bplus != NULL) *bplus='+'; if(classpat == classind) return NULL; *classind = 0; + /* If the class is one character long, there's not much point + in carrying around all the baggage. */ + if((classind > classpat+1) && (aplus != NULL || bplus != NULL)) + return classmatch(str_enter(classpat),pluscat(aplus,bplus)); + else return str_enter(classpat); } } @@ -100,7 +221,7 @@ xquit (const char *s, const char *t) { if (s != NULL) syslog (LOG_WARNING, "%s %s: %m", s, t ? t : ""); - exit (4); + abort(); } void panic(const char *x, ...) diff --git a/isdn_4/work.c b/isdn_4/work.c index 847d4b3..d4662d6 100644 --- a/isdn_4/work.c +++ b/isdn_4/work.c @@ -6,8 +6,9 @@ */ #include "master.h" +#include "isdn_12.h" - +/* Handle dead processes */ void deadkid (void) { @@ -69,6 +70,7 @@ deadkid (void) } +/* Push protocols onto stream */ int pushprot (conngrab cg, int minor, char update) { @@ -84,7 +86,7 @@ pushprot (conngrab cg, int minor, char update) break; } if (prot == NULL) - return ENOENT; + return -ENOENT; if(update) cg->flags = (cg->flags & ~F_SETINITIAL) | F_SETLATER; else @@ -93,8 +95,7 @@ pushprot (conngrab cg, int minor, char update) char *sp1, *sp2; char *sx; - if(!update) { - mblk_t *mj = allocb (40 + strlen (prot->args), BPRI_LO); + mblk_t *mj = allocb (60 + strlen (prot->args), BPRI_LO); int len; mods = prot->args; @@ -102,17 +103,22 @@ pushprot (conngrab cg, int minor, char update) m_putsx (mj, ARG_MINOR); m_puti (mj, minor); m_putdelim (mj); + if(update) + m_putid (mj, PROTO_UPDATEMODLIST); + else m_putid (mj, PROTO_MODLIST); + m_putsx (mj, ARG_MODE); /* set card mode */ + m_putsz (mj, prot->arg); m_putdelim (mj); m_putsz(mj, mods); len = mj->b_wptr - mj->b_rptr; DUMPW (mj->b_rptr, len); - (void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, &len, 1); + (void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, len, 1); freeb (mj); - } + sx = (char *)malloc (strlen (prot->args) + 5 + strlen (PROTO_NAME)); if (sx == NULL) - return ENOMEM; + return -ENOMEM; sprintf (sx, " %s %s", prot->args, PROTO_NAME); sp1 = sx; while (*sp1 != '\0' && !isspace (*sp1)) @@ -129,7 +135,7 @@ pushprot (conngrab cg, int minor, char update) *sp2++ = '\0'; if ((mi = allocb (256, BPRI_MED)) == NULL) { free (sx); - return ENOMEM; + return -ENOMEM; } for (cm = cf_MP; cm != NULL; cm = cm->next) { ushort_t id; @@ -209,7 +215,7 @@ pushprot (conngrab cg, int minor, char update) int len; if (mj == NULL) - return ENOMEM; + return -ENOMEM; m_putid (mj, CMD_PROT); m_putsx (mj, ARG_MINOR); m_puti (mj, minor); @@ -217,7 +223,7 @@ pushprot (conngrab cg, int minor, char update) m_putc (mj, PROTO_MODE); len = mj->b_wptr - mj->b_rptr; DUMPW (mj->b_rptr, len); - (void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, &len, 1); + (void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, len, 1); freeb (mj); } @@ -226,12 +232,21 @@ pushprot (conngrab cg, int minor, char update) } +/* Set ISDN card mode */ int pushcardprot (conngrab cg, int minor) { cf prot; cf cmod = NULL; + int num = 0; /* Grrr, GCC */ + struct isdncard *card; + for(card = isdn4_card; card != NULL; card = card->next) { + if(wildmatch(cg->card,card->name)) + break; + } + if(card == NULL) + return -ENOENT; for (prot = cf_ML; prot != NULL; prot = prot->next) { if(!matchflag(cg->flags,prot->type)) continue; if (!wildmatch (cg->site, prot->site)) continue; @@ -239,38 +254,46 @@ pushcardprot (conngrab cg, int minor) if (!wildmatch (cg->card, prot->card)) continue; if (!classmatch (cg->cclass, prot->cclass)) continue; + if(card->cap & CHM_INTELLIGENT) { + num = 1; + } else { for (cmod = cf_CM; cmod != NULL; cmod = cmod->next) { if (!wildmatch (cg->card, cmod->card)) continue; if (!wildmatch(prot->arg,cmod->arg)) continue; break; } - if (cmod != NULL) + if (cmod == NULL) + return -ENOENT; + num = cmod->num; break; } + } if (prot == NULL) - return ENOENT; + return -ENOENT; + if (minor != 0) { mblk_t *mj = allocb (32, BPRI_LO); int len; if (mj == NULL) - return ENOMEM; + return -ENOMEM; m_putid (mj, CMD_CARDSETUP); m_putsx (mj, ARG_MINOR); m_puti (mj, minor); m_putdelim (mj); m_putc (mj, PROTO_MODE); - m_puti (mj, cmod->num); + m_puti (mj, num); m_puti (mj, prot->num); len = mj->b_wptr - mj->b_rptr; DUMPW (mj->b_rptr, len); - (void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, &len, 1); + (void) strwrite (xs_mon, (uchar_t *) mj->b_rptr, len, 1); freeb (mj); } return 0; } +/* Startup a connection... */ struct conninfo * startconn(conngrab cg, int fminor, int connref, char **ret) { @@ -341,6 +364,7 @@ startconn(conngrab cg, int fminor, int connref, char **ret) } if(conn == NULL) { dropgrab(cg); + *ret = "Internal error: Connection not found"; return NULL; } @@ -490,7 +514,6 @@ printf("Start: %s:%s #%s...",cg->site,cg->protocol,cg->nr); * Start a new program. * - if foo is NULL (and conn isn't), start a subprogram. */ - char * runprog (cf cfr, struct conninfo **rconn, conngrab *foo) { @@ -778,7 +801,7 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) if(conn->cg->protocol != NULL) putenv2 ("PROTOCOL", conn->cg->protocol); if(conn->cg->cclass != NULL) - putenv2 ("CLASS", conn->cg->cclass); + putenv2 ("CLASS", strippat(conn->cg->cclass)); if(conn->cg->nr != NULL) putenv2 ("PHONE", conn->cg->nr); if(conn->cg->lnr != NULL) @@ -824,7 +847,7 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) else (*arg)++; alarm(0); - execv (ap, arg); + execvp (ap, arg); syslog (LOG_ERR, "Could not execute %s for %s/%s: %m", *arg,cg->site,cg->protocol); if (cfr != NULL && cg != NULL) write (pip[1], "EXEC", 4); @@ -894,9 +917,6 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) syslog (LOG_INFO, "exec %x:%x %d %s/%s %s", dev, dev2, pid, cfr->site,cfr->protocol, cfr->args); printf ("* PID %d\n", pid); - if (conn != NULL) { - } - if(prog != NULL) { prog->next = conn->run; conn->run = prog; @@ -916,7 +936,7 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) m_puti (&yy, conn->minor); xlen = yy.b_wptr - yy.b_rptr; DUMPW (yy.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, xlen, 1); yy.b_wptr = yy.b_rptr; if (conn->fminor != 0 && conn->fminor != conn->minor) { @@ -925,7 +945,7 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) m_puti (&yy, conn->fminor); xlen = yy.b_wptr - yy.b_rptr; DUMPW (yy.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, xlen, 1); yy.b_wptr = yy.b_rptr; } m_putid (&yy, CMD_PROT); @@ -943,7 +963,7 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) xlen = yy.b_wptr - yy.b_rptr; DUMPW (yy.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, xlen, 1); yy.b_wptr = yy.b_rptr; if(conn->fminor != 0 && conn->fminor != conn->minor) { @@ -957,11 +977,13 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) m_putsx (&yy, PROTO_ONLINE); xlen = yy.b_wptr - yy.b_rptr; DUMPW (yy.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, xlen, 1); yy.b_wptr = yy.b_rptr; } if(cg != NULL && (cg->flags & (F_INCOMING|F_OUTGOING))) { + char *msg = NULL; + cg->refs++; dropgrab(conn->cg); conn->cg = cg; @@ -973,10 +995,10 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) else cg->delay = 0; } - if(startconn(conn->cg,0,0, NULL) == conn) + if(startconn(conn->cg,0,0, &msg) == conn) setconnstate(conn,c_going_up); else { - syslog(LOG_CRIT,"Bug in runprog->startconn for %s:%s",cg->site,cg->protocol); + syslog(LOG_CRIT,"Bug in runprog->startconn (%s) for %s:%s",msg ? msg : "(unknown reason)", cg->site,cg->protocol); dropgrab(conn->cg); conn->cg = NULL; chkone(conn); @@ -990,7 +1012,7 @@ printf("NoProtoEnable NotPushprot\n"); m_puti (&yy, conn->minor); xlen = yy.b_wptr - yy.b_rptr; DUMPW (yy.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, xlen, 1); conn->minor = 0; if(conn->pid == 0) dropconn(conn); @@ -1006,7 +1028,7 @@ printf("NoProtoEnable NotPushprot\n"); m_putid(&yy,PROTO_ENABLE); xlen = yy.b_wptr - yy.b_rptr; DUMPW (yy.b_rptr, xlen); - (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, &xlen, 1); + (void) strwrite (xs_mon, (uchar_t *) yy.b_rptr, xlen, 1); } else printf("NoProtoEnable NotPermanent\n"); cg->card = str_enter("*"); /* cosmetic */ @@ -1021,6 +1043,8 @@ else printf("NoProtoEnable NotPermanent\n"); return NULL; } + +/* Kill applicable subprograms */ void kill_rp(struct conninfo *conn, char whatnot) { @@ -1053,6 +1077,7 @@ kill_rp(struct conninfo *conn, char whatnot) } } +/* Start applicable subprograms. */ void run_rp(struct conninfo *conn, char what) { @@ -1099,6 +1124,8 @@ run_rp(struct conninfo *conn, char what) } } + +/* Find the next program to run */ void run_now(void *nix) { @@ -1184,6 +1211,8 @@ printf("exist %s:%s\n",conn->cg->site,conn->cg->protocol); do_run_now = 0; } + +/* Any programs still running? */ int has_progs(void) { @@ -1201,6 +1230,7 @@ has_progs(void) return 0; } +/* Kill one program / all programs */ void kill_progs(struct conninfo *xconn) { @@ -1227,7 +1257,7 @@ kill_progs(struct conninfo *xconn) xlen = mb->b_wptr - mb->b_rptr; DUMPW (mb->b_rptr, xlen); - (void) strwrite (xs_mon, mb->b_rptr, &xlen, 1); + (void) strwrite (xs_mon, mb->b_rptr, xlen, 1); freemsg(mb); conn->minor = 0; if(xconn != NULL) diff --git a/ksupport/Makefile b/ksupport/Makefile index 24c8119..bb44466 100644 --- a/ksupport/Makefile +++ b/ksupport/Makefile @@ -1,54 +1,4 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = - -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux - -SOURCES = count.c dump.c log.c logh.c proto.c qinfo.c smallq.c streamlib.c x75lib.c -OBJ = count.o dump.o log.o logh.o proto.o qinfo.o smallq.o streamlib.o x75lib.o -ALL = - -all: $(OBJ) $(ALL) - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -clean: - rm -f $(ALL) $(OBJ) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - insmod streamlib.o - insmod smallq.o - insmod dump.o - insmod log.o - insmod logh.o - insmod count.o - insmod proto.o - insmod qinfo.o - insmod x75lib.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +KERNEL=1 +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/ksupport/dump.c b/ksupport/dump.c index 56ef869..732f419 100644 --- a/ksupport/dump.c +++ b/ksupport/dump.c @@ -1,5 +1,6 @@ #include "f_module.h" #include "primitives.h" +#include "kernel.h" #include "isdn_23.h" #ifdef KERNEL #define putchar(x) printf("%c",(x)) @@ -174,113 +175,146 @@ conv_ind (unsigned char xx) } } -void -dump_hdr (isdn23_hdr hdr, const char *what, uchar_t * data) +static void +dump_one_hdr (isdn23_hdr hdr) { -#define DUMP() do { dumpaschex(data,hdr->hdr_data.len); printf("\n");} while(0) - - if(what != NULL) - printf (" %s: ", what); - + printf("=%x_",hdr->seqnum); if(hdr->key & HDR_NOERROR) - printf("NoErr:"); + printf("NoErr_"); switch (hdr->key & ~HDR_FLAGS) { default: #ifdef KERNEL printf("??? Unknown header ID %d\n",hdr->key); - break; #else syslog (LOG_ERR, "Unknown header ID %d", hdr->key); - abort (); + printf("Unknown header ID %d", hdr->key); #endif + break; case HDR_ATCMD: - printf ("AT Cmd from %d: ", hdr->hdr_atcmd.minor); - if(data != NULL) - dumpascii (data, hdr->hdr_data.len); - printf ("\n"); + printf ("ATcmd from %d", hdr->hdr_atcmd.minor); break; case HDR_PROTOCMD: - printf ("Protocol Cmd from %d: ", hdr->hdr_atcmd.minor); - if(data != NULL) - dumpascii (data, hdr->hdr_data.len); - printf ("\n"); + printf ("ProtocolCmd from %d", hdr->hdr_atcmd.minor); break; case HDR_XDATA: - printf ("XData from %d:\n ", hdr->hdr_xdata.minor); - if(data != NULL) - DUMP (); + printf ("XData from %d", hdr->hdr_xdata.minor); break; case HDR_DATA: - printf ("I Data from %d/%02x\n ", hdr->hdr_data.card, hdr->hdr_data.SAPI); - if(data != NULL) - DUMP (); + printf ("Idata from %d/%02x", hdr->hdr_data.card, hdr->hdr_data.SAPI); break; case HDR_UIDATA: - printf ("UI Data from %d/%02x\n ", hdr->hdr_data.card, hdr->hdr_data.SAPI); - if(data != NULL) - DUMP (); + printf ("UIdata from %d/%02x", hdr->hdr_data.card, hdr->hdr_data.SAPI); break; case HDR_RAWDATA: - printf ("Raw Data from %d\n ", hdr->hdr_data.card); - if(data != NULL) - DUMP (); + printf ("RawData from %d", hdr->hdr_data.card); break; case HDR_LOAD: - printf("Boot from %d, stage %d, offset %d\n",hdr->hdr_load.card,hdr->hdr_load.seqnum,hdr->hdr_load.foffset); - if(data != NULL) - DUMP (); + printf("Boot from %d, stage %d, offset %d len %d",hdr->hdr_load.card,hdr->hdr_load.seqnum,hdr->hdr_load.foffset,hdr->hdr_load.len); break; case HDR_TEI: - printf ("TEI: card %d, TEI %d\n", hdr->hdr_tei.card, hdr->hdr_tei.TEI); + printf ("TEI card %d, TEI %d", hdr->hdr_tei.card, hdr->hdr_tei.TEI); break; case HDR_OPEN: - printf ("Open port %d, flags %o\n", hdr->hdr_open.minor, hdr->hdr_open.flags); + printf ("Open port %d, flags %o", hdr->hdr_open.minor, hdr->hdr_open.flags); break; case HDR_CLOSE: - printf ("Close port %d, errno %d\n", hdr->hdr_close.minor, hdr->hdr_close.error); + printf ("Close port %d, errno %d", hdr->hdr_close.minor, hdr->hdr_close.error); break; case HDR_ATTACH: - printf ("Attach chan %d/%d to port %d, mode %d, %s%s\n", + printf ("Attach chan %d/%d to port %d, mode %d, %s%s", hdr->hdr_attach.card, hdr->hdr_attach.chan, hdr->hdr_attach.minor, hdr->hdr_attach.mode, (hdr->hdr_attach.listen & 1) ? "listen" : "talk", (hdr->hdr_attach.listen & 2) ? " force" : ""); break; case HDR_DETACH: - printf ("Detach port %d, errno %d, force %d\n", hdr->hdr_detach.minor, + printf ("Detach port %d, errno %d, force %d", hdr->hdr_detach.minor, hdr->hdr_detach.error,hdr->hdr_detach.perm); break; case HDR_CARD: - printf ("Card %d online (%d B channels, flag 0%o)\n", hdr->hdr_card.card, hdr->hdr_card.bchans,hdr->hdr_card.flags); + printf ("Card %d online (%d B channels, flag 0%o)", hdr->hdr_card.card, hdr->hdr_card.bchans,hdr->hdr_card.flags); break; case HDR_NOCARD: - printf ("Card %d offline.\n", hdr->hdr_nocard.card); + printf ("Card %d offline.", hdr->hdr_nocard.card); break; case HDR_OPENPROT: - printf ("OpenProtocol %d/%02x, Ind %s\n", hdr->hdr_openprot.card, hdr->hdr_openprot.SAPI, conv_ind(hdr->hdr_openprot.ind)); + printf ("OpenProtocol %d/%02x, Ind %s", hdr->hdr_openprot.card, hdr->hdr_openprot.SAPI, conv_ind(hdr->hdr_openprot.ind)); break; case HDR_CLOSEPROT: - printf ("CloseProtocol %d/%02x, Ind %s\n", hdr->hdr_closeprot.card, hdr->hdr_closeprot.SAPI, conv_ind(hdr->hdr_closeprot.ind)); + printf ("CloseProtocol %d/%02x, Ind %s", hdr->hdr_closeprot.card, hdr->hdr_closeprot.SAPI, conv_ind(hdr->hdr_closeprot.ind)); break; case HDR_NOTIFY: - printf ("State Change %d/%02x, Ind %s:%x\n", hdr->hdr_notify.card, hdr->hdr_notify.SAPI, conv_ind(hdr->hdr_notify.ind), hdr->hdr_notify.add); + printf ("State Change %d/%02x, Ind %s:%x", hdr->hdr_notify.card, hdr->hdr_notify.SAPI, conv_ind(hdr->hdr_notify.ind), hdr->hdr_notify.add); break; case HDR_INVAL: #ifdef KERNEL if(hdr->hdr_inval.error != 0) - printf ("Invalid header, errno %d\n ", hdr->hdr_inval.error); + printf ("Error %d", hdr->hdr_inval.error); else - printf ("Command OK:\n "); + printf ("Command OK"); #else if(hdr->hdr_inval.error != 0) - printf ("Invalid header: %s\n ", strerror(hdr->hdr_inval.error)); + printf ("Error %s", strerror(hdr->hdr_inval.error)); else - printf ("Command OK:\n "); + printf ("Command OK"); #endif - if(data != NULL) - dumphex (data, sizeof (struct _isdn23_hdr)); + break; + } +} +void +dump_hdr (isdn23_hdr hdr, const char *what, uchar_t * data) +{ + if(what != NULL) + printf (" %s: ", what); + + dump_one_hdr(hdr); + switch (hdr->key & ~HDR_FLAGS) { + default: + dumpaschex((uchar_t *)hdr,sizeof(*hdr)); + printf("\n"); +#ifndef KERNEL + abort(); +#endif + break; + case HDR_ATCMD: + case HDR_PROTOCMD: + case HDR_XDATA: + if(data != NULL) { + printf (": "); + dumpascii (data, hdr->hdr_data.len); + } printf ("\n"); break; + case HDR_DATA: + case HDR_UIDATA: + case HDR_RAWDATA: + if(data != NULL) { + printf (": "); + dumphex (data, hdr->hdr_data.len); + } + printf("\n"); + break; + case HDR_LOAD: + case HDR_TEI: + case HDR_OPEN: + case HDR_CLOSE: + case HDR_ATTACH: + case HDR_DETACH: + case HDR_CARD: + case HDR_NOCARD: + case HDR_OPENPROT: + case HDR_CLOSEPROT: + case HDR_NOTIFY: + printf("\n"); + break; + case HDR_INVAL: + printf(" <"); + if(data != NULL) + dump_one_hdr ((isdn23_hdr) data); + else + dump_one_hdr(hdr+1); + printf (">\n"); + break; } } diff --git a/ksupport/log.c b/ksupport/log.c index 8286d2d..2e4dbd7 100644 --- a/ksupport/log.c +++ b/ksupport/log.c @@ -27,9 +27,7 @@ #endif #endif #include -#ifndef KERNEL #include "kernel.h" -#endif #define MAXB 100 @@ -88,7 +86,7 @@ log_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) log->flags = LOG_INUSE | LOG_READ | LOG_WRITE; log->nr = nr++; if (1) - printf (KERN_DEBUG "Log driver %d opened.\n", log->nr); + printf ("%sLog driver %d opened.\n", KERN_DEBUG,log->nr); MORE_USE; return 0; @@ -100,16 +98,21 @@ log_printmsg (void *xlog, const char *text, mblk_t * mp, const char *prefix) { struct _log *log = (struct _log *)xlog; /* int ms = splstr (); */ + static char pprefix[100]; - if(prefix != NULL) - printf("%s",prefix); + if(prefix != NULL) { + strcpy(pprefix,prefix); + printf("%s",pprefix); + } else + *pprefix = '\0'; if (log != NULL) printf ("Log %d: ", log->nr); #if defined(linux) && defined(KERNEL) printf("%ld ",jiffies); #endif + if(text != NULL) printf ("%s", text); -#ifdef KERNEL +#ifdef CONFIG_DEBUG_STREAMS if(msgdsize(mp) < 0) return; #endif @@ -255,12 +258,6 @@ log_printmsg (void *xlog, const char *text, mblk_t * mp, const char *prefix) } } printf ("\n"); -#ifdef KERNEL - if(msgdsize(mp) < 0) - return; -#else - if(msgdsize(mp) < 100) -#endif { int j; mblk_t *mp1; @@ -275,9 +272,18 @@ log_printmsg (void *xlog, const char *text, mblk_t * mp, const char *prefix) int k; int l = (uchar_t *) mp1->b_wptr - dp; - printf ("%s ",prefix?prefix:""); + printf ("%s%03x ",pprefix,i); +#ifdef KERNEL + if(i >= 3*BLOCKSIZE && l > 4*BLOCKSIZE) { /* Skip the stuff in the middle */ + l -= 3*BLOCKSIZE + (l % BLOCKSIZE); + printf("[... %d bytes (0x%x) skipped ...]\n",l,l); + dp += l; + continue; + } +#endif for (k = 0; k < BLOCKSIZE && k < l; k++) printf ("%c%c ", ctab[dp[k] >> 4], ctab[dp[k] & 0x0F]); + i += k; for (; k < BLOCKSIZE; k++) printf (" "); printf (" : "); @@ -363,7 +369,7 @@ log_close (queue_t * q, int dummy) flushq (q, FLUSHALL); flushq (WR (q), FLUSHALL); if(1) - printf (KERN_DEBUG "Log driver %d closed.\n", log->nr); + printf ("%sLog driver %d closed.\n", KERN_DEBUG,log->nr); free(log); LESS_USE; return; diff --git a/ksupport/logh.c b/ksupport/logh.c index 3cc1770..5bbe1e1 100644 --- a/ksupport/logh.c +++ b/ksupport/logh.c @@ -11,9 +11,7 @@ #include #include "streamlib.h" #include "isdn_23.h" -#ifndef KERNEL #include "kernel.h" -#endif #define MAXB 10 @@ -65,7 +63,7 @@ logh_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) q->q_ptr = (char *) log; log->flags = LOG_INUSE | LOG_READ | LOG_WRITE; - printf ("Log driver %d opened.\n", nr); + printf ("%sLog driver %d opened.\n",KERN_DEBUG, nr); log->nr = nr++; MORE_USE; @@ -79,9 +77,9 @@ logh_printmsg (void *xlog, const char *text, mblk_t * mp) struct _log *log = (struct _log *)xlog; if (log != NULL) - printf ("* * "); + printf ("%s* * ",KERN_DEBUG); else - printf ("** "); + printf ("%s** ",KERN_DEBUG); if ((DATA_TYPE(mp) == M_DATA) #ifdef M_EXDATA @@ -108,17 +106,16 @@ logh_printmsg (void *xlog, const char *text, mblk_t * mp) printf ("DupNull\n"); break; } - mn = pullupm (mm, sizeof(struct _isdn23_hdr)); + mn = pullupm (mm, -1); if (mn == NULL) { printf ("NoPullup\n"); freemsg (mm); break; } - dump_hdr ((isdn23_hdr) mn->b_rptr, text, NULL); + dump_hdr ((isdn23_hdr) mn->b_rptr, text, mn->b_rptr+sizeof(struct _isdn23_hdr)); freemsg (mn); } while(0); - log_printmsg (NULL, text, mp, KERN_DEBUG); splx (ms); } @@ -170,7 +167,7 @@ logh_close (queue_t * q, int dummy) flushq (q, FLUSHALL); flushq (WR (q), FLUSHALL); - printf ("LogH driver %d closed.\n", log->nr); + printf ("%sLogH driver %d closed.\n",KERN_DEBUG, log->nr); free(log); LESS_USE; return; diff --git a/ksupport/proto.c b/ksupport/proto.c index df5182e..0e5edf0 100644 --- a/ksupport/proto.c +++ b/ksupport/proto.c @@ -81,7 +81,7 @@ static void setmode(struct _proto *proto, enum Pmode mode) case P_LISTEN : x = "listen" ; break; case P_CONN : x = "connect"; break; } -if(proto->mode != mode) printf("Switch mode to %s, talk %d\n",x,proto->talker); +if(proto->mode != mode) printf("%sSwitch mode to %s, talk %d\n",KERN_DEBUG,x,proto->talker); proto->mode = mode; } @@ -92,7 +92,7 @@ proto_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) if (q->q_ptr) { if (0) - printf ("Protocol: already open?\n"); + printf ("%sProtocol: already open?\n",KERN_DEBUG); return 0; } proto = malloc(sizeof(*proto)); @@ -133,7 +133,7 @@ static void mm_reply (struct _proto *proto, queue_t * q, mblk_t * mp, int err) mblk_t *mq = allocb (err ? 17 : 9, BPRI_HI); if (mq == NULL) { - printf("* NoMem m_reply %d\n",err); + printf("%s* NoMem m_reply %d\n",KERN_DEBUG,err); freemsg (mq); return; } @@ -722,7 +722,7 @@ proto_wsrv (queue_t * q) int realq = 1; while ((mp = getq (q)) != NULL || (realq = 0) || (mp = S_dequeue(&proto->write_delay)) != NULL) { -if(!realq)printf("FromDel %p\n", &proto->write_delay); +if(!realq)printf("%sFromDel %p\n",KERN_DEBUG, &proto->write_delay); switch (DATA_TYPE(mp)) { case MSG_PROTO: freemsg (mp); @@ -900,7 +900,7 @@ if(!realq)printf("FromDel %p\n", &proto->write_delay); iocb = (struct iocblk *) mp->b_rptr; - if(0)printf("Proto IOC %x\n",iocb->ioc_cmd); + if(0)printf("%sProto IOC %x\n",KERN_DEBUG,iocb->ioc_cmd); switch (iocb->ioc_cmd) { #if 1 /* ndef linux */ #ifdef TCGETA @@ -1046,7 +1046,7 @@ if(!realq)printf("FromDel %p\n", &proto->write_delay); int ms; if (mp->b_cont == NULL || iocb->ioc_count != sizeof (struct termios)) { - printf("termios: want %d, got %d\n",sizeof(struct termios),iocb->ioc_count); + printf("%stermios: want %d, got %d\n",KERN_DEBUG,sizeof(struct termios),iocb->ioc_count); goto iocnak; } ms = splstr (); @@ -1214,7 +1214,7 @@ proto_close (queue_t * q, int dummy) flushq (q, FLUSHALL); flushq (WR (q), FLUSHALL); -if(0)printf("FlushDel %p\n", &proto->write_delay); +if(0)printf("%sFlushDel %p\n",KERN_DEBUG, &proto->write_delay); S_flush (&proto->write_delay); proto->qptr = NULL; diff --git a/ksupport/streamlib.c b/ksupport/streamlib.c index 7150c93..9713eae 100644 --- a/ksupport/streamlib.c +++ b/ksupport/streamlib.c @@ -176,7 +176,7 @@ mblk_t *pullupm(mblk_t *p_msg, short length) return NULL; #ifdef CONFIG_DEBUG_STREAMS - if(msgdsize(p_msg) < 0) + if(deb_msgdsize(deb_file,deb_line,p_msg) < 0) return NULL; #endif while(p_msg != NULL && p_msg->b_rptr >= p_msg->b_wptr && p_msg->b_cont != NULL) { @@ -270,7 +270,7 @@ putbqf (queue_t * q, mblk_t * mp) qflag = q->q_flag; q->q_flag |= QENAB; #ifdef CONFIG_DEBUG_STREAMS - if(0)printf(KERN_DEBUG "PutBQF %p:%p at %s:%d\n",q,mp,deb_file,deb_line); + if(0)printf("%sPutBQF %p:%p at %s:%d\n",KERN_DEBUG,q,mp,deb_file,deb_line); deb_putbq (deb_file,deb_line, q, mp); #else putbq (q, mp); @@ -652,12 +652,21 @@ m_putx (mblk_t * mb, ulong_t id) +void +m_getnskip (mblk_t * mb) +{ + if (mb == NULL) + return; + while ((mb->b_rptr < mb->b_wptr) && !isspace (*mb->b_rptr)) + mb->b_rptr++; +} + void m_getskip (mblk_t * mb) { if (mb == NULL) return; - while (mb->b_rptr < mb->b_wptr && isspace (*mb->b_rptr)) + while ((mb->b_rptr < mb->b_wptr) && isspace (*mb->b_rptr)) mb->b_rptr++; } @@ -670,12 +679,12 @@ m_getid (mblk_t * mb, ushort_t * id) #endif if (mb == NULL) - return EINVAL; + return -EINVAL; m_getskip (mb); while (mb->b_rptr < mb->b_wptr && *mb->b_rptr == ':') mb->b_rptr++; if (mb->b_rptr + sizeof(ushort_t) > mb->b_wptr) - return ESRCH; + return -ESRCH; #ifdef ALIGNED_ONLY for (i = 0; i < sizeof(ushort_t); i++) xid = xid << 8 | (*mb->b_rptr++ & 0xFF); @@ -695,23 +704,23 @@ m_getsx (mblk_t * mb, ushort_t * id) #endif if (mb == NULL) - return EINVAL; + return -EINVAL; while (1) { m_getskip (mb); - if (mb->b_rptr + sizeof(ushort_t) >= mb->b_wptr) - return ESRCH; + if (mb->b_rptr >= mb->b_wptr) + return -ESRCH; if (*mb->b_rptr == ':') { mb->b_rptr++; break; - } else { - while (mb->b_rptr + 2 < mb->b_wptr && *mb->b_rptr != ' ') - mb->b_rptr++; } + m_getnskip(mb); } if (*mb->b_rptr == ':') { mb->b_rptr++; - return EAGAIN; + return -EAGAIN; } + if (mb->b_rptr + sizeof(ushort_t) > mb->b_wptr) + return -ESRCH; #ifdef ALIGNED_ONLY for (i = 0; i < sizeof(ushort_t); i++) xid = (xid << 8) | (*mb->b_rptr++ & 0xFF); @@ -731,12 +740,12 @@ m_getlx (mblk_t * mb, ulong_t * id) #endif if (mb == NULL) - return EINVAL; + return -EINVAL; m_getskip (mb); if (*mb->b_rptr == ':') - return ENOENT; + return -ENOENT; if (mb->b_rptr + sizeof(ulong_t) > mb->b_wptr) - return ESRCH; + return -ESRCH; #ifdef ALIGNED_ONLY for (i = 0; i < sizeof(ulong_t); i++) xid = (xid << 8) | (*mb->b_rptr++ & 0xFF); @@ -755,22 +764,22 @@ m_geti (mblk_t * mb, long *id) streamchar *oldp; if (mb == NULL) - return EINVAL; + return -EINVAL; m_getskip (mb); if (mb->b_rptr >= mb->b_wptr) - return ESRCH; + return -ESRCH; if (*mb->b_rptr == '-') { neg = 1; if (++mb->b_rptr >= mb->b_wptr) - return ESRCH; + return -ESRCH; } oldp = mb->b_rptr; if (*oldp == ':') - return ENOENT; + return -ENOENT; while ((mb->b_rptr < mb->b_wptr) && (*mb->b_rptr >= '0' && *mb->b_rptr <= '9')) x = x * 10 + *mb->b_rptr++ - '0'; if (oldp == mb->b_rptr) - return ESRCH; + return -ESRCH; if (neg) *id = -x; else @@ -787,14 +796,14 @@ m_getx (mblk_t * mb, ulong_t * id) char ch; if (mb == NULL) - return EINVAL; + return -EINVAL; m_getskip (mb); if (mb->b_rptr >= mb->b_wptr) - return ESRCH; + return -ESRCH; oldp = mb->b_rptr; if (*oldp == ':') - return ENOENT; + return -ENOENT; while (ch = *mb->b_rptr, ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f'))) { if (ch <= '9') ch -= '0'; @@ -808,7 +817,7 @@ m_getx (mblk_t * mb, ulong_t * id) break; } if (oldp == mb->b_rptr) - return ESRCH; + return -ESRCH; *id = x; return 0; } @@ -821,16 +830,16 @@ m_gethex (mblk_t * mb, uchar_t * id, int len) char upper = 1; if (mb == NULL) - return EINVAL; + return -EINVAL; m_getskip (mb); if (mb->b_rptr >= mb->b_wptr) return 0; if (*mb->b_rptr == ':') - return ENOENT; + return -ENOENT; while (len > 0) { if (mb->b_rptr >= mb->b_wptr) - return EINVAL; + return -EINVAL; ch = *mb->b_rptr++; switch(ch) { @@ -903,14 +912,14 @@ m_getstr (mblk_t * mb, char *str, int maxlen) streamchar *lim; if (mb == NULL) - return EINVAL; + return -EINVAL; m_getskip (mb); if (mb->b_rptr >= mb->b_wptr) - return ESRCH; + return -ESRCH; p = mb->b_rptr; if (*p == ':') - return ENOENT; + return -ENOENT; lim = mb->b_wptr; while (!isspace (*p)) { if (maxlen == 0 || p == lim) @@ -924,28 +933,54 @@ m_getstr (mblk_t * mb, char *str, int maxlen) } +int +m_getstrlen (mblk_t * mb) +{ + streamchar *p; + streamchar *lim; + int len = 0; + + if (mb == NULL) + return -EINVAL; + m_getskip (mb); + if (mb->b_rptr >= mb->b_wptr) + return -ESRCH; + + p = mb->b_rptr; + if (*p == ':') + return -ENOENT; + lim = mb->b_wptr; + while (!isspace (*p)) { + if (p == lim) + break; + len++; + p++; + } + return len; +} + + int m_getc (mblk_t * mb, char *c) { if (mb == NULL) - return EINVAL; + return -EINVAL; m_getskip (mb); if (mb->b_rptr >= mb->b_wptr) - return ESRCH; + return -ESRCH; if (*mb->b_rptr == ':') - return ENOENT; + return -ENOENT; *c = *mb->b_rptr++; return 0; } - -void +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -deb_md_reply (const char *deb_file, unsigned int deb_line,queue_t * q, mblk_t * mb, int err) +deb_make_reply (const char *deb_file, unsigned int deb_line, int err) #else -md_reply (queue_t * q, mblk_t * mb, int err) +make_reply (int err) #endif { #ifdef CONFIG_DEBUG_STREAMS @@ -956,12 +991,11 @@ md_reply (queue_t * q, mblk_t * mb, int err) if (mq == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf("* NoMem md_reply %s:%d %d\n",deb_file,deb_line,err); + printf("* NoMem make_reply %s:%d %d\n",deb_file,deb_line,err); #else - printf("* NoMem md_reply %d\n",err); + printf("* NoMem make_reply %d\n",err); #endif - freemsg (mb); - return; + return NULL; } if (err == 0) { m_putid (mq, PROTO_NOERROR); @@ -971,8 +1005,27 @@ md_reply (queue_t * q, mblk_t * mb, int err) m_puti (mq, err); } m_putdelim (mq); - linkb (mq, mb); + return mq; +} +void +#ifdef CONFIG_DEBUG_STREAMS +deb_md_reply (const char *deb_file, unsigned int deb_line,queue_t * q, mblk_t * mb, int err) +#else +md_reply (queue_t * q, mblk_t * mb, int err) +#endif +{ +#ifdef CONFIG_DEBUG_STREAMS + mblk_t *mq = deb_make_reply(deb_file,deb_line,err); +#else + mblk_t *mq = make_reply(err); +#endif + + if (mq == NULL) { + freemsg (mb); + return; + } + linkb (mq, mb); putnext (OTHERQ (q), mq); } @@ -985,33 +1038,17 @@ m_reply (queue_t * q, mblk_t * mb, int err) #endif { #ifdef CONFIG_DEBUG_STREAMS - mblk_t *mq = deb_allocb (deb_file,deb_line,err ? 16 : 8, BPRI_HI); + mblk_t *mq = deb_make_reply(deb_file,deb_line,err); #else - mblk_t *mq = allocb (err ? 16 : 8, BPRI_HI); + mblk_t *mq = make_reply(err); #endif if (mq == NULL) { -#ifdef CONFIG_DEBUG_STREAMS - printf("* NoMem m_reply %s:%d %d\n",deb_file,deb_line,err); -#else - printf("* NoMem m_reply %d\n",err); -#endif freemsg (mb); return; } - if (err == 0) { - m_putid (mq, PROTO_NOERROR); - } else { - m_putid (mq, PROTO_ERROR); - m_putsx (mq, PROTO_ERROR); - if(err < 0) - err = -err; - m_puti (mq, err); - } - m_putdelim (mq); linkb (mq, mb); DATA_TYPE(mq) = MSG_PROTO; - putnext (OTHERQ (q), mq); } diff --git a/ksupport/x75lib.c b/ksupport/x75lib.c index 5284a64..f4a62d1 100644 --- a/ksupport/x75lib.c +++ b/ksupport/x75lib.c @@ -54,7 +54,7 @@ x75_setstate (x75 state, x75_status status) { if (state->debug & 0x02) - printf (KERN_DEBUG "x75.%d Setstate %d/%s -> %d/%s\n", state->debugnr, state->status, x75_sname[state->status], status, x75_sname[status]); + printf ("%sx75.%d Setstate %d/%s -> %d/%s\n", KERN_DEBUG,state->debugnr, state->status, x75_sname[state->status], status, x75_sname[status]); if(state->status != S_free) { state->status = status; if(state->status == S_down) @@ -73,7 +73,7 @@ x75_setstate (x75 state, x75_status status) if(state->T##xx) { \ state->T##xx = 0; \ if(state->debug & 0x08) \ - printf(KERN_DEBUG "Stop%d T"#xx" %d\n",state->debugnr,__LINE__); \ + printf("%sStop%d T"#xx" %d\n",KERN_DEBUG,state->debugnr,__LINE__); \ untimeout((void *)x75_T##xx,state); \ } splx(_ms); \ (er)=0; \ @@ -84,7 +84,7 @@ x75_setstate (x75 state, x75_status status) if(! state->T##xx) { \ state->T##xx = 1; \ if(state->debug & 0x08) \ - printf(KERN_DEBUG "Start%d T"#xx" %d %d\n",state->debugnr,state->RUN_T##xx, __LINE__); \ + printf("%sStart%d T"#xx" %d %d\n",KERN_DEBUG,state->debugnr,state->RUN_T##xx, __LINE__); \ timeout((void *)x75_T##xx,state,(state->RUN_T##xx * HZ) / 10); \ } splx(_ms); \ (er)=0; \ @@ -96,7 +96,7 @@ x75_setstate (x75 state, x75_status status) untimeout((void *)x75_T##xx,state); \ state->T##xx = 1; \ if(state->debug & 0x08) \ - printf(KERN_DEBUG "Restart%d T"#xx" %d %d\n",state->debugnr,state->RUN_T##xx, __LINE__); \ + printf("%sRestart%d T"#xx" %d %d\n",KERN_DEBUG,state->debugnr,state->RUN_T##xx, __LINE__); \ timeout((void *)x75_T##xx,state,(state->RUN_T##xx * HZ) / 10); \ splx(_ms); \ } while(0) @@ -108,7 +108,7 @@ x75_setstate (x75 state, x75_status status) if(state->T##xx) { \ state->T##xx = 0; \ if(state->debug & 0x08) \ - printf(KERN_DEBUG "Stop%d T"#xx" %d\n",state->debugnr,__LINE__); \ + printf("%sStop%d T"#xx" %d\n",KERN_DEBUG,state->debugnr,__LINE__); \ untimeout(state->timer_T##xx); \ } splx(_ms); \ (er)=0; \ @@ -119,7 +119,7 @@ x75_setstate (x75 state, x75_status status) if(! state->T##xx) { \ state->T##xx = 1; \ if(state->debug & 0x08) \ - printf(KERN_DEBUG "Start%d T"#xx" %d %d\n",state->debugnr,state->RUN_T##xx,__LINE__); \ + printf("%sStart%d T"#xx" %d %d\n",KERN_DEBUG,state->debugnr,state->RUN_T##xx,__LINE__); \ state->timer_T##xx = timeout((void *)x75_T##xx,state,(state->RUN_T##xx * HZ) / 10); \ } splx(_ms); \ (er)=0; \ @@ -131,7 +131,7 @@ x75_setstate (x75 state, x75_status status) untimeout(state->timer_T##xx); \ state->T##xx = 1; \ if(state->debug & 0x08) \ - printf(KERN_DEBUG "Restart%d T"#xx" %d %d\n",state->debugnr,state->RUN_T##xx,__LINE__); \ + printf("%sRestart%d T"#xx" %d %d\n",KERN_DEBUG,state->debugnr,state->RUN_T##xx,__LINE__); \ state->timer_T##xx = timeout((void *)x75_T##xx,state,(state->RUN_T##xx * HZ) / 10); \ splx(_ms); \ (er)=0; \ @@ -223,11 +223,11 @@ xmit3 (x75 state, char cmd, uchar_t what) int err; if (state->debug & 0x80) - printf (KERN_DEBUG "X%d%c%x ", state->debugnr, cmd ? 'c' : 'r', what); + printf ("%sX%d%c%x ", KERN_DEBUG,state->debugnr, cmd ? 'c' : 'r', what); mb = allocb (state->offset + 1, BPRI_HI); if (mb == NULL) { if(state->debug & 0x01) - printf(KERN_WARNING "NX4 NoMem "); + printf("%sNX4 NoMem ",KERN_WARNING); return -ENOENT; } mb->b_rptr += state->offset; @@ -249,11 +249,11 @@ xmit4 (x75 state, char cmd, uchar_t what1, uchar_t what2) int err; if (state->debug & 0x80) - printf (KERN_DEBUG "X%d%c%x.%x ", state->debugnr, cmd ? 'c' : 'r', what1, what2); + printf ("%sX%d%c%x.%x ", KERN_DEBUG,state->debugnr, cmd ? 'c' : 'r', what1, what2); mb = allocb (state->offset + 2, BPRI_HI); if (mb == NULL) { if(state->debug & 0x01) - printf(KERN_WARNING "NX4 NoMem "); + printf("%sNX4 NoMem ",KERN_WARNING); return -ENOENT; } mb->b_rptr += state->offset; @@ -275,7 +275,7 @@ Xestablish (x75 state, int line) int err, err2; if (state->debug & 0x10) - printf (KERN_EMERG "Establish%d %d\n", state->debugnr, line); + printf ("%sEstablish%d %d\n", KERN_EMERG,state->debugnr, line); if(state->broadcast) { return -ENXIO; } @@ -284,7 +284,7 @@ Xestablish (x75 state, int line) x75_setstate(state, S_await_up); if((state->errors += 10) >= 100) { x75_setstate(state, S_down); - printf(KERN_INFO "ERR_G 1, %d\n",state->errors); + printf("%sERR_G 1, %d\n",KERN_INFO,state->errors); state->errors = 0; msg_up (state, MDL_ERROR_IND, ERR_G); msg_up (state, DL_RELEASE_IND, 0); @@ -323,7 +323,7 @@ Xrecover_NR (x75 state, int line) if (state->flush != NULL) (*state->flush) (state->ref); - printf(KERN_INFO "ERR_J 1\n"); + printf("%sERR_J 1\n",KERN_INFO); msg_up (state, MDL_ERROR_IND, ERR_J); err = Xestablish (state, line); state->L3_req = 0; @@ -377,7 +377,7 @@ x75_T1 (x75 state) state->T1 = 0; if (state->debug & 0x10) - printf (KERN_DEBUG "T%d.1 %d RC %d\n", state->debugnr, state->status, state->RC); + printf ("%sT%d.1 %d RC %d\n", KERN_DEBUG,state->debugnr, state->status, state->RC); switch (state->status) { case S_await_up: if (state->RC != 0) { /* temporary kludge */ @@ -386,7 +386,7 @@ x75_T1 (x75 state) if(!state->wide) { #ifdef linux - printf(KERN_DEBUG "Xtimeout %ld\n",jiffies); + printf("%sXtimeout %ld\n",KERN_DEBUG,jiffies); #endif #if 0 { @@ -405,7 +405,7 @@ x75_T1 (x75 state) start_T (1, err2); } else { flush_I (state); - printf(KERN_INFO "ERR_G 2, %d\n",state->N1); + printf("%sERR_G 2, %d\n",KERN_INFO,state->N1); msg_up (state, MDL_ERROR_IND, ERR_G); msg_up (state, DL_RELEASE_IND, 0); x75_setstate(state, S_down); @@ -432,7 +432,7 @@ x75_T1 (x75 state) xmit3 (state, 1, L2_DISC | L2_PF_U); start_T (1, err2); } else { - printf(KERN_INFO "ERR_H 1\n"); + printf("%sERR_H 1\n",KERN_INFO); msg_up (state, MDL_ERROR_IND, ERR_H); msg_up (state, DL_RELEASE_CONF, 0); x75_setstate(state, S_down); @@ -444,7 +444,7 @@ x75_T1 (x75 state) state->RC++; start_T (1, err2); } else { - printf(KERN_INFO "ERR_I 1\n"); + printf("%sERR_I 1\n",KERN_INFO); msg_up (state, MDL_ERROR_IND, ERR_I); establish (state); state->L3_req = 0; @@ -465,7 +465,7 @@ x75_T3 (x75 state) { state->T3 = 0; if (state->debug & 0x10) - printf (KERN_DEBUG "T%d.3 %d\n", state->debugnr, state->status); + printf ("%sT%d.3 %d\n", KERN_DEBUG,state->debugnr, state->status); switch (state->status) { case S_up: x75_setstate(state, S_recover); @@ -529,13 +529,13 @@ x75_check_pending (x75 state, char fromLow) #if 0 /* def CONFIG_DEBUG_ISDN */ if(state->debug & 1) - printf(KERN_DEBUG "CP%d %s:%d ",state->debugnr,deb_file,deb_line); + printf("%sCP%d %s:%d ",KERN_DEBUG,state->debugnr,deb_file,deb_line); #ifdef CONFIG_DEBUG_STREAMS cS_check(deb_file,deb_line,&state->UI,NULL); #endif #else if(state->debug & 1) - printf(KERN_DEBUG "CP%d ",state->debugnr); + printf("%sCP%d ",KERN_DEBUG,state->debugnr); #endif if(state->status == S_free) @@ -556,7 +556,7 @@ x75_check_pending (x75 state, char fromLow) mb = mb2; *--mb->b_rptr = L2_UI; if (state->debug & 1) - printf (KERN_DEBUG "X%dc%x ", state->debugnr, mb->b_wptr[-1] & 0xFF); + printf ("%sX%dc%x ", KERN_DEBUG,state->debugnr, mb->b_wptr[-1] & 0xFF); if ((err = (*state->send) (state->ref, state->asBroadcast ? 3 : 1, mb)) != 0) { if (err == -EAGAIN) { /* Undo the above */ mb->b_rptr++; @@ -574,7 +574,7 @@ x75_check_pending (x75 state, char fromLow) */ if (state->status != S_up) { if(state->I.first != NULL) - printf(KERN_DEBUG "x75.%d: State %d/%s, pending\n",state->debugnr,state->status,x75_sname[state->status]); + printf("%sx75.%d: State %d/%s, pending\n",KERN_DEBUG,state->debugnr,state->status,x75_sname[state->status]); if ((state->status == S_await_up) && fromLow) { stop_T(1,err); x75_T1(state); @@ -610,11 +610,11 @@ x75_check_pending (x75 state, char fromLow) *--mb->b_rptr = state->v_r << 1; *--mb->b_rptr = state->v_s << 1; if (state->debug & 1) - printf (KERN_DEBUG "X%dc%x.%x ", state->debugnr, mb->b_rptr[0] & 0xFF, mb->b_rptr[1] & 0xFF); + printf ("%sX%dc%x.%x ", KERN_DEBUG,state->debugnr, mb->b_rptr[0] & 0xFF, mb->b_rptr[1] & 0xFF); } else { *--mb->b_rptr = (state->v_s << 1) | (state->v_r << 5); if (state->debug & 1) - printf (KERN_DEBUG "X%dc%x ", state->debugnr, mb->b_rptr[0] & 0xFF); + printf ("%sX%dc%x ", KERN_DEBUG,state->debugnr, mb->b_rptr[0] & 0xFF); } state->v_s = (state->v_s + 1) & (state->wide ? 0x7F : 0x07); if ((err = (*state->send) (state->ref, 1, mb)) != 0) { @@ -659,8 +659,8 @@ x75_check_pending (x75 state, char fromLow) err = err2; } #if 0 /* def CONFIG_DEBUG_ISDN */ - else if(did) printf(KERN_DEBUG "NX send "); - else printf(KERN_DEBUG "NX NoAckPend "); + else if(did) printf("%sNX send ",KERN_DEBUG ); + else printf("%sNX NoAckPend ",KERN_DEBUG ); #endif /* * Ugly Hack time. Continuously ask the remote side what's going on while @@ -690,7 +690,7 @@ checkV (x75 state, uchar_t n_r) if ((n_r == state->v_a) && (n_r == state->v_s)) return 1; if (state->debug & 0x08) - printf (KERN_DEBUG "Chk%d %d <= %d <= %d\n", state->debugnr, state->v_a, n_r, state->v_s); + printf ("%sChk%d %d <= %d <= %d\n",KERN_DEBUG,state->debugnr, state->v_a, n_r, state->v_s); if (state->v_a <= state->v_s) { if (state->v_a <= n_r && n_r <= state->v_s) return 1; @@ -698,7 +698,7 @@ checkV (x75 state, uchar_t n_r) if (state->v_a <= n_r || n_r <= state->v_s) return 1; } - printf (KERN_WARNING "\n*** X75-%d Sequence error: V_A %d, N_R %d, V_S %d\n", + printf ("\n%s*** X75-%d Sequence error: V_A %d, N_R %d, V_S %d\n",KERN_WARNING, state->debugnr, state->v_a, n_r, state->v_s); return 0; } @@ -723,7 +723,7 @@ pull_up (x75 state, uchar_t n_r) state->v_a = (state->v_a + 1) & (state->wide ? 0x7F : 0x07); } if (state->v_a != n_r) { - printf (KERN_WARNING "x75.%d consistency problem: v_a %d, n_r %d, v_s %d, nblk %d, firstblk %p\n", + printf ("%sx75.%d consistency problem: v_a %d, n_r %d, v_s %d, nblk %d, firstblk %p\n",KERN_WARNING, state->debugnr, state->v_a, n_r, state->v_s, state->I.nblocks, state->I.first); splx (ms); return -EFAULT; @@ -770,15 +770,15 @@ x75_recv (x75 state, char cmd, mblk_t * mb) if (state->debug & 0x80) { if (state->wide) { if ((x1 & L2_m_SU) == L2_is_U) { - printf (KERN_DEBUG "R%d%c%x ", state->debugnr, cmd ? 'c' : 'r', x1); + printf ("%sR%d%c%x ",KERN_DEBUG, state->debugnr, cmd ? 'c' : 'r', x1); } else { if (mb != NULL) - printf (KERN_DEBUG "R%d%c%x.%x ", state->debugnr, cmd ? 'c' : 'r', x1, *mb->b_rptr & 0xFF); + printf ("%sR%d%c%x.%x ", KERN_DEBUG,state->debugnr, cmd ? 'c' : 'r', x1, *mb->b_rptr & 0xFF); else - printf (KERN_DEBUG "R%d.half %x ", state->debugnr, x1); + printf ("%sR%d.half %x ",KERN_DEBUG, state->debugnr, x1); } } else { - printf (KERN_DEBUG "R%d%c%x ", state->debugnr, cmd ? 'c' : 'r', x1); + printf ("%sR%d%c%x ",KERN_DEBUG, state->debugnr, cmd ? 'c' : 'r', x1); } } mb = pullupm(mb,0); @@ -984,7 +984,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) * force-poll-while-RNR hack. Yes it _is_ * ugly. I know that. */ if (!(state->RNR && state->poll)) { - printf(KERN_INFO "ERR_A 1, RNR %d poll %d\n",state->RNR,state->poll); + printf("%sERR_A 1, RNR %d poll %d\n",KERN_INFO,state->RNR,state->poll); err2 = msg_up (state, MDL_ERROR_IND, ERR_A); if (err == 0) err = err2; @@ -1086,7 +1086,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) } else { if (pf) { if (!(state->poll && state->RNR)) { - printf(KERN_INFO "ERR_A 2\n"); + printf("%sERR_A 2\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_A); if (err == 0) err = err2; @@ -1177,7 +1177,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) } else { if (pf) { if (!(state->poll && state->RNR)) { - printf(KERN_INFO "ERR_A 3\n"); + printf("%sERR_A 3\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_A); if (err == 0) err = err2; @@ -1262,7 +1262,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) err2 = send_FRMR (state, pf, x1, x2, cmd, 1, 0, 0, 0); if (err == 0) err = err2; - printf(KERN_INFO "ERR_L 1\n"); + printf("%sERR_L 1\n",KERN_INFO); err2 = msg_up (state, MDL_ERROR_IND, ERR_L); if (err == 0) err = err2; @@ -1292,7 +1292,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) err2 = send_FRMR (state, pf, x1, 0, cmd, 1, 1, 0, 0); if (err == 0) err = err2; - printf(KERN_INFO "ERR_N 1\n"); + printf("%sERR_N 1\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_N); if (err == 0) err = err2; @@ -1300,7 +1300,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) } if ((code == L2_SABME) != (state->wide != 0)) { /* Configured extended mode, got normal mode, or vice versa */ - printf(KERN_INFO "ERR_? 1\n"); + printf("%sERR_? 1\n", KERN_INFO ); err2 = send_FRMR (state, pf, x1, 0, cmd, 1, 0, 0, 0); if (err == 0) err = err2; @@ -1357,7 +1357,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) err2 = clr_except (state); if (err == 0) err = err2; - printf(KERN_INFO "ERR_F 1\n"); + printf("%sERR_F 1\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_F); if (err == 0) err = err2; @@ -1389,7 +1389,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) err2 = send_FRMR (state, pf, x1, x2, cmd, 1, 1, 0, 0); if (err == 0) err = err2; - printf(KERN_INFO "ERR_N 2\n"); + printf("%sERR_N 2\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_N); if (err == 0) err = err2; @@ -1448,7 +1448,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) err2 = send_FRMR (state, pf, x1, x2, cmd, 1, 1, 0, 0); if (err == 0) err = err2; - printf(KERN_INFO "ERR_N 3\n"); + printf("%sERR_N 3\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_N); if (err == 0) err = err2; @@ -1494,12 +1494,12 @@ x75_recv (x75 state, char cmd, mblk_t * mb) case S_up: case S_recover: if (pf) { - printf(KERN_INFO "ERR_B 1\n"); + printf("%sERR_B 1\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_B); if (err == 0) err = err2; } else { - printf(KERN_INFO "ERR_E 1\n"); + printf("%sERR_E 1\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_E); if (err == 0) err = err2; @@ -1517,7 +1517,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) err2 = send_FRMR (state, pf, x1, x2, cmd, 1, 1, 0, 0); if (err == 0) err = err2; - printf(KERN_INFO "ERR_N\n"); + printf("%sERR_N\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_N); if (err == 0) err = err2; @@ -1527,7 +1527,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) case S_up: case S_down: case S_recover: - printf(KERN_INFO "ERR_CD 1\n"); + printf("%sERR_CD 1\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_C | ERR_D); if (err == 0) err = err2; @@ -1557,7 +1557,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) if(state->backenable) (*state->backenable) (state->ref); } else { - printf(KERN_INFO "ERR_D 1\n"); + printf("%sERR_D 1\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_D); } if (err == 0) @@ -1573,7 +1573,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) err = err2; x75_setstate(state, S_down); } else { - printf(KERN_INFO "ERR_D 2\n"); + printf("%sERR_D 2\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_D); } if (err == 0) @@ -1604,7 +1604,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) case L2_FRMR: case L2_FRMR | L2__CMD: /* technically an invalid frame, but replying with FRMR here is _bad_ */ - printf(KERN_INFO "ERR_D 3\n"); + printf("%sERR_D 3\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_D); if (err == 0) err = err2; @@ -1618,7 +1618,7 @@ x75_recv (x75 state, char cmd, mblk_t * mb) err2 = send_FRMR (state, pf, x1, x2, cmd, 1, 0, 0, 0); if (err == 0) err = err2; - printf(KERN_INFO "ERR_L 2\n"); + printf("%sERR_L 2\n",KERN_INFO ); err2 = msg_up (state, MDL_ERROR_IND, ERR_L); if (err == 0) err = err2; @@ -1660,6 +1660,8 @@ x75_send (x75 state, char isUI, mblk_t * mb) int x75_cansend (x75 state, char isUI) { + if(state->cansend != NULL) + (void)(*state->cansend) (state->ref); /* Trigger bringing L1 up */ if (isUI) return (state->I.nblocks < 3); /* arbitrary maximum */ else /* This allows us to enqueue one additional @@ -1694,11 +1696,11 @@ x75_changestate (x75 state, uchar_t ind, char isabort) #ifdef CONFIG_DEBUG_ISDN if(state->debug & 0x10) - printf(KERN_DEBUG "x75.%d: State %d/%s for ind %d %d from %s:%d\n",state->debugnr,state->status, + printf("%sx75.%d: State %d/%s for ind %d %d from %s:%d\n",KERN_DEBUG,state->debugnr,state->status, x75_sname[state->status],ind,isabort,deb_file,deb_line); #else if(state->debug & 0x10) - printf(KERN_DEBUG "x75.%d: State %d/%s for ind %d %d\n",state->debugnr,state->status, + printf("%sx75.%d: State %d/%s for ind %d %d\n",KERN_DEBUG,state->debugnr,state->status, x75_sname[state->status],ind,isabort); #endif if (isabort) @@ -1719,7 +1721,7 @@ x75_changestate (x75 state, uchar_t ind, char isabort) if (state->status == S_up || state->status == S_recover) break; /* Already established. */ if (state->debug & 0x10) - printf (KERN_DEBUG "X75%d: Forced establish.\n", state->debugnr); + printf ("%sX75%d: Forced establish.\n",KERN_DEBUG, state->debugnr); /* flush_I (state); */ state->errors = 0; if (state->status != S_down && state->status != S_free) @@ -1740,7 +1742,7 @@ x75_changestate (x75 state, uchar_t ind, char isabort) case S_down: case S_await_down: if(ind == DL_ESTABLISH_IND /* && state->UI.first == NULL && state->UI.first == NULL */ ) { - if(0)printf(KERN_DEBUG "x75.%d: DL_ESTABLISH_IND, down, nothing done\n",state->debugnr); + if(0)printf("%sx75.%d: DL_ESTABLISH_IND, down, nothing done\n",KERN_DEBUG,state->debugnr); break; } err = establish (state); @@ -1876,7 +1878,7 @@ x75_initconn (x75 state) || state->recv == NULL || state->state == NULL) return -EFAULT; - if(0)printf(KERN_DEBUG "X75 %d: Init %d %d\n",state->debugnr,state->RUN_T1,state->RUN_T3); + if(0)printf("%sX75 %d: Init %d %d\n",KERN_DEBUG,state->debugnr,state->RUN_T1,state->RUN_T3); return 0; } diff --git a/make.isdn b/make.isdn index 2ce604c..155e4a1 100755 --- a/make.isdn +++ b/make.isdn @@ -6,7 +6,7 @@ cat <<'EOF' Hi. -FÜR ABSTÜRZE, DATENVERLUST UND ÄHNLICHE PROBLEME ÜBERNEHME ICH KEINERLEI +FÜR ABSTÜRZE, DATENVERLUSTE UND ÄHNLICHE PROBLEME ÜBERNEHME ICH KEINERLEI WIE AUCH IMMER GEARTETE HAFTUNG. Wem das nicht paßt, der lösche diesen Code. Jetzt. @@ -22,15 +22,14 @@ Dann config/config.data ansehen und gegebenenfalls Dann nochmal make.isdn aufrufen. Die gebauten Module können automatisch beim Booten geladen werden; siehe -tools/rc.isdn. Dazu in /lib/modules/KERNELVERSION: modules.isdn.all nach -modules.isdn kopieren; nicht benötigte Module ggf. aus dieser Datei -rauswerfen. +tools/rc.isdn. Dazu in /lib/modules: modules.isdn.all nach modules.isdn +kopieren; nicht benötigte Module ggf. aus dieser Datei rauswerfen. EOF touch .toldem if test "$(whoami)" = "root" ; then - echo "Ach ja -- das nächste Mal: make.isdn zuerst als normaler Benutzer" - echo "starten, dann als root. Siehe DOKU." + echo "Ach ja -- make.isdn am besten zuerst als normaler Benutzer" + echo "starten (Programme bauen), dann als root (zum Installieren)." fi exit 1 fi @@ -44,13 +43,9 @@ fi VERSION=$(tools/getversion) if test "$(whoami)" = "root" ; then - dir=/lib/modules/$VERSION/isdn - if test ! -d $dir ; then mkdir -p $dir ; fi - cp /dev/null $dir/modules.isdn.all - PATH=$(pwd)/tools:$PATH make --no-print-directory load - make --no-print-directory iprog - test -f /etc/rc.d/rc.isdn || cp tools/rc.isdn /etc/rc.d/rc.isdn - set +x + make --no-print-directory all + make --no-print-directory install + if test -f /lib/modules/modules.isdn ; then echo "Ist /lib/modules/modules.isdn auf dem neuesten Stand?" else @@ -63,7 +58,6 @@ if test "$(whoami)" = "root" ; then echo "Die Treiber der Karten muessen parametrisiert werden. -> DOKU." fi else - if test ! -f .depend ; then make --no-print-directory depend ; fi make --no-print-directory all - make --no-print-directory prog + echo "Nun als Superuser bitte nochmal..." fi diff --git a/patches/biglog b/patches/biglog deleted file mode 100644 index a300367..0000000 --- a/patches/biglog +++ /dev/null @@ -1,20 +0,0 @@ -Dieser Patch vergroessert den fuer printk verwendeten Puffer. - -Es empfiehlt sich ausserdem, in syslogd.c die ewigen sync-Aufrufe zu -entfernen oder zumindest intelligenter zu gestalten, zB via Timeout. - -Optional, zum ISDN-Debuggen aber notwendig. - -Only in ./kernel: panic.o -diff -rub /pub/src/linux/kernel/linux-1.1/kernel/printk.c ./kernel/printk.c ---- /pub/src/linux/kernel/linux-1.1/kernel/printk.c Fri Jan 6 07:29:39 1995 -+++ ./kernel/printk.c Thu Jan 12 15:48:46 1995 -@@ -20,7 +20,7 @@ - #include - #include - --#define LOG_BUF_LEN 4096 -+#define LOG_BUF_LEN 40960 - - static char buf[1024]; - diff --git a/patches/debugmsg b/patches/debugmsg deleted file mode 100644 index 0edc0ce..0000000 --- a/patches/debugmsg +++ /dev/null @@ -1,158 +0,0 @@ -Dieser Patch markiert die Debuggingmeldungen, die beim Drücken der mit -show_* belegten Tasten ausgespuckt werden, als EMERGency-Meldungen. Sie -werden dann auch ausgegeben, wenn der Kernel normale Ausgaben unterdrückt -(klogd -c N, 1<=N<=7). - -Optional aber sehr sinnvoll. - -diff -rub --unidir /pub/src/linux/kernel/linux/arch/i386/kernel/process.c ./arch/i386/kernel/process.c ---- /pub/src/linux/kernel/linux/arch/i386/kernel/process.c Wed Mar 1 07:43:07 1995 -+++ ./arch/i386/kernel/process.c Wed Mar 22 15:42:43 1995 -@@ -100,13 +100,13 @@ - void show_regs(struct pt_regs * regs) - { - printk("\n"); -- printk("EIP: %04x:%08lx",0xffff & regs->cs,regs->eip); -+ printk(KERN_EMERG "EIP: %04x:%08lx",0xffff & regs->cs,regs->eip); - if (regs->cs & 3) - printk(" ESP: %04x:%08lx",0xffff & regs->ss,regs->esp); - printk(" EFLAGS: %08lx\n",regs->eflags); -- printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n", -+ printk(KERN_EMERG "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n", - regs->eax,regs->ebx,regs->ecx,regs->edx); -- printk("ESI: %08lx EDI: %08lx EBP: %08lx", -+ printk(KERN_EMERG "ESI: %08lx EDI: %08lx EBP: %08lx", - regs->esi, regs->edi, regs->ebp); - printk(" DS: %04x ES: %04x FS: %04x GS: %04x\n", - 0xffff & regs->ds,0xffff & regs->es, -diff -rub --unidir /pub/src/linux/kernel/linux/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c ---- /pub/src/linux/kernel/linux/arch/i386/kernel/traps.c Wed Feb 8 12:54:00 1995 -+++ ./arch/i386/kernel/traps.c Wed Mar 22 15:33:47 1995 -@@ -191,9 +186,9 @@ - asmlinkage void do_nmi(struct pt_regs * regs, long error_code) - { - #ifndef CONFIG_IGNORE_NMI -- printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n"); -- printk("You probably have a hardware problem with your RAM chips or a\n"); -- printk("power saving mode enabled.\n"); -+ printk(KERN_EMERG "Uhhuh. NMI received. Dazed and confused, but trying to continue\n"); -+ printk(KERN_EMERG "You probably have a hardware problem with your RAM chips or a\n"); -+ printk(KERN_EMERG "power saving mode enabled.\n"); - #endif - } - -@@ -293,8 +288,8 @@ - - asmlinkage void math_emulate(long arg) - { -- printk("math-emulation not enabled and no coprocessor found.\n"); -- printk("killing %s.\n",current->comm); -+ printk(KERN_EMERG "math-emulation not enabled and no coprocessor found.\n"); -+ printk(KERN_EMERG "killing %s.\n",current->comm); - send_sig(SIGFPE,current,1); - schedule(); - } -diff -rub --unidir /pub/src/linux/kernel/linux/arch/i386/mm/init.c ./arch/i386/mm/init.c ---- /pub/src/linux/kernel/linux/arch/i386/mm/init.c Tue Apr 4 15:17:07 1995 -+++ ./arch/i386/mm/init.c Tue Mar 28 19:02:46 1995 -@@ -79,9 +79,9 @@ - int i,free = 0,total = 0,reserved = 0; - int shared = 0; - -- printk("Mem-info:\n"); -+ printk(KERN_EMERG "Mem-info:\n"); - show_free_areas(); -- printk("Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); -+ printk(KERN_EMERG "Free swap: %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); - i = high_memory >> PAGE_SHIFT; - while (i-- > 0) { - total++; -@@ -92,10 +92,10 @@ - else - shared += mem_map[i]-1; - } -- printk("%d pages of RAM\n",total); -- printk("%d free pages\n",free); -- printk("%d reserved pages\n",reserved); -- printk("%d pages shared\n",shared); -+ printk(KERN_EMERG "%d pages of RAM\n",total); -+ printk(KERN_EMERG "%d free pages\n",free); -+ printk(KERN_EMERG "%d reserved pages\n",reserved); -+ printk(KERN_EMERG "%d pages shared\n",shared); - show_buffers(); - #ifdef CONFIG_NET - show_net_buffers(); -diff -rub --unidir /pub/src/linux/kernel/linux/fs/buffer.c ./fs/buffer.c ---- /pub/src/linux/kernel/linux/fs/buffer.c Mon Mar 6 10:22:08 1995 -+++ ./fs/buffer.c Wed Mar 22 15:41:33 1995 -@@ -1400,9 +1400,9 @@ - int shared; - int nlist, isize; - -- printk("Buffer memory: %6dkB\n",buffermem>>10); -- printk("Buffer heads: %6d\n",nr_buffer_heads); -- printk("Buffer blocks: %6d\n",nr_buffers); -+ printk(KERN_EMERG "Buffer memory: %6dkB\n",buffermem>>10); -+ printk(KERN_EMERG "Buffer heads: %6d\n",nr_buffer_heads); -+ printk(KERN_EMERG "Buffer blocks: %6d\n",nr_buffers); - - for(nlist = 0; nlist < NR_LIST; nlist++) { - shared = found = locked = dirty = used = lastused = 0; -@@ -1419,10 +1419,10 @@ - used++, lastused = found; - bh = bh->b_next_free; - } while (bh != lru_list[nlist]); -- printk("Buffer[%d] mem: %d buffers, %d used (last=%d), %d locked, %d dirty %d shrd\n", -+ printk(KERN_EMERG "Buffer[%d] mem: %d buffers, %d used (last=%d), %d locked, %d dirty %d shrd\n", - nlist, found, used, lastused, locked, dirty, shared); - }; -- printk("Size [LAV] Free Clean Unshar Lck Lck1 Dirty Shared\n"); -+ printk(KERN_EMERG "Size [LAV] Free Clean Unshar Lck Lck1 Dirty Shared\n" KERN_EMERG); - for(isize = 0; isizecomm, (p == current) ? -nr : nr); -+ printk(KERN_EMERG "%-8s %3d ", p->comm, (p == current) ? -nr : nr); - if (((unsigned) p->state) < sizeof(stat_nam)/sizeof(char *)) - printk(stat_nam[p->state]); - else -@@ -763,8 +763,8 @@ - { - int i; - -- printk(" free sibling\n"); -- printk(" task PC stack pid father child younger older\n"); -+ printk(KERN_EMERG " free sibling\n"); -+ printk(KERN_EMERG " task PC stack pid father child younger older\n"); - for (i=0 ; i -+#include -+#else -+#define MOD_INC_USE_COUNT -+#define MOD_DEC_USE_COUNT -+#endif -+ - #include - #include - #include -@@ -80,11 +88,13 @@ - * should be after the IRQ has been active. - */ - --static struct async_struct *IRQ_ports[16]; -+static struct async_struct *IRQ_ports[16] = {NULL,}; - static int IRQ_timeout[16]; -+#ifndef MODULE - static volatile int rs_irq_triggered; - static volatile int rs_triggered; - static int rs_wild_int_mask; -+#endif - - static void autoconfig(struct async_struct * info); - static void change_speed(struct async_struct *info); -@@ -343,6 +353,7 @@ - * ----------------------------------------------------------------------- - */ - -+#ifndef MODULE - /* - * This is the serial driver's interrupt routine while we are probing - * for submarines. -@@ -353,6 +364,7 @@ - rs_triggered |= 1 << irq; - return; - } -+#endif - - /* - * This routine is used by the interrupt handler to schedule -@@ -788,6 +804,7 @@ - * --------------------------------------------------------------- - */ - -+#ifndef MODULE - /* - * Grab all interrupts in preparation for doing an automatic irq - * detection. dontgrab is a mask of irq's _not_ to grab. Returns a -@@ -819,6 +836,7 @@ - free_irq(i); - } - } -+#endif - - /* - * This routine figures out the correct timeout for a particular IRQ. -@@ -1632,6 +1650,7 @@ - sti(); - } - -+#ifndef MODULE - /* - * This routine returns a bitfield of "wild interrupts". Basically, - * any unclaimed interrupts which is flapping around. -@@ -1675,6 +1694,7 @@ - restore_flags(flags); - return wild_interrupts; - } -+#endif - - static int rs_ioctl(struct tty_struct *tty, struct file * file, - unsigned int cmd, unsigned long arg) -@@ -1745,6 +1765,7 @@ - case TIOCSERCONFIG: - return do_autoconfig(info); - -+#ifndef MODULE - case TIOCSERGWILD: - error = verify_area(VERIFY_WRITE, (void *) arg, - sizeof(int)); -@@ -1752,6 +1773,7 @@ - return error; - put_fs_long(rs_wild_int_mask, (unsigned long *) arg); - return 0; -+#endif - - case TIOCSERGETLSR: /* Get line status register */ - error = verify_area(VERIFY_WRITE, (void *) arg, -@@ -1761,6 +1783,7 @@ - else - return get_lsr_info(info, (unsigned int *) arg); - -+#ifndef MODULE - case TIOCSERSWILD: - if (!suser()) - return -EPERM; -@@ -1768,6 +1791,7 @@ - if (rs_wild_int_mask < 0) - rs_wild_int_mask = check_wild_interrupts(0); - return 0; -+#endif - - case TIOCSERGSTRUCT: - error = verify_area(VERIFY_WRITE, (void *) arg, -@@ -1835,6 +1859,7 @@ - - if (tty_hung_up_p(filp)) { - restore_flags(flags); -+ MOD_DEC_USE_COUNT; - return; - } - -@@ -1860,6 +1885,7 @@ - } - if (info->count) { - restore_flags(flags); -+ MOD_DEC_USE_COUNT; - return; - } - info->flags |= ASYNC_CLOSING; -@@ -1923,6 +1949,7 @@ - ASYNC_CLOSING); - wake_up_interruptible(&info->close_wait); - restore_flags(flags); -+ MOD_DEC_USE_COUNT; - } - - /* -@@ -2097,22 +2124,27 @@ - printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line, - info->count); - #endif -+ MOD_INC_USE_COUNT; - info->count++; - tty->driver_data = info; - info->tty = tty; - - if (!tmp_buf) { - tmp_buf = (unsigned char *) get_free_page(GFP_KERNEL); -- if (!tmp_buf) -+ if (!tmp_buf) { -+ MOD_DEC_USE_COUNT; - return -ENOMEM; - } -+ } - - /* - * Start up serial port - */ - retval = startup(info); -- if (retval) -+ if (retval) { -+ MOD_DEC_USE_COUNT; - return retval; -+ } - - retval = block_til_ready(tty, filp, info); - if (retval) { -@@ -2120,6 +2152,7 @@ - printk("rs_open returning after block_til_ready with %d\n", - retval); - #endif -+ MOD_DEC_USE_COUNT; - return retval; - } - -@@ -2168,6 +2201,8 @@ - #undef SERIAL_OPT - } - -+ -+#ifndef MODULE - /* - * This routine is called by do_auto_irq(); it attempts to determine - * which interrupt a serial port is configured to use. It is not -@@ -2259,6 +2294,7 @@ - free_all_interrupts(irq_lines); - return (irq_try_1 == irq_try_2) ? irq_try_1 : 0; - } -+#endif /* CONFIG_SERIAL */ - - /* - * This routine is called by rs_init() to initialize a specific serial -@@ -2322,12 +2358,14 @@ - } - } - -+#ifndef MODULE - /* - * If the AUTO_IRQ flag is set, try to do the automatic IRQ - * detection. - */ - if (info->flags & ASYNC_AUTO_IRQ) - info->irq = do_auto_irq(info); -+#endif - - serial_outp(info, UART_FCR, UART_FCR_ENABLE_FIFO); - scratch = serial_in(info, UART_IIR) >> 6; -@@ -2382,15 +2420,31 @@ - /* - * The serial driver boot-time initialization code! - */ -+#ifdef MODULE -+ -+char kernel_version[]= UTS_RELEASE; -+ -+void cleanup_module(void) -+{ -+ tty_unregister_driver(&serial_driver); -+ tty_unregister_driver(&callout_driver); -+ bh_base[SERIAL_BH].routine = NULL; -+ timer_table[RS_TIMER].fn = NULL; -+} -+ -+int init_module(void) -+#else - long rs_init(long kmem_start) -+#endif - { -- int i; -+ int i, err; - struct async_struct * info; - - bh_base[SERIAL_BH].routine = do_serial_bh; -+ enable_bh(SERIAL_BH); - timer_table[RS_TIMER].fn = rs_timer; - timer_table[RS_TIMER].expires = 0; --#ifdef CONFIG_AUTO_IRQ -+#if defined(CONFIG_AUTO_IRQ) && !defined(MODULE) - rs_wild_int_mask = check_wild_interrupts(1); - #endif - -@@ -2445,10 +2499,15 @@ - callout_driver.major = TTYAUX_MAJOR; - callout_driver.subtype = SERIAL_TYPE_CALLOUT; - -- if (tty_register_driver(&serial_driver)) -- panic("Couldn't register serial driver\n"); -- if (tty_register_driver(&callout_driver)) -- panic("Couldn't register callout driver\n"); -+ if ((err = tty_register_driver(&serial_driver)) < 0) { -+ printk("Couldn't register serial driver\n"); -+ return err; -+ } -+ if ((err = tty_register_driver(&callout_driver)) < 0) { -+ printk("Couldn't register callout driver\n"); -+ tty_unregister_driver(&serial_driver); -+ return err; -+ } - - for (i = 0, info = rs_table; i < NR_PORTS; i++,info++) { - info->magic = SERIAL_MAGIC; -@@ -2471,6 +2530,7 @@ - info->prev_port = 0; - if (info->irq == 2) - info->irq = 9; -+#ifndef MODULE - if (!(info->flags & ASYNC_BOOT_AUTOCONF)) - continue; - autoconfig(info); -@@ -2496,8 +2556,13 @@ - printk("\n"); - break; - } -+#endif - } -+#ifndef MODULE - return kmem_start; -+#else -+ return 0; -+#endif - } - - /* -@@ -2533,12 +2598,14 @@ - "device already open\n", i, req->port, req->irq); - return -1; - } -+ MOD_INC_USE_COUNT; - info->irq = req->irq; - info->port = req->port; - autoconfig(info); - if (info->type == PORT_UNKNOWN) { - restore_flags(flags); - printk("register_serial(): autoconfig failed\n"); -+ MOD_DEC_USE_COUNT; - return -1; - } - printk("tty%02d at 0x%04x (irq = %d)", info->line, -@@ -2571,4 +2638,5 @@ - info->type = PORT_UNKNOWN; - printk("tty%02d unloaded\n", info->line); - restore_flags(flags); -+ MOD_DEC_USE_COUNT; - } diff --git a/patches/more_free b/patches/more_free deleted file mode 100644 index 5216d74..0000000 --- a/patches/more_free +++ /dev/null @@ -1,18 +0,0 @@ -Fuenf freie Seiten bei starkem NFS-Traffic ist fuer ISDN viel zu wenig. - -Notwendig, wenn der ISDN-Server als NFS-Client arbeitet. - ---- /pub/src/linux/kernel/linux-1.1/mm/swap.c Fri Jan 20 00:12:16 1995 -+++ mm/swap.c Sat Jan 21 08:35:01 1995 -@@ -646,8 +652,9 @@ - priority = GFP_ATOMIC; - } - } -- reserved_pages = 5; -- if (priority != GFP_NFS) -+ if (priority == GFP_NFS) -+ reserved_pages = min_free_pages>>1; -+ else - reserved_pages = min_free_pages; - save_flags(flags); - repeat: diff --git a/patches/nm.background b/patches/nm.background deleted file mode 100644 index 8d727d3..0000000 --- a/patches/nm.background +++ /dev/null @@ -1,15 +0,0 @@ -NM beim Kernelbauen kann ruhig im Hintergrund laufen, wenn man genug -Hauptspeicher hat... - -diff -rub --unidir /pub/src/linux/kernel/linux/Makefile ./Makefile ---- /pub/src/linux/kernel/linux/Makefile Tue Apr 4 15:19:12 1995 -+++ ./Makefile Tue Apr 4 11:34:33 1995 -@@ -125,7 +125,7 @@ - $(FILESYSTEMS) \ - $(DRIVERS) \ - $(LIBS) -o vmlinux -- $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | sort > System.map -+ $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | sort > System.map & - - symlinks: - rm -f include/asm diff --git a/patches/panicreboot b/patches/panicreboot deleted file mode 100644 index 1876400..0000000 --- a/patches/panicreboot +++ /dev/null @@ -1,120 +0,0 @@ -Dieser Patch loest eienen Reboot-nach-Panic aus, damit ein Server -unbeaufsichtigt neustarten kann. - -Optional. - - -diff -rub --unidir /pub/src/linux/kernel/linux/kernel/panic.c ./kernel/panic.c ---- /pub/src/linux/kernel/linux/kernel/panic.c Wed Mar 1 12:31:54 1995 -+++ ./kernel/panic.c Fri Mar 3 05:32:15 1995 -@@ -13,20 +13,38 @@ - #include - #include - -+#include -+ - asmlinkage void sys_sync(void); /* it's really int */ -+extern void hard_reset_now(void); -+ -+int in_panic = 0; - - NORET_TYPE void panic(const char * fmt, ...) - { - static char buf[1024]; - va_list args; - -+ cli(); -+ - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); -+ -+ if(!in_panic++) { - printk(KERN_EMERG "Kernel panic: %s\n",buf); -+ *((char *)0)=0; -+ } -+ -+#if 0 - if (current == task[0]) - printk(KERN_EMERG "In swapper task - not syncing\n"); - else - sys_sync(); -- for(;;); -+#endif -+ { -+ int i,j; -+ for(i=0;i<300;i++) for(j=0;j<1000;j++) udelay(1000); -+ } -+ hard_reset_now(); - } -diff -rub --unidir /pub/src/linux/kernel/linux/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c ---- /pub/src/linux/kernel/linux/arch/i386/kernel/traps.c Wed Feb 8 12:54:00 1995 -+++ ./arch/i386/kernel/traps.c Wed Mar 22 15:33:47 1995 -@@ -100,6 +100,7 @@ - unsigned short ss; - unsigned long *stack, addr, module_start, module_end; - extern char start_kernel, etext; -+ extern int in_panic; - - esp = (unsigned long) ®s->esp; - ss = KERNEL_DS; -@@ -109,29 +110,27 @@ - esp = regs->esp; - ss = regs->ss; - } -- console_verbose(); -- printk("%s: %04lx\n", str, err & 0xffff); -- printk("EIP: %04x:%08lx\nEFLAGS: %08lx\n", 0xffff & regs->cs,regs->eip,regs->eflags); -- printk("eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", -+ console_verbose(); cli(); -+ printk("\n" KERN_EMERG "%s: %04lx ", str, err & 0xffff); -+ printk(KERN_EMERG "EIP: %04x:%08lx EFLAGS: %08lx\n", 0xffff & regs->cs,regs->eip,regs->eflags); -+ printk(KERN_EMERG "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", - regs->eax, regs->ebx, regs->ecx, regs->edx); -- printk("esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", -+ printk(KERN_EMERG "esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", - regs->esi, regs->edi, regs->ebp, esp); -- printk("ds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n", -+ printk(KERN_EMERG "ds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n", - regs->ds, regs->es, regs->fs, regs->gs, ss); - store_TR(i); - if (STACK_MAGIC != *(unsigned long *)current->kernel_stack_page) -- printk("Corrupted stack page\n"); -- printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)\nStack: ", -+ printk(KERN_EMERG "Corrupted stack page; "); -+ printk(KERN_EMERG "Process %s (pid: %d, process nr: %d, stackpage=%08lx)\nStack: ", - current->comm, current->pid, 0xffff & i, current->kernel_stack_page); - stack = (unsigned long *) esp; - for(i=0; i < kstack_depth_to_print; i++) { - if (((long) stack & 4095) == 0) - break; -- if (i && ((i % 8) == 0)) -- printk("\n "); -- printk("%08lx ", get_seg_long(ss,stack++)); -+ printk("%lx ", get_seg_long(ss,stack++)); - } -- printk("\nCall Trace: "); -+ printk("\n" KERN_EMERG "Call Trace: "); - stack = (unsigned long *) esp; - i = 1; - module_start = ((high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)); -@@ -149,16 +148,12 @@ - if (((addr >= (unsigned long) &start_kernel) && - (addr <= (unsigned long) &etext)) || - ((addr >= module_start) && (addr <= module_end))) { -- if (i && ((i % 8) == 0)) -- printk("\n "); -- printk("%08lx ", addr); -+ printk("%lx ", addr); - i++; - } - } -- printk("\nCode: "); -- for(i=0;i<20;i++) -- printk("%02x ",0xff & get_seg_byte(regs->cs,(i+(char *)regs->eip))); -- printk("\n"); -+ in_panic++; -+ panic("Crash"); - do_exit(SIGSEGV); - } - diff --git a/patches/setnoswap b/patches/setnoswap deleted file mode 100644 index d618e7f..0000000 --- a/patches/setnoswap +++ /dev/null @@ -1,21 +0,0 @@ -Dieser "Hack"-Patch ermoeglicht es einem Prozess, sich im Speicher zu -verewigen... - -Notwendig, wenn der ISDN-Server auch noch was anderes zu tun hat. -Das Standardinterface fuer solche Faelle (mlockall() oder so) existiert -leider noch nicht. - -diff -rub --unidir /pub/src/linux/kernel/linux/kernel/sys.c ./kernel/sys.c ---- /pub/src/linux/kernel/linux/kernel/sys.c Sat Mar 4 23:16:36 1995 -+++ ./kernel/sys.c Wed Mar 8 05:38:27 1995 -@@ -146,6 +146,10 @@ - { - if (!suser()) - return -EPERM; -+ if(magic == 0xfee1dead && magic_too == 0x17392634) { -+ current->mm->swappable = flag ? 0 : 1; -+ return 0; -+ } - if (magic != 0xfee1dead || magic_too != 672274793) - return -EINVAL; - if (flag == 0x01234567) diff --git a/patches/symbols b/patches/symbols deleted file mode 100644 index 4c7f058..0000000 --- a/patches/symbols +++ /dev/null @@ -1,70 +0,0 @@ -Einige zusaetzliche Symbole fuer kernel/swap.c. - -Notwendig. - -diff -rub --unidir /pub/src/linux/kernel/linux/include/linux/time.h ./include/linux/time.h ---- /pub/src/linux/kernel/linux/include/linux/time.h Wed Feb 1 08:19:36 1995 -+++ ./include/linux/time.h Fri Mar 3 05:32:13 1995 -@@ -43,4 +43,10 @@ - struct timeval it_value; /* current value */ - }; - -+#ifdef __KERNEL__ -+ -+void do_gettimeofday(struct timeval *tv); -+ -+#endif /* __KERNEL__ */ -+ - #endif -diff -rub --unidir /pub/src/linux/kernel/linux/include/linux/tty.h ./include/linux/tty.h ---- /pub/src/linux/kernel/linux/include/linux/tty.h Sun Feb 26 15:45:26 1995 -+++ ./include/linux/tty.h Fri Mar 3 05:32:13 1995 -@@ -293,6 +293,7 @@ - extern void stop_tty(struct tty_struct * tty); - extern void start_tty(struct tty_struct * tty); - extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); -+extern int tty_unregister_ldisc(int disc, struct tty_ldisc *new_ldisc); - extern int tty_register_driver(struct tty_driver *driver); - extern int tty_unregister_driver(struct tty_driver *driver); - extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, -diff -rub --unidir /pub/src/linux/kernel/linux/kernel/ksyms.c ./kernel/ksyms.c ---- /pub/src/linux/kernel/linux/kernel/ksyms.c Tue Apr 4 15:18:53 1995 -+++ ./kernel/ksyms.c Tue Mar 28 19:04:11 1995 -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -174,8 +181,13 @@ - X(get_blkfops), - - /* Module creation of serial units */ -+#ifdef CONFIG_SERIAL - X(register_serial), - X(unregister_serial), -+#endif -+ X(do_SAK), -+ X(ldiscs), -+ X(bh_base), - - /* tty routines */ - X(tty_hangup), -@@ -190,6 +202,7 @@ - /* executable format registration */ - X(register_binfmt), - X(unregister_binfmt), -+ X(start_thread), - - /* execution environment registration */ - X(lookup_exec_domain), -@@ -247,6 +260,7 @@ - X(simple_strtoul), - X(system_utsname), - X(sys_call_table), -+ X(do_gettimeofday), - - /* Signal interfaces */ - X(do_signal), diff --git a/pr_on/Makefile b/pr_on/Makefile index ff0453b..59a3139 100644 --- a/pr_on/Makefile +++ b/pr_on/Makefile @@ -1,47 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ @@ @@ -I../include >()= -CFLAGS = -O2 -Wall -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include - -## =()@>()= -SYS = linux - -SOURCES = pr_on.c - -OBJ = pr_on.o -ALL = - -all: $(OBJ) - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -clean: - rm -f $(OBJ) $(ALL) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -load: - insmod pr_on.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/rate/Makefile b/rate/Makefile index f817465..59a3139 100644 --- a/rate/Makefile +++ b/rate/Makefile @@ -1,47 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux - -SOURCES = rate.c - -OBJ = rate.o -ALL = - -all: $(OBJ) $(ALL) - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -clean: - rm -f $(OBJ) $(ALL) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -load: - insmod rate.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/reconnect/Makefile b/reconnect/Makefile index e035741..59a3139 100644 --- a/reconnect/Makefile +++ b/reconnect/Makefile @@ -1,47 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux - -SOURCES = reconnect.c - -OBJ = reconnect.o -ALL = - -all: $(OBJ) $(ALL) - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -clean: - rm -f $(OBJ) $(ALL) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -load: - insmod reconnect.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/str_if/Makefile b/str_if/Makefile index 77aee69..8b0ad26 100644 --- a/str_if/Makefile +++ b/str_if/Makefile @@ -1,73 +1,11 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +TOPDIR=.. +include $(TOPDIR)/Make.config -## =()@>()= -CC = gcc -## =()@>()= -CCU = gcc -## =()@ @@ -I../include>()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@ -I../include>()= -DEFSN = -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -I../include -## =()@ $(DEFSN)>()= -CFLAGSN = -O2 -Wall $(DEFSN) -## =()@>()= -LDFLAGS = -v -## =()@>()= -STR_IN = str_linux -## =()@>()= -LIBS = -lbsd +REALSOURCE = $(addsuffix .c,$(STR_IF)) -## =()@>()= -SYS = linux +OBJS=str_if.o +KERNEL=1 +SUBDIRS=tools -SOURCES = ${STR_IN}.c slipto.c - -OBJ = str_if.o ${STR_IN}.o -ALL = slipto - -all: str_if.o -prog: slipto - -slipto: slipto.o ../support.a - $(CCU) $(LDFLAGS) -o $@ $^ ${LIBS} - -../support.a: - cd ../support; make lib - -slipto.o: slipto.c - $(CCU) $(CFLAGSN) -c slipto.c - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -clean: - rm -f $(ALL) $(OBJ) slipto.old - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -str_if.o: ${STR_IN}.o - @-rm str_if.o 2>/dev/null - @ln ${STR_IN}.o str_if.o - -load: - insmod str_if.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +include $(TOPDIR)/Make.rules diff --git a/str_if/slipto.c.orig b/str_if/slipto.c.orig deleted file mode 100644 index c5465f3..0000000 --- a/str_if/slipto.c.orig +++ /dev/null @@ -1,711 +0,0 @@ -#ifdef linux -#define INET_BSD -#include -#ifdef CONFIG_INET_BSD -#define SOCK_HAS_LEN -#else -#define SET_STEP -#define ROUTE_IF -#endif -#include -#endif -#include "primitives.h" -#include -#include -#include -#include -#include "f_ioctl.h" -#include "f_ip.h" -#include -#include -#include "f_termio.h" -#include -#include -#include -#include -#ifdef CONFIG_INET_BSD -#include -#include -#else -#include -#endif -#include -#ifdef SYSV -#include -#endif -#include -#include -#include -#ifdef AUX -#include -#endif -#include - -#include "str_if.h" -#include "sioctl.h" - -void -xquit (const char *s) -{ - syslog (LOG_WARNING, "%s: %m", s ? s : "(NULL)"); - exit (3); -} - -void -squit (int sig) -{ - syslog (LOG_INFO, "Sig %d", sig); - xquit (NULL); -} - -void -quit (void) -{ - xquit ("Trouble"); -} - -struct hostent * -host_name (const char *name) -{ - struct hostent *h = gethostbyname (name); - - if (h == NULL) { - static struct hostent def; - static struct in_addr defaddr; - static char *alist[1]; - static char namebuf[128]; - - defaddr.s_addr = inet_addr (name); - if (defaddr.s_addr == -1) - return NULL; - strcpy (namebuf, name); - def.h_name = namebuf; - def.h_addr_list = alist, def.h_addr = (char *) &defaddr; - def.h_length = sizeof (struct in_addr); - - def.h_addrtype = AF_INET; - def.h_aliases = 0; - h = &def; - } - return h; -} - -static char ifname[IFNAMSIZ]; -static int s; -int devfd = 0; -char *dev = NULL; - -char makeroute[2000], unmakeroute[2000]; - -ushort_t id = 0; -long ich = 0, du = 0, mask = 0; -char *ichaddr, *duaddr; -int islinked = 0; -int ifflags = IFF_UP|IFF_POINTOPOINT; -int mtu = 0; - -char *destaddr[20]; -char **destxaddr = destaddr; - -char *desthaddr[20]; -char **desthxaddr = desthaddr; - -void -enable (void) -{ - int xid; - - if (islinked) - return; - -#ifdef SIOCGIFNAME - if(ioctl(devfd,SIOCGIFNAME,&ifname) >= 0) - xid = atoi(strpbrk(ifname,"0123456789")); - else -#endif -#ifdef SIOCGETU - if (sioctl (devfd, SIOCGETU, &xid) >= 0) - sprintf (ifname, "str%d", xid); - else -#endif -#ifdef SLIOCGUNIT - if(ioctl(devfd,SLIOCGUNIT,&xid) >= 0) - sprintf (ifname, "str%d", xid); - else -#endif - xquit ("GetU"); - id = xid; - - syslog(LOG_DEBUG,"Setting up IF %s",ifname); - if(makeroute[0]=='\0') { - struct hostent *h; - char **y; - - if ((h = host_name (ichaddr)) == NULL) - xquit (ichaddr); - ich = *(long *) h->h_addr; - if ((h = host_name (duaddr)) == NULL) - xquit (duaddr); - du = *(long *) h->h_addr; - - makeroute[0]='\0'; -#if 0 - sprintf(makeroute+strlen(makeroute),"set -xv; exec >>/tmp/sll 2>&1 >/tmp/sll 2>&1 0) { - ifr.ifr_mtu = mtu; - if (ioctl (s, SIOCSIFMTU, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCSIFMTU): %m"); - quit (); - } - } - } -#endif - { - struct ifreq ifr; - - strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); - ifr.ifr_addr.sa_family = AF_INET; -#ifdef SOCK_HAS_LEN - ifr.ifr_addr.sa_len = sizeof(struct sockaddr_in); -#endif - if (ioctl (s, SIOCGIFADDR, (caddr_t) & ifr) < 0) { - if(errno != EADDRNOTAVAIL) { - syslog (LOG_ERR, "ioctl (SIOCGIFADDR): %m"); - quit (); - } - } else { -#ifndef SET_STEP - if (ioctl (s, SIOCDIFADDR, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCDIFADDR): %m"); - quit (); - } -#endif - } - - } -#ifdef SET_STEP - { - struct ifreq ifr; - - strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); - ifr.ifr_addr.sa_family = AF_INET; -#ifdef SOCK_HAS_LEN - ifr.ifr_addr.sa_len = sizeof(struct sockaddr_in); -#endif - ((struct sockaddr_in *) & ifr.ifr_dstaddr)->sin_addr.s_addr = ich; - if (ioctl(s, SIOCSIFADDR, &ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCSIFADDR %d.%d.%d.%d %d.%d.%d.%d): %m", - ((uchar_t *)&ich)[0], ((uchar_t *)&ich)[1], ((uchar_t *)&ich)[2], ((uchar_t *)&ich)[3], - ((uchar_t *)&du )[0], ((uchar_t *)&du )[1], ((uchar_t *)&du )[2], ((uchar_t *)&du )[3]); - quit(); - } - - ifr.ifr_addr.sa_family = AF_INET; -#ifdef SOCK_HAS_LEN - ifr.ifr_addr.sa_len = sizeof(struct sockaddr_in); -#endif - ((struct sockaddr_in *) & ifr.ifr_dstaddr)->sin_addr.s_addr = du; - if (ioctl(s, SIOCSIFDSTADDR, &ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCSIFDSTADDR %d.%d.%d.%d %d.%d.%d.%d): %m", - ((uchar_t *)&ich)[0], ((uchar_t *)&ich)[1], ((uchar_t *)&ich)[2], ((uchar_t *)&ich)[3], - ((uchar_t *)&du )[0], ((uchar_t *)&du )[1], ((uchar_t *)&du )[2], ((uchar_t *)&du )[3]); - quit(); - } - - if (mask != 0) { - ifr.ifr_addr.sa_family = AF_INET; -#ifdef SOCK_HAS_LEN - ifr.ifr_addr.sa_len = sizeof(struct sockaddr_in); -#endif - ((struct sockaddr_in *) & ifr.ifr_netmask)->sin_addr.s_addr = mask; - if (ioctl(s, SIOCSIFNETMASK, &ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCSIFNETMASK): %m"); - quit(); - } - } - } - { - struct ifreq ifr; - - strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); - if (ioctl (s, SIOCGIFFLAGS, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); - quit (); - } - ifr.ifr_flags |= ifflags; - if (ioctl (s, SIOCSIFFLAGS, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCSIFFLAGS): %m"); - quit (); - } - if(mtu > 0) { - ifr.ifr_mtu = mtu; - if (ioctl (s, SIOCSIFMTU, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCSIFMTU): %m"); - quit (); - } - } - } -#else - { - struct ifaliasreq ifr; - - bzero ((char *) &ifr, sizeof (ifr)); - strncpy (ifr.ifra_name, ifname, sizeof (ifr.ifra_name)); - - ifr.ifra_addr.sa_family = AF_INET; -#ifdef SOCK_HAS_LEN - ifr.ifra_addr.sa_len = sizeof(struct sockaddr_in); -#endif - ((struct sockaddr_in *) & ifr.ifra_addr)->sin_addr.s_addr = ich; - - ifr.ifra_dstaddr.sa_family = AF_INET; -#ifdef SOCK_HAS_LEN - ifr.ifra_dstaddr.sa_len = sizeof(struct sockaddr_in); -#endif - ((struct sockaddr_in *) & ifr.ifra_dstaddr)->sin_addr.s_addr = du; - - if (mask != 0) { - - /* ifr.ifra_mask.sa_family = AF_INET; */ -#ifdef SOCK_HAS_LEN - ifr.ifra_mask.sa_len = sizeof(struct sockaddr_in); -#endif - ((struct sockaddr_in *) & ifr.ifra_mask)->sin_addr.s_addr = mask; - - if (ioctl (s, SIOCAIFADDR, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCAIFADDR %d.%d.%d.%d %d.%d.%d.%d): %m", - ((uchar_t *)&ich)[0], ((uchar_t *)&ich)[1], ((uchar_t *)&ich)[2], ((uchar_t *)&ich)[3], - ((uchar_t *)&du )[0], ((uchar_t *)&du )[1], ((uchar_t *)&du)[2], ((uchar_t *)&du )[3]); - xquit ("Dead"); - } - } - } -#endif - - islinked = 1; - if(fork() == 0) { - signal(SIGCHLD,SIG_DFL); - execl("/bin/sh","sh","-c",makeroute,NULL); - /* system (makeroute); */ - } -} - -void -disable (void) -{ - if (!islinked) - return; - - syslog(LOG_DEBUG,"Taking down IF %s",ifname); - if(fork() == 0) { - signal(SIGCHLD,SIG_DFL); - execl("/bin/sh","sh","-c",unmakeroute,NULL); - } - { - struct ifreq ifr; - - strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); - if (ioctl (s, SIOCGIFFLAGS, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); - quit (); - } - ifr.ifr_flags &= ~IFF_UP; - if (ioctl (s, SIOCSIFFLAGS, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCSIFFLAGS): %m"); - quit (); - } - - strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); - ifr.ifr_addr.sa_family = AF_INET; -#ifdef SOCK_HAS_LEN - ifr.ifr_addr.sa_len = sizeof(struct sockaddr_in); -#endif - if (ioctl (s, SIOCGIFADDR, (caddr_t) & ifr) < 0) { - if(errno != EADDRNOTAVAIL) - syslog (LOG_ERR, "ioctl (SIOCGIFADDR): %m"); - } else { -#ifndef SET_STEP - if (ioctl (s, SIOCDIFADDR, (caddr_t) & ifr) < 0) { - syslog (LOG_ERR, "ioctl(SIOCDIFADDR): %m"); - quit (); - } -#endif - } - } - - islinked = 0; -} - -void -disableq (void) -{ - disable (); - syslog(LOG_INFO,"Exit DisableQ"); - exit (0); -} - -void -sigon (void) -{ - syslog (LOG_INFO, "Sig USR1"); - enable (); -} - -void -sigoff (void) -{ - syslog (LOG_INFO, "Sig USR2"); - disable (); -} - -int -main (int argc, char *argv[]) -{ - extern char *optarg; - extern int optind; - char *progname = *argv; - int pid = getpid (); - int dodial = 0, domon = 0, dovanj = 0, dofakeh = 0, dolog = 0, dologmodem = 0, - docount = 0, doqinfo = 0, noslip = 0, doenable = 0; - int speed = 0; - -#ifdef AUX - setcompat (COMPAT_BSD); -#endif - alarm(0); - - openlog (progname, LOG_PID|LOG_PERROR, LOG_LOCAL7); - - signal (SIGUSR1, (sigfunc__t) enable); - signal (SIGUSR2, (sigfunc__t) disable); - signal (SIGPWR, (sigfunc__t) disable); - signal (SIGHUP, (sigfunc__t) disableq); - signal (SIGINT, (sigfunc__t) disableq); - signal (SIGTERM, (sigfunc__t) disableq); - signal (SIGQUIT, (sigfunc__t) disableq); - signal (SIGCHLD, SIG_IGN); - signal (SIGTTOU, SIG_IGN); - - while ((s = getopt (argc, argv, "dr:R:lEMm:vfLop:s:S")) != EOF) - switch (s) { - case 'S': - noslip = 1; - break; - case 's': - speed = atoi(optarg); - break; - case 'l': - dolog ++; - break; - case 'L': - dologmodem = 1; - break; - case 'E': - doenable = 1; - break; - case 'm': - mtu = atoi(optarg); - break; - case 'M': - domon = 1; - break; - case 'f': - dofakeh = 1; - break; - case 'v': - dovanj = 1; - break; - case 'o': - dodial = 1; - break; - case 'p': - dev = optarg; - break; - case 'd': - *destxaddr++ = "default"; - break; - case 'R': - *desthxaddr++ = optarg; - break; - case 'r': - *destxaddr++ = optarg; - break; - case '?': - default: - usage: - fprintf (stderr, "Usage: %s [-d {-r route}... -p device -o -l -m -v ] from to\n", progname); - syslog(LOG_ERR,"Usage!"); - exit (99); - } - - argv += optind; - argc -= optind; - if (argc != 2) - goto usage; - - ichaddr = *argv++; - duaddr = *argv++; - - if ((s = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) - xquit ("socket"); - - if (dev != NULL) { - if (dodial) - if ((devfd = open ("/dev/tty", O_RDWR)) >= 0) { -#ifdef TIOCNOTTY - (void) ioctl (devfd, TIOCNOTTY, 0); -#endif - close (devfd); - } - if ((devfd = open (dev, O_RDWR)) < 0) { - syslog (LOG_ERR,"%s: %m",dev); - exit (1); - } { - struct termios ts; - -#ifdef UIOCFLOW - ioctl(devfd,UIOCFLOW,0); -#endif -#ifdef UIOCMODEM - ioctl(devfd,UIOCMODEM,0); -#endif - if (ioctl (devfd, TCGETS, &ts) == 0) { - int i; - long ocflag = ts.c_cflag; - for(i = 0; i < NCCS; i++) - ts.c_cc[i] = '\0'; - ts.c_cc[VMIN] = 1; - ts.c_cc[VTIME] = 0; - ts.c_iflag = (BRKINT); - ts.c_oflag = (0); - ts.c_lflag = (0); - ts.c_cflag = (CRTSCTS|HUPCL|CREAD|CS8); - if(speed == 0) - ts.c_cflag |= ocflag&CBAUD; - else { - cfsetispeed(&ts,speed); - cfsetospeed(&ts,speed); - } - if (ioctl (devfd, TCSETSF, &ts) != 0) { - syslog (LOG_ERR,"%s TCSETSF: %m",dev); - exit (1); - } - } - } - if (dodial) { - ioctl (devfd, I_PUSH, "strlog"); - write (devfd, "AT&L1A\r", 7); - sleep (1); - ioctl (devfd, TCFLSH, 0); - ioctl (devfd, I_FLUSH, FLUSHR); - dor: - { - char c; - - if (read (devfd, &c, 1) != 1) - syslog (LOG_ERR,"read: %m"); - if (c == '\r' || c == '\n') - goto dor; - if (c != 'C') { - syslog (LOG_ERR,"got %02x: %m",c); - exit (1); - } - } - sleep (1); - ioctl (devfd, TCFLSH, 0); - ioctl (devfd, I_FLUSH, FLUSHR); - ioctl (devfd, I_POP, NULL); - } - if(dologmodem) - if (ioctl (devfd, I_PUSH, "strlog") != 0) { - syslog (LOG_ERR,"strlog %m"); - exit (1); - } - if(!noslip) { - if (ioctl (devfd, I_PUSH, "slip") != 0) { - if(0)syslog (LOG_ERR,"slip: %m"); - } - } - } - if(dolog) { - doqinfo++; dolog--; - } - if(dolog) { - docount++; dolog--; - } - if (dolog) { - --dolog; - if (ioctl (devfd, I_PUSH, "strlog") != 0) { - syslog (LOG_ERR,"strlog: %m"); - exit (1); - } - } - if (dofakeh) { - if (ioctl (devfd, I_PUSH, "fakeh") != 0) { - syslog (LOG_ERR,"fakeh: %m"); - exit (1); - } - } - if (dovanj) { - if (ioctl (devfd, I_PUSH, "van_j") < 0) { -#ifdef SIOCSIFENCAP - int i = SL_MODE_CSLIP|SL_OPT_ADAPTIVE; - ioctl(devfd,SIOCSIFENCAP,&i); -#endif -#ifdef SC_COMPRESS - ifflags |= SC_COMPRESS; -#endif - } - } - if (dolog) { - --dolog; - if (ioctl (devfd, I_PUSH, "strlog") != 0) { - syslog (LOG_ERR,"strlog: %m"); - exit (1); - } - } - if (domon) - if (ioctl (devfd, I_PUSH, "ip_mon") != 0) { - syslog (LOG_ERR,"ip_mon: %m"); - exit (1); - } - if (dolog) { - --dolog; - if (ioctl (devfd, I_PUSH, "strlog") != 0) { - syslog (LOG_ERR,"strlog: %m"); - exit (1); - } - } - if (docount) - if (ioctl (devfd, I_PUSH, "count") != 0) { - syslog (LOG_ERR,"count: %m"); - exit (1); - } - if(doqinfo) - if (ioctl (devfd, I_PUSH, "qinfo") != 0) { - syslog (LOG_ERR,"qinfo: %m"); - exit (1); - } - if(dev != NULL) { - if (ioctl (devfd, I_PUSH, "str_if") != 0) { - int oerrno = errno; - int disc = N_SLIP; - - if(ioctl(devfd,TIOCSETD,&disc) < 0) { - syslog (LOG_ERR,"str_if: %m"); - errno = oerrno; - syslog (LOG_ERR,"str_if: %m"); - exit (1); - } - } - if (ioctl (devfd, I_PUSH, "strlog") != 0) { - syslog (LOG_ERR,"strlog: %m"); - } - if (ioctl (devfd, I_PUSH, "pr_on") != 0) { - syslog (LOG_ERR,"pr_on: %m"); - } - if (0) { - if (ioctl (devfd, I_PUSH, "strlog") != 0) { - syslog (LOG_ERR,"strlog: %m"); - exit (1); - } - } - } - if(dev != NULL || doenable) - enable (); - -#ifdef HAVE_SETPGRP_2 - setpgrp (0, pid); -#endif -#ifdef HAVE_SETPGRP_0 - setpgrp(); -#endif -#ifdef TIOCSPGRP - (void) ioctl (0, TIOCSPGRP, &pid); -#endif - - alarm(0); - for (;;) { - char c; - int i = read (devfd, &c, 1); - int oerrno; - - switch (i) { - case -1: - oerrno = errno; - syslog (LOG_DEBUG, "Driver: %m"); - if (oerrno != EAGAIN && oerrno != EINTR) { - if(oerrno == EIO) pause(); - goto Out; - } - break; - case 0: - goto Out; - default: - syslog (LOG_DEBUG, "Got Data %02x from driver -- down?", c); - (void) ioctl(devfd,I_FLUSH,FLUSHR); - } - } - /* At this point, we have decided to shut down */ - Out: - syslog (LOG_DEBUG, "Terminating"); - disable(); - exit(1); -} diff --git a/str_if/str_if.h b/str_if/str_if.h index 9b6c982..30f2de3 100644 --- a/str_if/str_if.h +++ b/str_if/str_if.h @@ -10,10 +10,7 @@ #endif #define STRIF_MTU CHAR2('m','t') - -#define STRIF_PPP CHAR2('p','p') -#define STRIF_NOPPP CHAR2('n','p') - +#define STRIF_ETHERTYPE CHAR2('e','T') #endif /* _STR_IF_H */ diff --git a/str_if/str_linux.c b/str_if/str_linux.c index 8f24f9a..5751bbf 100644 --- a/str_if/str_linux.c +++ b/str_if/str_linux.c @@ -90,6 +90,7 @@ #include #include #include +#include "kernel.h" #ifdef CONFIG_DEBUG_STREAMS int strl_debug = 1; @@ -103,6 +104,7 @@ struct strl_local { struct enet_statistics stats; queue_t *q; short offset; + unsigned short ethertype; #if 0 #ifdef NEW_TIMEOUT long timer; @@ -144,7 +146,9 @@ strl_header(struct sk_buff *skb, struct device *dev, unsigned short type, #if LINUX_VERSION_CODE < 66304 /* 1.3.0 */ static unsigned short strl_type_trans (struct sk_buff *skb, struct device *dev) { - return htons(ETH_P_IP); + struct strl_local *lp = (struct strl_local *)dev->priv; + + return lp->ethertype; } #endif @@ -194,6 +198,14 @@ printk("Q NULL\n"); return -ENXIO; } +#if LINUX_VERSION_CODE >= 66304 /* 1.3.0 */ + if(!lp->encap && (skb->protocol != lp->ethertype)) { + lp->stats.tx_dropped++; + dev_kfree_skb (skb, FREE_WRITE); + return 0; + } +#endif + if(!canput(WR(lp->q)->q_next)) { /* printk("Queue full\n"); */ dev->tbusy = 1; @@ -217,7 +229,7 @@ printk("No Buff\n"); #if LINUX_VERSION_CODE >= 66304 /* 1.3.0 */ *(ushort_t *)mb->b_rptr = skb->protocol; #else - *(ushort_t *)mb->b_rptr = htons(ETH_P_IP); + *(ushort_t *)mb->b_rptr = lp->ethertype; #endif else if(lp->encap == ENCAP_PPP) { #if LINUX_VERSION_CODE >= 66304 /* 1.3.0 */ @@ -371,6 +383,11 @@ str_if_proto (queue_t * q, mblk_t * mp, char isdown) goto err; case PROTO_MODULE: break; + case STRIF_ETHERTYPE: + if ((error = m_getx (mp, &z)) != 0) + goto err; + lp->ethertype = z; + break; case STRIF_MTU: if ((error = m_geti (mp, &z)) != 0) goto err; @@ -379,12 +396,18 @@ str_if_proto (queue_t * q, mblk_t * mp, char isdown) dev->mtu = z; break; case PROTO_TYPE_NONE: + if((lp->encap != ENCAP_NONE) && (lp->offset >= 2)) + lp->offset -= 2; lp->encap = ENCAP_NONE; break; case PROTO_TYPE_ETHER: + if(lp->encap == ENCAP_NONE) + lp->offset += 2; lp->encap = ENCAP_ETHER; break; case PROTO_TYPE_PPP: + if(lp->encap == ENCAP_NONE) + lp->offset += 2; lp->encap = ENCAP_PPP; break; } @@ -491,6 +514,7 @@ str_if_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) netdev->mtu = 1500; netdev->family = AF_INET; netdev->pa_alen = sizeof(unsigned long); + lp->ethertype = htons(ETH_P_IP); lp->q = q; WR (q)->q_ptr = q->q_ptr = (caddr_t) netdev; @@ -673,7 +697,7 @@ str_if_rsrv (queue_t *q) struct device *dev = (struct device *)q->q_ptr; struct strl_local *lp = (struct strl_local *)dev->priv; - ushort_t encap = htons(ETH_P_IP); + ushort_t encap = lp->ethertype; while ((mp = getq (q)) != NULL) { switch (DATA_TYPE(mp)) { @@ -709,7 +733,7 @@ str_if_rsrv (queue_t *q) skb = alloc_skb(len, GFP_ATOMIC); if (skb == NULL) { - printk(KERN_INFO "%s: Memory squeeze, dropping packet.\n", dev->name); + printk("%s%s: Memory squeeze, dropping packet.\n", KERN_INFO,dev->name); lp->stats.rx_dropped++; putbqf(q,mp); return; diff --git a/str_if/tools/Makefile b/str_if/tools/Makefile new file mode 100644 index 0000000..7433de3 --- /dev/null +++ b/str_if/tools/Makefile @@ -0,0 +1,7 @@ +PROGRAMS = slipto +EXTRA_INCLUDES = -I.. +EXTRA_LIBS=../../support.a + +TOPDIR=../.. +include $(TOPDIR)/Make.rules + diff --git a/str_if/slipto.c b/str_if/tools/slipto.c similarity index 100% rename from str_if/slipto.c rename to str_if/tools/slipto.c diff --git a/streams/Makefile b/streams/Makefile index 4c706c8..2d8199c 100644 --- a/streams/Makefile +++ b/streams/Makefile @@ -1,56 +1,16 @@ -## Makefile for cStreams support -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +all:: -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@>()= -LD = ld - -## =()@>()= -SYS = linux - -SOURCES = streams_sys.c streams_io.c -OBJ = streams_sys.o streams_io.o -ALL = streams.o - -all: ${ALL} - -lib: - -install: all - # @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - # @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -clean: - rm -f sys linux - rm -f $(ALL) $(OBJ) - # @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -depend: Makefile $(SOURCES) +depend:: rm -f sys linux ln -s . linux ln -s . sys - $(CC) -M $(DEFS) $(SOURCES) > .depend -load: - insmod streams.o +KERNEL=1 +OBJ = streams.o -streams.o: $(OBJ) - $(LD) -r -o streams.o $(OBJ) +TOPDIR=.. +include $(TOPDIR)/Make.rules -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +clean:: + rm -f sys linux diff --git a/streams/log/Makefile b/streams/log/Makefile deleted file mode 100644 index 7b1ddd8..0000000 --- a/streams/log/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -# Makefile for the log Streams driver. -# -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# - -.c.s: - $(CC) $(CFLAGS) -S $< -.s.o: - $(AS) -c -o $*.o $< -.c.o: - $(CC) $(CFLAGS) -c $< - -SUBDIRS= - -OBJS = log.o - -all: log.a - -log.a: $(OBJS) - @$(LD) -r -o log.a $(OBJS) - -#subdirs: dummy -# @for i in $(SUBDIRS); do (cd $$i && echo $$i && $(MAKE)) || exit; done - -clean: - rm -f core *.o *.a *.s -# for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done - -dep: - $(CPP) -M $(KEYBOARD) *.c > .depend -# for i in $(SUBDIRS); do (cd $$i && $(MAKE) dep) || exit; done - -dummy: - -# -# include a dependency file if one exists -# -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/streams/log/log.c b/streams/log/log.c deleted file mode 100644 index c03ab24..0000000 --- a/streams/log/log.c +++ /dev/null @@ -1,383 +0,0 @@ - -/* Streams logging module */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "log.h" - -#define MAXB 100 - -static struct module_info log_minfo = -{ - 0, "strlog", 0, INFPSZ, 0, 0 -}; - -static int log_open (), log_close (); -static int log_wput (), log_rput (); - -static struct qinit log_rinit = -{ - log_rput, NULL, log_open, log_close, NULL, &log_minfo, NULL -}; - -static struct qinit log_winit = -{ - log_wput, NULL, NULL, NULL, NULL, &log_minfo, NULL -}; - -struct streamtab log_info = -{&log_rinit, &log_winit, NULL, NULL}; - -#define NLOG 10 -static struct log { - char flags; - char nr; -} log_log[NLOG]; - -static int log_cnt = NLOG; - - -static int -log_open (queue_t * q, int dev, int flag, int sflag -#ifdef DO_ADDERROR - ,int *err -#endif -) -{ - struct log *log; - -#ifdef DO_STREAMDEBUG - logme (); -#endif - if (q->q_ptr) { - if (0) - printf ("Log: already open?\n"); - return 0; - } - for (dev = 0; dev < log_cnt; dev++) { - if (!(log_log[dev].flags & LOG_INUSE)) - break; - } - - if (dev >= log_cnt) { - printf ("log: all %d devices allocated\n", log_cnt); - return OPENFAIL; - } - log = &log_log[dev]; - WR (q)->q_ptr = (char *) log; - q->q_ptr = (char *) log; - - log->flags = LOG_INUSE | LOG_READ | LOG_WRITE; - log->nr = minor (dev); - if (1) - printf ("Log driver %d opened.\n", dev); - - return 0; -} - - -#if 0 -void -log_printtcp (struct log *log, mblk_t * mp, char wr) -{ - register struct ip *ip; - register uint_t hlen; - register struct tcphdr *oth; - register struct tcphdr *th; - - register mblk_t *mq = dupmsg (mp); - - if (wr) - wr = 'w'; - else - wr = 'r'; - - mp = pullup (mq, 128); - if (mp == NULL) { - freemsg (mq); - printf ("Log%cN %d ", wr); - return; - } - ip = (struct ip *) mp->b_rptr; - hlen = ip->ip_hl; - - - if (ip->ip_p != IPPROTO_TCP - || (ip->ip_off & htons (0x3fff)) || mq->b_wptr - mq->b_rptr < 40) { - freemsg (mp); - printf ("Log%cT %x", wr, ip->ip_p); - return; - } - th = (struct tcphdr *) & ((unchar *) ip)[hlen << 2]; - if (wr == 'w') { - printf ("TCP %x.%x ", th->th_seq, dsize (mp) - th->th_off); - } else { - printf ("TCP %x ", th->th_ack); - } - freemsg (mp); -} - -#endif - -void -log_printmsg (struct log *log, const char *text, mblk_t * mp) -{ - int ms = splstr (); - -#ifdef DO_STREAMDEBUG - logme (); -#endif - if (log != NULL) { -#if 0 - if (log - log_log != 0 && DATA_TYPE(mp) == M_DATA) - return; -#endif - printf ("Log %d: ", log - log_log); - } - printf ("%s", text); - - { - mblk_t *mp1; - char *name; - int nblocks = 0; - static mblk_t *blocks[MAXB]; - - for (mp1 = mp; mp1 != NULL; mp1 = mp1->b_cont) { - blocks[nblocks++] = mp1; - switch (DATA_TYPE(mp1)) { - case M_DATA: - name = "DATA"; - break; - case M_PROTO: - name = "PROTO"; - break; -#ifdef M_SPROTO - case M_SPROTO: - name = "SPROTO"; - break; -#endif - case M_BREAK: - name = "BREAK"; - break; - case M_SIG: - name = "SIG"; - break; - case M_DELAY: - name = "DELAY"; - break; - case M_CTL: - name = "CTL"; - break; - case M_IOCTL: - name = "IOCTL"; - break; - case M_SETOPTS: - name = "SETOPTS"; - break; -#ifdef M_ADMIN - case M_ADMIN: - name = "ADMIN"; - break; -#endif -#ifdef M_EXPROTO - case M_EXPROTO: - name = "EXPROTO"; - break; -#endif -#ifdef M_EXDATA - case M_EXDATA: - name = "EXDATA"; - break; -#endif -#ifdef M_EXSPROTO - case M_EXSPROTO: - name = "EXSPROTO"; - break; -#endif -#ifdef M_EXSIG - case M_EXSIG: - name = "EXSIG"; - break; -#endif -#ifdef M_PCPROTO - case M_PCPROTO: - name = "PCPROTO"; - break; -#endif -#ifdef M_PKT - case M_PKT: - name = "PKT"; - break; -#endif -#ifdef M_PKTSTOP - case M_PKTSTOP: - name = "PKTSTOP"; - break; -#endif - case M_IOCACK: - name = "IOCACK"; - break; - case M_IOCNAK: - name = "IOCNAK"; - break; - case M_PCSIG: - name = "PCSIG"; - break; - case M_FLUSH: - name = "FLUSH"; - break; - case M_STOP: - name = "STOP"; - break; - case M_START: - name = "START"; - break; - case M_HANGUP: - name = "HANGUP"; - break; - case M_ERROR: - name = "ERROR"; - break; -#ifdef _MSG_PROTO_OWN -#ifdef MSG_PROTO - case MSG_PROTO: - name = "MSGPROTO"; - break; -#endif -#endif - default: - printf (":%d:", DATA_TYPE(mp1)); - name = "unknown"; /* ,DATA_TYPE(mp)); */ - break; - } - printf ("; %s: %x.%x.%d", name, mp1, DATA_BLOCK(mp1), mp1->b_wptr - mp1->b_rptr); - if (nblocks == MAXB) { - printf ("\n*** Block 0x%x pointed to 0x%x", mp1, mp1->b_cont); - mp1->b_cont = NULL; - } else { - int j; - - for (j = 0; j < nblocks; j++) { - if (mp1->b_cont == blocks[j]) { - printf ("\n*** Block 0x%x circled to 0x%x (%d)", mp1, mp1->b_cont, j); - mp1->b_cont = NULL; - } - } - } - } - } - printf ("\n"); - { - int j; - mblk_t *mp1; - const char ctab[]= "0123456789abcdef"; - -#define BLOCKSIZE 0x10 - for (j = 0, mp1 = mp; mp1 != NULL; mp1 = mp1->b_cont, j++) { - int i; - unchar *dp; - unchar x; - - for (i = 0, dp = (unchar *) mp1->b_rptr; dp < (unchar *) mp1->b_wptr; dp += BLOCKSIZE) { - int k; - int l = (unchar *) mp1->b_wptr - dp; - - printf (" "); - for (k = 0; k < BLOCKSIZE && k < l; k++) - printf ("%c%c ", ctab[dp[k] >> 4], ctab[dp[k] & 0x0F]); - for (; k < BLOCKSIZE; k++) - printf (" "); - printf (" : "); - for (k = 0; k < BLOCKSIZE && k < l; k++) - if (dp[k] > 31 && dp[k] < 127) - printf ("%c", dp[k]); - else - printf ("."); - if (k < l) - printf (" +\n"); - else if (mp1->b_cont != NULL) { - for (; k < BLOCKSIZE; k++) - printf (" "); - printf (" -\n"); - } else - printf ("\n"); - } - } - } - splx (ms); -} - -static int -log_wput (queue_t * q, mblk_t * mp) -{ - register struct log *log; - -#ifdef DO_STREAMDEBUG - logme (); -#endif - log = (struct log *) q->q_ptr; - - if (log->flags & LOG_WRITE) { -#if 0 - if (*mp->b_rptr == 0x45) - log_printtcp (log, mp, 1); - else -#endif - log_printmsg (log, "write", mp); - switch (DATA_TYPE(mp)) { - default:{ - break; - } - } - } - putnext (q, mp); - return 0; -} - -static int -log_rput (queue_t * q, mblk_t * mp) -{ - register struct log *log; - -#ifdef DO_STREAMDEBUG - logme (); -#endif - log = (struct log *) q->q_ptr; - - if (log->flags & LOG_READ) { -#if 0 - if (*mp->b_rptr == 0x45) - log_printtcp (log, mp, 0); - else -#endif - log_printmsg (log, "read", mp); - } - putnext (q, mp); - return 0; -} - - -static int -log_close (queue_t * q) -{ - struct log *log; - -#ifdef DO_STREAMDEBUG - logme (); -#endif - log = (struct log *) q->q_ptr; - - flushq (q, FLUSHALL); - flushq (WR (q), FLUSHALL); - if (1) - printf ("Log driver %d closed.\n", log->nr); - log->flags = 0; - return 0; -} diff --git a/streams/log/log.h b/streams/log/log.h deleted file mode 100644 index 3a46d6f..0000000 --- a/streams/log/log.h +++ /dev/null @@ -1,3 +0,0 @@ -#define LOG_INUSE 01 -#define LOG_WRITE 02 -#define LOG_READ 04 diff --git a/streams/loop/Makefile b/streams/loop/Makefile index 08927f4..4e101b1 100644 --- a/streams/loop/Makefile +++ b/streams/loop/Makefile @@ -1,43 +1,8 @@ -# -# Makefile for the loop Streams driver. -# -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -.c.s: - $(CC) $(CFLAGS) -S $< -.s.o: - $(AS) -c -o $*.o $< -.c.o: - $(CC) $(CFLAGS) -c $< +all:: -SUBDIRS= +KERNEL=1 -OBJS = loop.o +TOPDIR=../.. +include $(TOPDIR)/Make.rules -all: loop.a - -loop.a: $(OBJS) - @$(LD) -r -o loop.a $(OBJS) - -#subdirs: dummy -# @for i in $(SUBDIRS); do (cd $$i && echo $$i && $(MAKE)) || exit; done - -clean: - rm -f core *.o *.a *.s -# for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done - -dep: - $(CPP) -M $(KEYBOARD) *.c > .depend -# for i in $(SUBDIRS); do (cd $$i && $(MAKE) dep) || exit; done - -dummy: - -# -# include a dependency file if one exists -# -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/streams/streams_io.c b/streams/streams_io.c index 66f778e..633d935 100644 --- a/streams/streams_io.c +++ b/streams/streams_io.c @@ -47,6 +47,8 @@ static void stream_rput (queue_t *, mblk_t *); static void stream_wsrv (queue_t *); static void stream_rsrv (queue_t *); +int fasync_helper(struct inode * inode, struct file * filp, int on, struct fasync_struct **fapp); + static struct stream_header *first_stream = NULL; /** * streams_open @@ -937,15 +939,15 @@ static int xstream_write(struct stream_header *p_stream, int fromuser, const cha if (p_msg != NULL) { if (p_stream->flag & (SF_MSGDISCARD | SF_MSGKEEP)) { freemsg (p_msg); - printk(KERN_DEBUG "ExWrite 8\n"); + printk("%sExWrite 8\n",KERN_DEBUG ); return -ENOSR; } else { putq (p_stream->write_queue, p_msg); - printk(KERN_DEBUG "ExWriteS %d\n",bytes); + printk("%sExWriteS %d\n",KERN_DEBUG,bytes); return bytes; } } else { - printk(KERN_DEBUG "ExWrite 9\n"); + printk("%sExWrite 9\n",KERN_DEBUG ); return -ENOSR; } } @@ -971,7 +973,7 @@ static int xstream_write(struct stream_header *p_stream, int fromuser, const cha } if(bytes <= 0) - printk(KERN_DEBUG "ExWriteT %d\n",bytes); + printk("%sExWriteT %d\n",KERN_DEBUG,bytes); return bytes; } @@ -982,19 +984,19 @@ streams_write (struct inode *inode, struct file *file, const char *buf, int coun unsigned long s; if ((p_stream = (struct stream_header *)inode->u.generic_ip) == NULL) { - printk(KERN_DEBUG "ExWrite 7\n"); + printk("%sExWrite 7\n",KERN_DEBUG ); return -ENXIO; } if(p_stream->magic != STREAM_MAGIC) { - printk(KERN_DEBUG "ExWrite 8\n"); + printk("%sExWrite 8\n",KERN_DEBUG ); return -EIO; } if (p_stream->error < 0) { - printk(KERN_DEBUG "ExWrite 5\n"); + printk("%sExWrite 5\n",KERN_DEBUG ); return p_stream->error; } else if (p_stream->flag & SF_HANGUP) { - printk(KERN_DEBUG "ExWrite 6\n"); + printk("%sExWrite 6\n",KERN_DEBUG ); return -ENXIO; } /* @@ -1006,7 +1008,7 @@ streams_write (struct inode *inode, struct file *file, const char *buf, int coun while (!canput (p_stream->write_queue)) { if (file->f_mode & O_NDELAY) { splx(s); - printk(KERN_DEBUG "ExWrite 1\n"); + printk("%sExWrite 1\n",KERN_DEBUG ); return -EAGAIN; } @@ -1014,17 +1016,17 @@ streams_write (struct inode *inode, struct file *file, const char *buf, int coun if (p_stream->error < 0) { splx(s); - printk(KERN_DEBUG "ExWrite 3\n"); + printk("%sExWrite 3\n",KERN_DEBUG ); return p_stream->error; } if (p_stream->flag & SF_HANGUP) { splx(s); - printk(KERN_DEBUG "ExWrite 4\n"); + printk("%sExWrite 4\n",KERN_DEBUG ); return -ENXIO; } if (current->signal & ~current->blocked) { splx(s); - printk(KERN_DEBUG "ExWrite 2\n"); + printk("%sExWrite 2\n",KERN_DEBUG ); return -ERESTARTSYS; } } @@ -1070,10 +1072,10 @@ stream_wsrv (queue_t * p_queue) */ #ifdef CONFIG_DEBUG_STREAMS -#define do_ioctl(a,b) deb_do_ioctl(__FILE__,__LINE__,a,b) -int deb_do_ioctl (const char *deb_file, unsigned int deb_line, struct stream_header *p_stream, struct strioctl *strioctl_pb) +#define do_ioctl(a,b,c) deb_do_ioctl(__FILE__,__LINE__,(a),(b),(c)) +int deb_do_ioctl (const char *deb_file, unsigned int deb_line, struct stream_header *p_stream, struct strioctl *strioctl_pb, unsigned long cmd) #else -int do_ioctl (struct stream_header *p_stream, struct strioctl *strioctl_pb) +int do_ioctl (struct stream_header *p_stream, struct strioctl *strioctl_pb, unsigned long cmd) #endif { mblk_t *p_msg; @@ -1099,7 +1101,7 @@ int do_ioctl (struct stream_header *p_stream, struct strioctl *strioctl_pb) /* * Send down data, if any. */ - if (ioctl_pb->ioc_count && (ioctl_pb->ioc_cmd & IOC_IN)) { + if (ioctl_pb->ioc_count && (cmd & IOC_IN)) { mblk_t *p_cont = allocb (ioctl_pb->ioc_count, BPRI_HI); if (p_cont == NULL) { @@ -1213,7 +1215,7 @@ int do_ioctl (struct stream_header *p_stream, struct strioctl *strioctl_pb) /* * Data returned? */ - if ((ioctl_pb->ioc_cmd & IOC_OUT) && ioctl_pb->ioc_count) { + if ((cmd & IOC_OUT) && ioctl_pb->ioc_count) { int count; char *arg = strioctl_pb->ic_dp; @@ -1279,7 +1281,7 @@ xstreams_ioctl (struct stream_header *p_stream, unsigned int cmd, unsigned long case TCSETSW: case TCSETSF: strioc.ic_len = sizeof(struct termios); - strioc.ic_cmd |= IOC_IN; + cmd |= IOC_IN; goto doit; #endif #ifdef TCSETA @@ -1287,25 +1289,25 @@ xstreams_ioctl (struct stream_header *p_stream, unsigned int cmd, unsigned long case TCSETAW: case TCSETAF: strioc.ic_len = sizeof(struct termio); - strioc.ic_cmd |= IOC_IN; + cmd |= IOC_IN; goto doit; #endif #ifdef TCGETS case TCGETS: strioc.ic_len = sizeof(struct termios); - strioc.ic_cmd |= IOC_OUT; + cmd |= IOC_OUT; goto doit; #endif #ifdef TCGETA case TCGETA: strioc.ic_len = sizeof(struct termio); - strioc.ic_cmd |= IOC_OUT; + cmd |= IOC_OUT; goto doit; #endif #ifdef UIOCTTSTAT case UIOCTTSTAT: strioc.ic_len = 3; - strioc.ic_cmd |= IOC_OUT; + cmd |= IOC_OUT; goto doit; #endif default: @@ -1323,11 +1325,13 @@ xstreams_ioctl (struct stream_header *p_stream, unsigned int cmd, unsigned long if (strioc.ic_len < 0 || strioc.ic_timout < TIMEOUT_INFINITE) return -EINVAL; + cmd = strioc.ic_cmd; + do_strioctl: if (p_stream->flag & SF_HANGUP) return -ENXIO; - error = do_ioctl (p_stream, &strioc); + error = do_ioctl (p_stream, &strioc, cmd); if(cmd == I_STR) memcpy_tofs ((caddr_t) arg, &strioc, sizeof (struct strioctl)); @@ -1521,7 +1525,7 @@ static int streams_select(struct inode *inode, struct file *file, int sel_type, if (inode == NULL || (p_stream = (struct stream_header *)inode->u.generic_ip) == NULL || p_stream->magic != STREAM_MAGIC) { #if 0 /* def CONFIG_DEBUG_STREAMS */ - printf(KERN_EMERG "STREAMS SELECT inode %p, file %p, selTable %p!\n",inode,file,wait); + printf("%sSTREAMS SELECT inode %p, file %p, selTable %p!\n",KERN_EMERG,inode,file,wait); sysdump(NULL,NULL,0xdeadbeef); #endif return 1; diff --git a/streams/streams_sys.c b/streams/streams_sys.c index 2d18d4a..7d369c2 100644 --- a/streams/streams_sys.c +++ b/streams/streams_sys.c @@ -25,10 +25,15 @@ #include #include #include +#else +unsigned long bh_mask; #endif +#include "kernel.h" #ifdef linux +#ifdef __KERNEL__ #include +#endif #include #ifdef SK_STREAM #include @@ -102,7 +107,7 @@ __res;}) long module_start, module_end; extern char start_kernel, etext; - printk(KERN_EMERG "Stackback of %d in %s! Call Trace: ",str, current->comm); + printk("%sStackback of %d in %s! Call Trace: ",KERN_EMERG,str, current->comm); module_start = ((high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)); module_end = module_start + MODULE_RANGE; while (((long) stack & 4095) != 0) { @@ -161,7 +166,7 @@ mblk_t * allocb(ushort size, ushort pri) #ifdef SK_STREAM skb = alloc_skb(size,GFP_ATOMIC); if(skb == NULL) { - printf(KERN_WARNING "Couldn't allocate %d bytes (Streams SKB)\n",size); + printf("%sCouldn't allocate %d bytes (Streams SKB)\n",KERN_WARNING,size); return NULL; } #else @@ -171,7 +176,7 @@ mblk_t * allocb(ushort size, ushort pri) p_data = (struct datab *) kmalloc(size + sizeof(struct datab), GFP_ATOMIC); #endif if(p_data == NULL) { - printf(KERN_WARNING "Couldn't allocate %d bytes (Streams Data)\n",size+sizeof(struct datab)); + printf("%sCouldn't allocate %d bytes (Streams Data)\n",KERN_WARNING,size+sizeof(struct datab)); return NULL; } #endif @@ -187,7 +192,7 @@ mblk_t * allocb(ushort size, ushort pri) #else kfree_s(p_data,sizeof(struct msgb)); #endif - printf(KERN_WARNING "Couldn't allocate %d bytes (Streams Msg)\n",sizeof(struct msgb)); + printf("%sCouldn't allocate %d bytes (Streams Msg)\n",KERN_WARNING,sizeof(struct msgb)); return NULL; } p_msg->b_next = p_msg->b_prev = p_msg->b_cont = NULL; @@ -235,7 +240,7 @@ void freeb(mblk_t *p_msg) if (p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Freeing NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sFreeing NULL msg at %s:%d\n",KERN_ERR,deb_file,deb_line); #endif return; } @@ -394,7 +399,7 @@ void freeq(queue_t *p_queue) { if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Freeing NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sFreeing NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return; } @@ -428,7 +433,7 @@ void freemsg(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Freeing NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sFreeing NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return; } @@ -457,7 +462,7 @@ mblk_t *dupb(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Dup'ing NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sDup'ing NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -497,7 +502,7 @@ mblk_t *dupmsg(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Dup'ing NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sDup'ing NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -535,7 +540,7 @@ mblk_t *copyb(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Copying NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sCopying NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -570,7 +575,7 @@ mblk_t *copymsg(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Copying NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sCopying NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -606,7 +611,7 @@ mblk_t *copybufb(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Copying NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sCopying NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -642,7 +647,7 @@ mblk_t *copybufmsg(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Copying NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sCopying NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -701,13 +706,13 @@ mblk_t *rmvb(mblk_t *p_msg, mblk_t *p_block) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Removing NULL msga at %s:%d\n",deb_file,deb_line); + printf("%sRemoving NULL msga at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } if(p_block == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Removing NULL msgb at %s:%d\n",deb_file,deb_line); + printf("%sRemoving NULL msgb at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -717,7 +722,7 @@ mblk_t *rmvb(mblk_t *p_msg, mblk_t *p_block) else do { if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Block not in message at %s:%d\n",deb_file,deb_line); + printf("%sBlock not in message at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } else if(p_msg->b_cont == p_block) { @@ -748,7 +753,7 @@ int pullupmsg(mblk_t *p_msg, short length) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Pullup NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sPullup NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return 0; } @@ -834,7 +839,7 @@ int adjmsg(mblk_t *p_msg, short length) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Adjust NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sAdjust NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return 0; } @@ -897,7 +902,7 @@ int xmsgsize(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "XMsgSize of NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sXMsgSize of NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return 0; } @@ -949,7 +954,7 @@ int msgdsize(mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "MsgDSize of NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sMsgDSize of NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif traceback(0); return -EFAULT; @@ -1186,7 +1191,7 @@ mblk_t *getq(queue_t *p_queue) if (p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Get from NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sGet from NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -1195,7 +1200,7 @@ mblk_t *getq(queue_t *p_queue) #if defined(CONFIG_DEBUG_STREAMS) && defined(CONFIG_MALLOC_NAMES) && defined(__KERNEL__) deb_kcheck_s(deb_file,deb_line, RDQ(p_queue),2*sizeof(*p_queue)); #endif -if(0)printf(KERN_ERR "G %s:%d ",deb_file,deb_line); +if(0)printf("%sG %s:%d ",KERN_ERR ,deb_file,deb_line); if ((p_msg = p_queue->q_first) == NULL) p_queue->q_flag |= QWANTR; else { @@ -1209,12 +1214,12 @@ if(0)printf(KERN_ERR "G %s:%d ",deb_file,deb_line); rmv_post(p_queue,p_msg); #ifdef CONFIG_DEBUG_STREAMS if (p_msg->b_rptr == NULL) { - printf(KERN_ERR "GetQ NULL stream/rptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sGetQ NULL stream/rptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); p_msg = NULL; } if (p_msg->b_wptr == NULL) { - printf(KERN_ERR "GetQ NULL stream/wptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sGetQ NULL stream/wptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); p_msg = NULL; } @@ -1261,13 +1266,13 @@ void rmvq(queue_t *p_queue, mblk_t *p_msg) if (p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Rmv NULL msg from queue at %s:%d\n",deb_file,deb_line); + printf("%sRmv NULL msg from queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return ; } if (p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Rmv msg from NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sRmv msg from NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return ; } @@ -1335,7 +1340,7 @@ void flushq(queue_t *p_queue, int flag) if (p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Flush NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sFlush NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return ; } @@ -1394,11 +1399,11 @@ int canput(queue_t *p_queue) { if (p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Queue NULL in canput at %s:%d\n",deb_file,deb_line); + printf("%sQueue NULL in canput at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return 0; } -if(0)printf(KERN_ERR "P %s:%d ",deb_file,deb_line); +if(0)printf("%sP %s:%d ",KERN_ERR ,deb_file,deb_line); while (p_queue->q_next != NULL && p_queue->q_qinfo->qi_srvp == NULL) p_queue = p_queue->q_next; if (p_queue->q_flag & QFULL) { @@ -1431,25 +1436,25 @@ void putq(queue_t *p_queue, mblk_t *p_msg) if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Putting NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sPutting NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return; } if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Putting on NULL stream at %s:%d\n",deb_file,deb_line); + printf("%sPutting on NULL stream at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif freemsg(p_msg); return; } #ifdef CONFIG_DEBUG_STREAMS if (p_msg->b_rptr == NULL) { - printf(KERN_ERR "PutQ NULL stream/rptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sPutQ NULL stream/rptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); return; } if (p_msg->b_wptr == NULL) { - printf(KERN_ERR "PutQ NULL stream/wptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sPutQ NULL stream/wptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); return; } @@ -1462,7 +1467,7 @@ void putq(queue_t *p_queue, mblk_t *p_msg) deb_kcheck(deb_file,deb_line,p_msg->b_datap); #endif #endif -if(0)printf(KERN_ERR "P %s:%d ",deb_file,deb_line); +if(0)printf("%sP %s:%d ",KERN_ERR ,deb_file,deb_line); s = splstr(); if (p_queue->q_first == NULL) { @@ -1516,25 +1521,25 @@ void putbq(queue_t *p_queue, mblk_t *p_msg) if (p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "PutBack msg to NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sPutBack msg to NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return ; } if (p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "PutBack NULL msg to queue at %s:%d\n",deb_file,deb_line); + printf("%sPutBack NULL msg to queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif freemsg(p_msg); return ; } #ifdef CONFIG_DEBUG_STREAMS if (p_msg->b_rptr == NULL) { - printf(KERN_ERR "PutBQ NULL stream/rptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sPutBQ NULL stream/rptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); return; } if (p_msg->b_wptr == NULL) { - printf(KERN_ERR "PutBQ NULL stream/wptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sPutBQ NULL stream/wptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); return; } @@ -1597,13 +1602,13 @@ void insq(queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) if (p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "InsQ msg to NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sInsQ msg to NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return ; } if (p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "InsQ NULL msg to queue at %s:%d\n",deb_file,deb_line); + printf("%sInsQ NULL msg to queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif freemsg(p_msg); return ; @@ -1664,25 +1669,25 @@ void appq(queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) if (p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "AppQ msg to NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sAppQ msg to NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return ; } if (p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "AppQ NULL msg to queue at %s:%d\n",deb_file,deb_line); + printf("%sAppQ NULL msg to queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif freemsg(p_msg); return ; } #ifdef CONFIG_DEBUG_STREAMS if (p_msg->b_rptr == NULL) { - printf(KERN_ERR "AppQ NULL stream/rptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sAppQ NULL stream/rptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); return; } if (p_msg->b_wptr == NULL) { - printf(KERN_ERR "AppQ NULL stream/wptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sAppQ NULL stream/wptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); return; } @@ -1784,7 +1789,7 @@ queue_t *backq(queue_t *p_queue) { if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "BackQ from NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sBackQ from NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return NULL; } @@ -1811,25 +1816,25 @@ void qreply(queue_t *p_queue, mblk_t *p_msg) { if(p_msg == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Replying with NULL msg at %s:%d\n",deb_file,deb_line); + printf("%sReplying with NULL msg at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return; } if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Replying on NULL stream at %s:%d\n",deb_file,deb_line); + printf("%sReplying on NULL stream at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif freemsg(p_msg); return; } #ifdef CONFIG_DEBUG_STREAMS if (p_msg->b_rptr == NULL) { - printf(KERN_ERR "QReply NULL stream/rptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sQReply NULL stream/rptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); return; } if (p_msg->b_wptr == NULL) { - printf(KERN_ERR "QReply NULL stream/wptr at %s:%d, last at %s:%d\n",deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); + printf("%sQReply NULL stream/wptr at %s:%d, last at %s:%d\n",KERN_ERR ,deb_file,deb_line,p_msg->deb_file,p_msg->deb_line); freemsg(p_msg); return; } @@ -1866,7 +1871,7 @@ int qsize(queue_t *p_queue) if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "SizeQ on NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sSizeQ on NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return 0; } @@ -1890,12 +1895,12 @@ void setq (queue_t * p_queue, struct qinit *read_init, struct qinit *write_init) { if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "SetQ on NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sSetQ on NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return; } #if 0 /* def CONFIG_DEBUG_STREAMS */ - printf(KERN_DEBUG "setq: Queue %p, read_init %p, write_init %p",p_queue,read_init,write_init); + printf("%ssetq: Queue %p, read_init %p, write_init %p",KERN_DEBUG ,p_queue,read_init,write_init); if(read_init) printf(", read_init.minfo %p",read_init->qi_minfo); if(read_init->qi_minfo) printf(" %s %d %d",read_init->qi_minfo->mi_idname,read_init->qi_minfo->mi_lowat,read_init->qi_minfo->mi_hiwat); if(write_init) printf(", write_init.minfo %p",write_init->qi_minfo); @@ -1932,7 +1937,7 @@ void qdetach (queue_t * p_queue, int do_close, int flag) if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Detach on NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sDetach on NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return ; } @@ -1959,7 +1964,7 @@ void qdetach (queue_t * p_queue, int do_close, int flag) #endif } if (do_close) { - printf(KERN_DEBUG "Closing %s\n", p_queue->q_qinfo->qi_minfo->mi_idname); + printf("%sClosing %s\n",KERN_DEBUG , p_queue->q_qinfo->qi_minfo->mi_idname); (*p_queue->q_qinfo->qi_qclose) (p_queue, (p_queue->q_next ? 0 : flag)); } @@ -2015,14 +2020,14 @@ int qattach (struct streamtab *qinfo, queue_t * p_queue, dev_t dev, int flag) if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "Attach on NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sAttach on NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return -EIO; } if ((p_newqueue = allocq ()) == NULL) return -ENOMEM; #if 0 /* def CONFIG_DEBUG_STREAMS */ - printf(KERN_DEBUG "qattach: info %p, oldq %p, newq %p\n",qinfo,p_queue,p_newqueue); + printf("%sqattach: info %p, oldq %p, newq %p\n",KERN_DEBUG ,qinfo,p_queue,p_newqueue); #endif s = splstr (); @@ -2046,15 +2051,15 @@ int qattach (struct streamtab *qinfo, queue_t * p_queue, dev_t dev, int flag) * Now call the new module/driver's open routine. */ #if 0 /* def CONFIG_DEBUG_STREAM */ - printf(KERN_DEBUG "CallOpen %p %p %p\n",p_newqueue,p_newqueue->q_qinfo,p_newqueue->q_qinfo->qi_qopen); + printf("%sCallOpen %p %p %p\n",KERN_DEBUG ,p_newqueue,p_newqueue->q_qinfo,p_newqueue->q_qinfo->qi_qopen); #endif if ((err = (*p_newqueue->q_qinfo->qi_qopen) (p_newqueue, dev, flag, open_mode)) < 0) { -printf(KERN_DEBUG "CallOpen %s got %d\n",p_newqueue->q_qinfo->qi_minfo->mi_idname,err); +printf("%sCallOpen %s got %d\n",KERN_DEBUG ,p_newqueue->q_qinfo->qi_minfo->mi_idname,err); qdetach (p_newqueue, 0, 0); splx (s); return err; } -printf(KERN_DEBUG "Driver %s opened\n",p_newqueue->q_qinfo->qi_minfo->mi_idname); +printf("%sDriver %s opened\n",KERN_DEBUG ,p_newqueue->q_qinfo->qi_minfo->mi_idname); splx (s); return 0; } @@ -2074,14 +2079,14 @@ void qenable(queue_t *p_queue) if(p_queue == NULL) { #ifdef CONFIG_DEBUG_STREAMS - printf(KERN_ERR "QEnable on NULL queue at %s:%d\n",deb_file,deb_line); + printf("%sQEnable on NULL queue at %s:%d\n",KERN_ERR ,deb_file,deb_line); #endif return ; } if (p_queue->q_qinfo->qi_srvp == NULL) { #ifdef CONFIG_DEBUG_STREAMS if(p_queue->q_next || !(p_queue->q_flag & QREADR)) /* not Stream head? */ - printf(KERN_ERR "QEnable on queue for %s with NULL service proc at %s:%d\n",p_queue->q_qinfo->qi_minfo->mi_idname, deb_file,deb_line); + printf("%sQEnable on queue for %s with NULL service proc at %s:%d\n",KERN_ERR ,p_queue->q_qinfo->qi_minfo->mi_idname, deb_file,deb_line); #endif return ; } @@ -2100,7 +2105,7 @@ void qenable(queue_t *p_queue) return; } } - printf(KERN_EMERG "QErr Queue not in list, from %s:%d\n",deb_file,deb_line); + printf("%sQErr Queue not in list, from %s:%d\n",KERN_EMERG ,deb_file,deb_line); #else splx(s); return; @@ -2118,7 +2123,7 @@ void qenable(queue_t *p_queue) #ifdef CONFIG_DEBUG_STREAMS else if(sched_last == NULL) { sched_first = sched_last = p_queue; - printf(KERN_EMERG "QErr Sched_First != NULL; _Last == NULL ; at %s:%d\n",deb_file,deb_line); + printf("%sQErr Sched_First != NULL; _Last == NULL ; at %s:%d\n",KERN_EMERG ,deb_file,deb_line); } #endif else @@ -2216,7 +2221,7 @@ static void do_runqueues(void *dummy) while ((p_queue = (queue_t *)sched_first) != NULL) { #ifdef CONFIG_DEBUG_STREAMS if((p_queue->q_link == NULL) != (p_queue == sched_last)) { - printf(KERN_ERR "End of Queue bad; link %p, last %p\n", + printf("%sEnd of Queue bad; link %p, last %p\n",KERN_ERR , p_queue->q_link, sched_last); #if defined(__KERNEL__) && defined(linux) sysdump(NULL,NULL,0); @@ -2229,7 +2234,7 @@ static void do_runqueues(void *dummy) sched_last = NULL; #ifdef CONFIG_DEBUG_STREAMS if(!(p_queue->q_flag & QENAB)) { - printf(KERN_ERR "Queue on list but QENAB not set for %s\n",p_queue->q_qinfo->qi_minfo->mi_idname); + printf("%sQueue on list but QENAB not set for %s\n",KERN_ERR ,p_queue->q_qinfo->qi_minfo->mi_idname); #if defined(__KERNEL__) && defined(linux) sysdump(NULL,NULL,0); #endif @@ -2245,7 +2250,7 @@ static void do_runqueues(void *dummy) (void)splstr(); if(!--cnt) { if(!looping) - printf(KERN_WARNING "Streams loop?\n"); + printf("%sStreams loop?\n",KERN_WARNING); looping++; looping++; break; } @@ -2394,7 +2399,7 @@ int unregister_strdev (unsigned int major, struct streamtab *strtab, int nminor) if (err >= 0) { LESS_USE; } else - printf("Unregister: Driver %s not deleted: %d\n",name,err); + printf("Unregister: Driver %s not deleted: %d\n",KERN_WARNING ,name,err); #endif return err; } @@ -2466,13 +2471,11 @@ static int do_init_module(void) { } static int do_exit_module( void) { - if (MOD_IN_USE) - printf(KERN_INFO "Streams: module is in use, remove delayed\n"); - if(streams_inited) { - if (q_timeout > 1) + if (q_timeout > 0) del_timer(&q_later); } + return 0; } #endif diff --git a/streams/stropts.h b/streams/stropts.h index de06b80..f9f262f 100644 --- a/streams/stropts.h +++ b/streams/stropts.h @@ -22,18 +22,18 @@ #define FLUSHRW (FLUSHR|FLUSHW) /* - * Ioctls. + * Ioctls. Originally used 'S', but that conflicted. */ -#define I_NREAD _IOR('S', 01, int) -#define I_PUSH _IOW('S', 02, char[FMNAMESZ+1]) -#define I_POP _IO('S', 03) -#define I_LOOK _IOR('S', 04, char[FMNAMESZ+1]) -#define I_FLUSH _IO('S', 05) -#define I_SRDOPT _IO('S', 06) -#define I_GRDOPT _IOR('S', 07, int) -#define I_STR _IOWR('S', 010, struct strioctl) +#define I_NREAD _IOR('|', 01, int) +#define I_PUSH _IOW('|', 02, char[FMNAMESZ+1]) +#define I_POP _IO('|', 03) +#define I_LOOK _IOR('|', 04, char[FMNAMESZ+1]) +#define I_FLUSH _IO('|', 05) +#define I_SRDOPT _IO('|', 06) +#define I_GRDOPT _IOR('|', 07, int) +#define I_STR _IOWR('|', 010, struct strioctl) -#define I_FIND _IOW('S', 011, char[FMNAMESZ+1]) +#define I_FIND _IOW('|', 011, char[FMNAMESZ+1]) /* * ioctl control block. Needed for ioctl commands which do not correctly encode their data, and for compatibility with stupid systems like S5R4. diff --git a/strslip/Makefile b/strslip/Makefile index 82d8f82..59a3139 100644 --- a/strslip/Makefile +++ b/strslip/Makefile @@ -1,49 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@>()= -LDFLAGS = -v - -## =()@>()= -LIBS = -lbsd - -## =()@>()= -SYS = linux - -SOURCES = strslip.c - -OBJ = strslip.o -ALL = - -all: $(OBJ) - -lib: - -install: all - @cd $(SYS) ; make install - -clean: - rm -f $(ALL) $(OBJ) - -indent: - ../indent.sh $(SOURCES) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - insmod strslip.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/support/Makefile b/support/Makefile index 57479a9..7e98896 100644 --- a/support/Makefile +++ b/support/Makefile @@ -1,62 +1,24 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +all:: -## =()@>()= -CC = gcc -## =()@ -I../include>()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@>()= -RANLIB = ranlib +XHEADERS = count.h log.h qinfo.h +HEADERS = $(XHEADERS) -## =()@>()= -SYS = linux - -HEADERS = count.h log.h qinfo.h - -SOURCES = q_data.c streamlib.c dump.c sioctl.c timeout.c streams.c \ - kernel.c smallq.c log.c logh.c wildmat.c count.c \ - qinfo.c libc.c vectcmp.c streams_sys.c -XSOURCES = count.c count.h dump.c log.c log.h logh.c qinfo.c qinfo.h \ - smallq.c streamlib.c +XSOURCES = count.c dump.c log.c logh.c qinfo.c smallq.c streamlib.c YSOURCES = streams_sys.c -OBJ = q_data.o streamlib.o dump.o sioctl.o timeout.o streams.o \ - kernel.o smallq.o log.o logh.o wildmat.o count.o \ - qinfo.o libc.o vectcmp.o +PSOURCES = q_data.c sioctl.c timeout.c streams.c kernel.c wildmat.c \ + libc.c vectcmp.c $(XSOURCES) $(YSOURCES) -ALL = ../support.a +LIB = ../support.a -all prog: $(HEADERS) $(OBJ) $(ALL) -lib: all - -../support.a: $(OBJ) - ar r ../support.a $? - @ $(RANLIB) ../support.a - -indent: - ../indent.sh $(HEADERS) $(SOURCES) - -clean: - rm -f $(OBJ) $(ALL) ../support.a - rm -f $(XSOURCES) $(YSOURCES) - -install update: all - -depend: Makefile $(SOURCES) $(HEADERS) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif - -$(XSOURCES): +$(XHEADERS) $(XSOURCES): ln -sf ../ksupport/$@ $@ $(YSOURCES): ln -sf ../streams/$@ $@ +clean:: + rm -f $(HEADERS) $(XSOURCES) $(YSOURCES) + +TOPDIR=.. +include $(TOPDIR)/Make.rules + diff --git a/support/kernel.c b/support/kernel.c index 6e203ad..d961a64 100644 --- a/support/kernel.c +++ b/support/kernel.c @@ -1,4 +1,6 @@ +#include + int bh_base; int diff --git a/support/streams.c b/support/streams.c index 9650d47..9535693 100644 --- a/support/streams.c +++ b/support/streams.c @@ -84,6 +84,7 @@ mblk_t * allocb (ushort_t size, ushort_t pri) databp = (dblk_t *)malloc (sizeof (dblk_t)+size+1); if (databp == NULL) return NULL; + ((streamchar *)databp)[sizeof (dblk_t)+size] = 0; bp = (mblk_t *)malloc (sizeof (mblk_t)); if (bp == NULL) { free (databp); @@ -216,8 +217,11 @@ void freeb (mblk_t * bp) return; } #endif - if (!--bp->b_datap->db_ref) + if (!--bp->b_datap->db_ref) { + bp->deb_file = deb_file; + bp->deb_line = deb_line; free (bp->b_datap); + } free (bp); chkall(); splx (s); @@ -378,7 +382,7 @@ strclose (struct xstream *xp, int flag) */ int -strread (struct xstream *xp, streamchar *data, int *len, int usehq) +strread (struct xstream *xp, streamchar *data, int len, int usehq) { mblk_t *bp, *nbp; queue_t *q; @@ -391,10 +395,9 @@ strread (struct xstream *xp, streamchar *data, int *len, int usehq) else q = &xp->rl; - /* loop terminates when *len == 0 */ + /* loop terminates when len == 0 */ for (;;) { if ((bp = getq (q)) == NULL) { - *len = 0; return 0; } runqueues (); @@ -412,17 +415,16 @@ strread (struct xstream *xp, streamchar *data, int *len, int usehq) putbq (q, bp); else freemsg (bp); - *len = nlen; - return 0; + return nlen; } rflg = 1; - while (bp && *len) { - if ((n = min (*len, bp->b_wptr - bp->b_rptr)) > 0) { + while (bp && len) { + if ((n = min (len, bp->b_wptr - bp->b_rptr)) > 0) { bcopy (bp->b_rptr, data, n); bp->b_rptr += n; data += n; nlen += n; - *len -= n; + len -= n; } while (bp && (bp->b_rptr >= bp->b_wptr)) { nbp = bp; @@ -434,19 +436,16 @@ strread (struct xstream *xp, streamchar *data, int *len, int usehq) if (bp) putbq (q, bp); - if (*len && !usehq) + if (len && !usehq) printf ("NotEnoughData\n"); - *len = nlen; - return 0; + return nlen; case M_HANGUP: - *len = 0; putbq (q, bp); return 0; case M_ERROR: - *len = 0; putbq (q, bp); - return *bp->b_rptr; + return -*bp->b_rptr; default: /* * Garbage on stream head read queue @@ -522,7 +521,11 @@ strrput (queue_t * q, mblk_t * bp) int -strwrite (struct xstream *xp, streamchar * data, int *len, int usehq) +#ifdef CONFIG_DEBUG_STREAMS +deb_strwrite (const char *deb_file, unsigned int deb_line, struct xstream *xp, streamchar * data, int len, int usehq) +#else +strwrite (struct xstream *xp, streamchar * data, int len, int usehq) +#endif { mblk_t *mp; queue_t *q; @@ -533,21 +536,28 @@ strwrite (struct xstream *xp, streamchar * data, int *len, int usehq) else q = &xp->wl; - mp = allocb (*len, BPRI_LO); +#ifdef CONFIG_DEBUG_STREAMS + mp = deb_allocb (deb_file,deb_line, len, BPRI_LO); +#else + mp = allocb (len, BPRI_LO); +#endif if (mp == NULL) - return ENOMEM; - bcopy (data, mp->b_wptr, *len); - mp->b_wptr += *len; - *len = 0; + return -ENOMEM; + bcopy (data, mp->b_wptr, len); + mp->b_wptr += len; (*q->q_next->q_qinfo->qi_putp) (q->q_next, mp); runqueues (); - return 0; + return len; } int +#ifdef CONFIG_DEBUG_STREAMS +deb_strwritev (const char *deb_file,unsigned int deb_line, struct xstream *xp, struct iovec *iov, int iovlen, int usehq) +#else strwritev (struct xstream *xp, struct iovec *iov, int iovlen, int usehq) +#endif { mblk_t *mp, *bp = NULL; queue_t *q; @@ -559,11 +569,15 @@ strwritev (struct xstream *xp, struct iovec *iov, int iovlen, int usehq) q = &xp->wl; while (iovlen--) { +#ifdef CONFIG_DEBUG_STREAMS + mp = deb_allocb (deb_file,deb_line, iov->iov_len, BPRI_LO); +#else mp = allocb (iov->iov_len, BPRI_LO); +#endif if (mp == NULL) { if (bp != NULL) freemsg (bp); - return ENOMEM; + return -ENOMEM; } bcopy (iov->iov_base, mp->b_wptr, iov->iov_len); mp->b_wptr += iov->iov_len; @@ -638,7 +652,7 @@ strioctl (struct xstream *xp, long cmd, long arg) * find module in fmodsw */ if ((i = findmod (mname)) < 0) { - return EINVAL; + return -EINVAL; } /* look downstream to see if module is there */ for (q = q->q_next; @@ -662,13 +676,13 @@ strioctl (struct xstream *xp, long cmd, long arg) */ strncpy (mname, (char *) arg, FMNAMESZ + 1); if ((i = findmod (mname)) < 0) { - return EINVAL; + return -EINVAL; } /* * push new module and call its open routine via qattach */ if (!qattach (fmod_sw[i].f_str, RD (q), 0,0)) - return ENXIO; + return -ENXIO; /* * If flow control is on, don't break it - enable first back queue @@ -698,7 +712,7 @@ strioctl (struct xstream *xp, long cmd, long arg) qdetach (RD (q->q_next), 1, 0); return 0; } - return EINVAL; + return -EINVAL; @@ -714,7 +728,7 @@ strioctl (struct xstream *xp, long cmd, long arg) strncpy ((char *) arg, fmod_sw[i].f_name, FMNAMESZ + 1); return 0; } - return ENOENT; + return -ENOENT; } @@ -726,10 +740,10 @@ strioctl (struct xstream *xp, long cmd, long arg) * read/write queue */ if (arg & ~FLUSHRW) { - return EINVAL; + return -EINVAL; } if (!putctl1 (q->q_next, M_FLUSH, arg)) - return ENOMEM; + return -ENOMEM; runqueues (); return 0; diff --git a/t70/Makefile b/t70/Makefile index 953af13..59a3139 100644 --- a/t70/Makefile +++ b/t70/Makefile @@ -1,64 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@ >()= -DEFSN = -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -## =()@ $(DEFSN)>()= -CFLAGSN = -O2 -Wall $(DEFSN) - -## =()@>()= -SYS = linux - -SOURCES = t70.c -TESTSOURCES = test_t70.c - -OBJ = t70.o -ALL = -TESTALL = test_t70 -TESTOBJ = test_t70.o t70t.o - -all: $(OBJ) $(ALL) - -test: $(TESTALL) - -test_t70: test_t70.o t70t.o ../support.a - $(CC) $(CFLAGS) -o $@ test_t70.o t70t.o ../support.a - -test_t70.o: test_t70.c - $(CC) $(CFLAGSN) -c $< -t70t.o: t70.c - $(CC) $(CFLAGSN) -c -o $@ $< - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) $(TESTSOURCES) - -depend: Makefile $(SOURCES) $(TESTSOURCES) - $(CC) -M $(DEFS) $(SOURCES) $(TESTSOURCES) > .depend - -clean: - rm -f $(OBJ) $(ALL) $(TESTALL) $(TESTOBJ) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -load: - insmod t70.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/t70/test_t70.c b/t70/test_t70.c deleted file mode 100644 index 9b5b4f3..0000000 --- a/t70/test_t70.c +++ /dev/null @@ -1,106 +0,0 @@ - -#include -#include -#include -#include -#include "f_signal.h" -#include -#include "f_termio.h" -#ifdef AUX -#include -#endif -#include -#include "streams.h" -#include "kernel.h" -#include "msgtype.h" - -#include "dump.h" - -main () -{ -#define d(a,b) do { if(!(a)) { printf("%s\n",b); exit(1); } } while(0) -#define dd(a,b) do { if((err=(a))!=0) { printf("E %d: %s\n",err,b); exit(1); } } while(0) - struct xstream *xp = stropen (0); - int err; - int len; - int i, j; - - { - extern struct streamtab log_info; - extern struct streamtab t70info; - - modregister (&log_info); - modregister (&t70info); - } -#ifdef AUX - setcompat (getcompat ()| COMPAT_BSDSIGNALS); -#endif - - - d (!strioctl (xp, I_PUSH, (int) "strlog"), "Damn Log 1"); - d (!strioctl (xp, I_PUSH, (int) "t70"), "Damn T70 1"); - d (!strioctl (xp, I_PUSH, (int) "strlog"), "Damn Log 2"); - - { - char *x; - -#define T do { int len = strlen(x); mblk_t *mp = allocb(len,BPRI_MED); bcopy(x,mp->b_wptr,len); mp->b_wptr += len; mp->b_datap->db_type = MSG_PROTO; putnext(&xp->wl,mp); } while(0) - x = "ms :ms t70 :mt 5"; - T; - x = "ou"; - T; - x = "co"; - T; - } - - while (1) { - char d[100]; - char *x = (char *) gets (d); - - if (x == NULL) - break; - len = strlen (d); - switch (*d) { - default: - printf ("???\n"); - break; - case 'w': - len--; - hexm ((uchar_t *) d + 1, &len); - if (len) - dd (strwrite (xp, (uchar_t *) d + 1, &len, 0), "WriteLow"); - else - printf ("???\n"); - break; - case 'W': - len--; - hexm ((uchar_t *) d + 1, &len); - if (len) - dd (strwrite (xp, (uchar_t *) d + 1, &len, 1), "WriteHigh"); - else - printf ("???\n"); - break; - - case '\0': - break; - } - runqueues (); - - for (i = 0; i < 5; i++) - for (j = 0; j <= 1; j++) { - if ((err = strread (xp, d, &len, j)) == 0) { - } else { - printf ("Err %d in pass %d, reading from %s\n", err, i, j ? "up" : "down"); - exit (1); - } - } - } - d (!strioctl (xp, I_POP, 0), "pop"); - d (!strioctl (xp, I_POP, 0), "pop"); - d (!strioctl (xp, I_POP, 0), "pop"); - strclose (xp, 0); - printf ("Done\n"); - exit (0); -} - -mblk_t *c_dupmsg(mblk_t *a, const char *b, int c) { return dupmsg(a); } diff --git a/timer/Makefile b/timer/Makefile index e5d4e78..59a3139 100644 --- a/timer/Makefile +++ b/timer/Makefile @@ -1,47 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux - -SOURCES = timer.c - -OBJ = timer.o -ALL = - -all: $(OBJ) $(ALL) - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -clean: - rm -f $(OBJ) $(ALL) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -load: - insmod timer.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/tools/Makefile b/tools/Makefile index 504ac8c..97f3f13 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,60 +1,29 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +TOPDIR=.. +include $(TOPDIR)/Make.config +PROGRAMS = cardname catfone +NOCLEAN = catfone -## =()@>()= -CCU = gcc -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@ -I../include >()= -DEFSN = -I../streams -I../compat -I/usr/src/linux/include -I/usr/include/bsd -I../include -## =()@ $(DEFSN)>()= -NCFLAGS = -O2 -Wall $(DEFSN) -## =()@>()= -LIBS = -lbsd -## =()@>()= -LDFLAGS = -v +all:: -## =()@>()= -SYS = linux +install:: + -mkdir -p /lib/modules/$(shell ./getversion)/isdn + -mkdir -p $(DESTDIR)/bin-$(shell ./getversion) + cp /dev/null /lib/modules/modules.isdn.all + @if test ! -f /etc/isdn.conf; then \ + echo install isdn.conf /etc ; \ + install isdn.conf /etc ; \ + fi + @if test -d /etc/rc.d ; then \ + if test ! -f /etc/rc.d/rc.isdn ; then \ + echo install rc.isdn /etc/rc.d ; \ + install rc.isdn /etc/rc.d; \ + fi; \ + else \ + if test ! -f /etc/rc.isdn ; then \ + echo install rc.isdn /etc ; \ + install rc.isdn /etc; \ + fi; \ + fi -SOURCES = cardname.c -OBJ = cardname.o -ALL = cardname - -all: - -prog: cardname - -cardname: cardname.o - ${CCU} ${LDFLAGS} -o $@ cardname.o ${LIBS} -cardname.o: cardname.c - ${CCU} ${NCFLAGS} -c cardname.c - -lib: - -install: all - -update: all - -indent: - ../indent.sh $(SOURCES) - -clean: - rm -f $(ALL) $(OBJ) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +include $(TOPDIR)/Make.rules diff --git a/bin/catfone b/tools/catfone similarity index 100% rename from bin/catfone rename to tools/catfone diff --git a/tools/d_insmod b/tools/d_insmod new file mode 100644 index 0000000..564e7a0 --- /dev/null +++ b/tools/d_insmod @@ -0,0 +1,14 @@ +#!/bin/sh +# +## Diese Version von "insmod" fügt ein Modul nicht in diesen, sondern in +## den nächsten Kernel ein... + +FILE=$1 + +VERSION=${VERSION:-$(${TOPDIR}/tools/getversion)} +dir=/lib/modules/$VERSION +echo isdn/d_$FILE >>$dir/../modules.isdn.all +rm -f $dir/isdn/d_$FILE +cp $FILE $dir/isdn/d_$FILE & + +exit 0 diff --git a/tools/getvers b/tools/getvers deleted file mode 100644 index 147c7eb..0000000 --- a/tools/getvers +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -grep UTS_REL /usr/include/linux/version.h | sed -e 's/.*"\([0-9]*\.[0-9]*\.\([0-9a-z]*\)\)"/\2/' diff --git a/tools/getversion b/tools/getversion index 69a0bfa..20f7398 100755 --- a/tools/getversion +++ b/tools/getversion @@ -1,3 +1,9 @@ #!/bin/sh -grep UTS_REL /usr/include/linux/version.h | sed -e 's/.*"\([0-9]*\.[0-9]*\.\([0-9a-z]*\)\)"/\1/' +KERNELSRC=${1:-${KERNELSRC:-/usr/src/linux}} +if test -f ${KERNELSRC}/include/linux/version.h ; then + grep UTS_REL ${KERNELSRC}/include/linux/version.h | sed -e 's/.*"\([0-9]*\.[0-9]*\.\([0-9a-z]*\)\)"/\1/' +else + echo "${KERNELSRC}/include/linux not found; using uname" >&2 + uname -r +fi # \2 statt \1 für die letzte Ziffer diff --git a/tools/insmod b/tools/insmod index 596c424..0afbfed 100755 --- a/tools/insmod +++ b/tools/insmod @@ -1,14 +1,13 @@ -#!/bin/bash +#!/bin/sh # ## Diese Version von "insmod" fügt ein Modul nicht in diesen, sondern in ## den nächsten Kernel ein... FILE=$1 -VERSION=$(getversion) +VERSION=${VERSION:-$(${TOPDIR}/tools/getversion)} dir=/lib/modules/$VERSION -touch $dir/../modules.isdn.all -echo $FILE >>$dir/../modules.isdn.all +echo isdn/$FILE >>$dir/../modules.isdn.all rm -f $dir/isdn/$FILE cp $FILE $dir/isdn/$FILE & diff --git a/cf b/tools/isdn.conf similarity index 96% rename from cf rename to tools/isdn.conf index ce3105e..4a89f5e 100644 --- a/cf +++ b/tools/isdn.conf @@ -2,7 +2,7 @@ ### Everything in angle brackets is to be replaced with more sensible values! ## Flags ":sv " are specific to the German 1TR6 protocol. ## Flags ":vB " are specific to Euro-ISDN. - +# See the DOKU file for an explanation. # Sample answering machine. # It answers on EAZ 2 (1TR6) bzw. MSN ...2 (Euro). @@ -90,8 +90,8 @@ D * unknown U * - +* # Local numbers. -#DL Tel0 +49=911-959913/[1-3] :pr 0 :sp 8 :pr 63 -DL Tel0 +49=911-919402/ :pr 0 :sp 65 :pr 63 +#DL * Tel0 +49=911-959913/[1-3] :pr 0 :sp 8 :pr 63 +DL * Tel0 +49=911-919402/ :pr 0 :sp 65 :pr 63 ## :pr 64 -- leased lines ONLY. ## :pr 65 -- cards with CAPI interface ONLY. ## :pr 0 -- the normal circuit-mode D channel protocol @@ -116,7 +116,7 @@ CM ???? 14 frameb # Limit how many B channel connections may be opened. # Override the limit with :il in the P line. -CL * 2 +CL * * 2 ## Load cards diff --git a/bin/tester b/tools/nologin similarity index 100% rename from bin/tester rename to tools/nologin diff --git a/tools/rc.isdn b/tools/rc.isdn index 18787dd..78dd1ef 100755 --- a/tools/rc.isdn +++ b/tools/rc.isdn @@ -10,7 +10,7 @@ cd /usr/local/isdn /bin/echo -n "\rISDN Modules: " >&2 /bin/echo -n "\rISDN Modules: $a: " >&2 eval "insmod -m $a" ## wegen name=$(cardname Foo0) in $a - done < ../modules.isdn >> symbols + done < ../modules.isdn > symbols.isdn /bin/echo "\rISDN Modules...done. " ) diff --git a/v110/Makefile b/v110/Makefile index 9612c3b..59a3139 100644 --- a/v110/Makefile +++ b/v110/Makefile @@ -1,47 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux - -SOURCES = v110.c - -OBJ = v110.o -ALL = - -all: $(OBJ) $(ALL) - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -clean: - rm -f $(OBJ) $(ALL) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - insmod v110.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/van_j/Makefile b/van_j/Makefile index 1b6d80c..1384746 100644 --- a/van_j/Makefile +++ b/van_j/Makefile @@ -1,52 +1,6 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 +OBJ = vanj.o -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) -## =()@>()= -LD = ld - -## =()@>()= -SYS = linux - -SOURCES = van_j.c compress.c - -OBJ = van_j.o compress.o -ALL = vanj.o - -all: $(OBJ) $(ALL) - -lib: - -vanj.o: $(OBJ) - $(LD) -r -o $@ $(OBJ) - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -clean: - rm -f $(OBJ) $(ALL) - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -load: - insmod vanj.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/van_j/van_j.c b/van_j/van_j.c index c86e766..b8dcd9c 100644 --- a/van_j/van_j.c +++ b/van_j/van_j.c @@ -179,11 +179,7 @@ van_j_proto (queue_t * q, mblk_t * mp, char isdown) static int -van_j_open (queue_t * q, dev_t dev, int flag, int sflag -#ifdef DO_ADDERROR - ,int *err -#endif -) +van_j_open (queue_t * q, dev_t dev, int flag, int sflag ERR_DECL) { struct _van_j *van_j; @@ -191,7 +187,7 @@ van_j_open (queue_t * q, dev_t dev, int flag, int sflag return 0; van_j = malloc(sizeof(van_j)); if(van_j == NULL) - return OPENFAIL; + ERR_RETURN(-ENOMEM); memset(van_j,0,sizeof(*van_j)); WR (q)->q_ptr = (char *) van_j; q->q_ptr = (char *) van_j; @@ -209,7 +205,7 @@ van_j_wput (queue_t * q, mblk_t * mp) { switch (DATA_TYPE(mp)) { case MSG_PROTO: - CASE_DATA + case CASE_DATA: putq (q, mp); break; case M_FLUSH: @@ -239,7 +235,8 @@ van_j_wsrv (queue_t * q) case MSG_PROTO: van_j_proto (q, mp, 1); break; - CASE_DATA { + case CASE_DATA: + { mblk_t *mq; struct ip *p_ip; ushort_t protocol; @@ -349,7 +346,7 @@ van_j_rput (queue_t * q, mblk_t * mp) break; case MSG_PROTO: - CASE_DATA + case CASE_DATA: putq (q, mp); /* queue it for my service routine */ break; @@ -374,7 +371,8 @@ van_j_rsrv (queue_t * q) case MSG_PROTO: van_j_proto (q, mp, 0); break; - CASE_DATA { + case CASE_DATA: + { mblk_t *mq; ushort_t protocol = 0; @@ -457,9 +455,8 @@ van_j_rsrv (queue_t * q) } if (mp != NULL) putnext (q, mp); - break; - } + break; default: if (DATA_TYPE(mp) > QPCTL || canput (q->q_next)) { putnext (q, mp); diff --git a/x75/Makefile b/x75/Makefile index cb6da36..59a3139 100644 --- a/x75/Makefile +++ b/x75/Makefile @@ -1,53 +1,5 @@ -SHELL = /bin/sh -MAKE = make -## =()

@>()= -P = +KERNEL=1 -## =()@>()= -CC = gcc -## =()@ @@ -I../include >()= -DEFS = -I../streams -I../compat -I/usr/src/linux/include -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS -I../include -## =()@ $(DEFS)>()= -CFLAGS = -O2 -Wall $(DEFS) - -## =()@>()= -SYS = linux - -SOURCES = x75.c - -OBJ = x75.o -ALL = - -all: $(OBJ) $(ALL) - -lib: - -install: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make" - -update: all - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make update" - -indent: - ../indent.sh $(SOURCES) - -depend: Makefile $(SOURCES) - $(CC) -M $(DEFS) $(SOURCES) > .depend - -clean: - rm -f $(OBJ) $(ALL) - rm -f test_x75 test_x75.o - @sh ../iftrue.sh "-d $(SYS)" "cd $(SYS); make clean" - -test: test_x75 - -test_x75: test_x75.o x75.o ../support.a - $(CC) $(CFLAGS) -o $@ $< - -load: - insmod x75.o - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif +TOPDIR=.. +include $(TOPDIR)/Make.rules diff --git a/x75/test_x75.c b/x75/test_x75.c deleted file mode 100644 index 5577132..0000000 --- a/x75/test_x75.c +++ /dev/null @@ -1,134 +0,0 @@ - -#include -#include -#include -#include -#include "f_signal.h" -#include -#include "f_termio.h" -#include -#include -#include -#include "streams.h" -#include "kernel.h" - -#include "dump.h" - -extern int x75_T1 (); -extern int x75_T3 (); -int t1arg; -int t3arg; - -timeout (a, b, c) -{ - if (a == (int) &x75_T1) { - printf ("Timer T1: %d.%02d\n", c / 60, c % 60 * 100 / 60); - t1arg = b; - } else if (a == (int) &x75_T3) { - printf ("Timer T3: %d.%02d\n", c / 60, c % 60 * 100 / 60); - t3arg = b; - } else - printf ("Unknown Timer %x/%x %d.%02d\n", a, b, c / 60, c % 60 * 100 / 60); -} - -untimeout (a, b) -{ - if (a == (int) &x75_T1) { - if (b != t1arg) - printf ("Bad (%x vs %x) ", b, t1arg); - printf ("Untimer T1\n"); - } else if (a == (int) &x75_T3) { - if (b != t3arg) - printf ("Bad (%x vs %x) ", b, t3arg); - printf ("Untimer T3\n"); - } else - printf ("Unknown Untimer %x/%x\n", a, b); - -} - -main () -{ -#define d(a,b) do { if(!(a)) { printf("%s\n",b); exit(1); } } while(0) -#define dd(a,b) do { if((err=(a))!=0) { printf("E %d: %s\n",err,b); exit(1); } } while(0) - struct xstream *xp = stropen (0); - int err; - int len; - int i, j; - - { - extern struct streamtab loginfo; - extern struct streamtab x75info; - - modregister (&loginfo); - modregister (&x75info); - } - setcompat (getcompat ()| COMPAT_BSDSIGNALS); - - - d (!strioctl (xp, I_PUSH, (int) "strlog"), "Damn Log 1"); - d (!strioctl (xp, I_PUSH, (int) "x75"), "Damn X75 1"); - d (!strioctl (xp, I_PUSH, (int) "strlog"), "Damn Log 2"); - - { - char *x; -#define T do { int len = strlen(x); mblk_t *mp = allocb(len,BPRI_MED); bcopy(x,mp->b_wptr,len); mp->b_wptr += len; mp->b_datap->db_type = M_PROTO; putnext(&xp->wl,mp); } while(0) - x = "x75 :po :nk 1 :t3 25 :ad 60 60 :cm 0"; T; - x = "*ou"; T; - x = "*co"; T; - } - - while (1) { - char d[100]; - char *x = (char *) gets (d); - - if (x == NULL) - break; - len = strlen (d); - switch (*d) { - default: - printf ("???\n"); - break; - case 'w': - len--; - hexm ((uchar_t *) d + 1, &len); - if (len) - dd (strwrite (xp, (uchar_t *) d + 1, &len, 0), "WriteLow"); - else - printf ("???\n"); - break; - case 'W': - len--; - hexm ((uchar_t *) d + 1, &len); - if (len) - dd (strwrite (xp, (uchar_t *) d + 1, &len, 1), "WriteHigh"); - else - printf ("???\n"); - break; - - case 't': - x75_T1 (t1arg); - break; - case 'T': - x75_T3 (t3arg); - break; - case '\0': - break; - } - runqueues (); - - for (i = 0; i < 5; i++) - for (j = 0; j <= 1; j++) { - if ((err = strread (xp, d, &len, j)) == 0) { - } else { - printf ("Err %d in pass %d, reading from %s\n", err, i, j ? "up" : "down"); - exit (1); - } - } - } - d (!strioctl (xp, I_POP, 0), "pop"); - d (!strioctl (xp, I_POP, 0), "pop"); - d (!strioctl (xp, I_POP, 0), "pop"); - strclose (xp, 0); - printf ("Done\n"); - exit (0); -} diff --git a/x75/x75.c b/x75/x75.c index c9a1e80..de29703 100644 --- a/x75/x75.c +++ b/x75/x75.c @@ -88,7 +88,7 @@ struct x75_ { static int x75__state (struct x75_ *x_75, uchar_t ind, ushort_t add) { - printf (KERN_DEBUG "x75__state %d: Ind %d/%o\n", x_75 ->nr, ind, add); + printf ("%sx75__state %d: Ind %d/%o\n",KERN_DEBUG , x_75 ->nr, ind, add); switch (ind) { case DL_ESTABLISH_IND: case DL_ESTABLISH_CONF:{ @@ -159,7 +159,7 @@ x75__send (struct x75_ *x_75, char iscmd, mblk_t * mb2) mblk_t *mb; if (x_75->q == NULL) { - printf(KERN_DEBUG "X75_send EIO\n"); + printf("%sX75_send EIO\n",KERN_DEBUG ); return -EIO; } if(x_75->wide) { @@ -203,7 +203,7 @@ x75__recv (struct x75_ *x_75, char isUI, mblk_t * mp) else if ((isUI != 0) != ((x_75->connmode & X75CONN_UI) != 0)) { if (!(x_75->flags & X75_ADRWARN)) { x_75->flags |= X75_ADRWARN; - printf (KERN_WARNING "X75: Got %s frame, but want %s\n", + printf ("%sX75: Got %s frame, but want %s\n",KERN_WARNING, isUI ? "UI" : "I", isUI ? "I" : "UI"); } freemsg (mp); @@ -647,7 +647,7 @@ x75_wsrv (queue_t * q) } else if ((err = x75_send (&x_75->x75, isUI, mp)) == 0) break; else { - printf (KERN_DEBUG "x75_send: Err %d\n", err); + printf ("%sx75_send: Err %d\n",KERN_DEBUG , err); putctlerr (RD (q), err); freemsg (mp); } @@ -732,7 +732,7 @@ x75_rsrv (queue_t * q) if (adr != x_75->radr_cmd && adr != x_75->radr_meld) { if (!(x_75->flags & X75_ADRWARN)) { x_75->flags |= X75_ADRWARN; - printf (KERN_WARNING "X75: got address %x, expected %x or %x\n", adr, x_75->radr_cmd, x_75->radr_meld); + printf ("%sX75: got address %x, expected %x or %x\n",KERN_WARNING , adr, x_75->radr_cmd, x_75->radr_meld); } if(0) log_printmsg (NULL, "Bad Addr", mp, KERN_INFO); freemsg (mp); @@ -745,7 +745,7 @@ x75_rsrv (queue_t * q) isCmd = 0; #endif if ((err = x75_recv (&x_75->x75, isCmd, mp)) != 0) { - printf (KERN_DEBUG "x75_recv err %d\n", err); + printf ("%sx75_recv err %d\n",KERN_DEBUG , err); /* putbq(q,mp); return; */ /* always freed, so forget it */ }