From 7daf7bbf26b169d4e847a90c9ffefe00d036cdf9 Mon Sep 17 00:00:00 2001 From: akool Date: Sat, 29 Mar 1997 09:24:17 +0000 Subject: [PATCH] CLIP presentation enhanced, new ILABEL/OLABEL operators --- isdnlog/README | 68 ++++++++++++++++++++++----- isdnlog/isdnlog/isdnlog.c | 8 ++-- isdnlog/isdnlog/processor.c | 76 ++++++++++++++++++------------ isdnlog/tools/tools.c | 94 +++++++++++-------------------------- isdnlog/tools/tools.h | 24 ++++++---- 5 files changed, 148 insertions(+), 122 deletions(-) diff --git a/isdnlog/README b/isdnlog/README index 2d9c99b5..46102a3c 100644 --- a/isdnlog/README +++ b/isdnlog/README @@ -1,4 +1,4 @@ -ISDNLOG - Version 3.0 - 20-Mar-97 23:29 +ISDNLOG - Version 3.0 - 28-Mar-97 20:49 isdnlog ist ein Tool zur Auswertung der Info's vom ISDN-S0-Bus sowie @@ -13,7 +13,7 @@ Fuer alle, die es nun ueberhaupt nicht mehr abwarten koennen, hier das Quick-Installation-Guide ------------------------ -1. Linux-2.0.29 + isdn4liunx-Patches (oder 2.0.30???) verwenden: +1. Linux-2.0.29 + isdn4kernel-2.0.29.5 verwenden: CONFIG_ISDN=m CONFIG_ISDN_DRV_TELES=m @@ -552,12 +552,40 @@ ACHTUNG: "MYPATH = /home/fred" wird als Variable zu "MYPATH=/home/fred". Die dritte Sektion beschreibt spezifische Angaben fuer den isdnlog. Diese -Sektion wird durch [ISDNLOG] eingeleitet: +Sektion wird durch [ISDNLOG] eingeleitet. -Andreas, die folgenden Zeilen muss du noch dokumentieren: -RELOADCMD -STOPCMD -RELOADCMD +RELOADCMD = reload + +Hiermit wird ein ausfuehrbares Programm (z.b. Shell-Script) angegeben, +mit dem isdnlog ein evtl. wildgewordenes isdn4linux reanimieren kann. +(Ein Beispiel findet sich im Kapitel 14.1 Watchdog) + +STOPCMD = stop + +Hiermit wird ein ausfuehrbares Programm (z.b. Shell-Script) angegeben, +mit dem isdnlog isdn4linux terminieren kann. +(Ein Beispiel findet sich im Kapitel 14.2 CHARGEMAX) + +REBOOTCMD = /sbin/reboot + +Hiermit wird ein ausfuehrbares Programm (z.b. Shell-Script) angegeben, +mit dem isdnlog Linux herunterfahren kann. +(Ein Beispiel findet sich im Kapitel 14.2 CHARGEMAX) + +CHARGEMAX = 15.00 + +Hiermit wird (in DM) angegeben, wieviel Geld man pro Tag maximal +mit isdn4linux vertelefonieren moechte. + +CONNECTMAX = 18000,0 + +Hiermit wird (in Sekunden) angegeben, wieviel Zeit man pro Monat +maximal Online sein moechte. + +BYTEMAX = 67108864,0 + +Hiermit wird (in Byte) angegeben, wieviel Byte man maximal pro +Monat saugen moechte. CURRENCY=factor,currency @@ -585,7 +613,7 @@ OLABEL=xxxxx Hiermit kann definiert werden, wie die Console-Ausgaben aussehen sollen. Fehlen diese Eintraege, wird ILABEL=%b %e %T %ICall to tei %t from %N2 on %n2 - OLABEL=%b %e %T %ICall to tei %t from %N2 on %n2 + OLABEL=%b %e %T %Itei %t calling %N2 with %n2 angenommen (die bislang bekannte Optik) Bei reinkommenden Verbindungen wird das "ILABEL", und bei rausgehenden @@ -601,21 +629,39 @@ koennen folgende Platzhalter angegeben werden: %C Call reference %Nx MSN (Telefonnummer) des Gegner's (siehe *1) %nx Eigene MSN (Telefonnummer) (siehe *1) + %cx Via CLIP vermeldete MSN (siehe *1) + %A der Text " alias ", falls + CLIP-Meldung, sonst leer %I Tabulation (siehe *2) %a Wochentag (-> "Fri") %b Monat (-> "Aug") %e Tag im Monat (-> " 8") %T Uhrzeit (-> "13:17:11") %B B-Kanal (0, oder 1) + %k Nummer der ISDN-Karte, von der die Meldung kam (0 = 1. Karte) -*1 Bei %N sowie %n muss angegeben werden, wie die Telefonnummer ausgegeben + %/ + % + %( + %) Falls die Nummer des Gegners bekannt, entsprechendes Zeichen, + sonst Leerstring + + +*1 Bei %N, %n sowie %c muss angegeben werden, wie die Telefonnummer ausgegeben werden soll: %N0 - Telefonnummer exakt so, wie von der VSt gemeldet + (z.b. "8989810530") %N1 - Telefonnummer, von isdnlog um Vorwahl, vorlaufende "0" etc. - ergaenzt + ergaenzt (z.b. "+498989810530") %N2 - Von isdnlog optimal "verschoenerte" Nummer, also Alias - aus "isdn.conf", mit Ortsnetz etc. + aus "isdn.conf" oder mit Ortsnetz etc. + (z.b. "+49 89/89810530, Muenchen") + %N3 - Vorwahl (z.b. "89") + %N4 - Rufnummer (z.b. "89810530") + %N5 - Alias + %N6 - Ortsnetz (z.b. "Muenchen") + %N7 - Areacode (z.b. "+49") *2 Dieser Platzhalter wird von isdnlog folgendermassen aufgeloest: diff --git a/isdnlog/isdnlog/isdnlog.c b/isdnlog/isdnlog/isdnlog.c index b7fb6f72..6dc8b2bd 100644 --- a/isdnlog/isdnlog/isdnlog.c +++ b/isdnlog/isdnlog/isdnlog.c @@ -1,4 +1,4 @@ -/* $Id: isdnlog.c,v 1.2 1997/03/20 22:42:31 akool Exp $ +/* $Id: isdnlog.c,v 1.3 1997/03/29 09:24:23 akool Exp $ * * ISDN accounting for isdn4linux. (log-module) * @@ -436,7 +436,7 @@ int set_options(int argc, char* argv[]) message = newmessage; if (trace && isdaemon) { - printf("%s","Can not trace and daemon together!\n"); + printf("%s","Can not trace daemonized!\n"); exit(20); } /* if */ @@ -450,7 +450,7 @@ int set_options(int argc, char* argv[]) syslogmessage = defaultmsg; switch (fork()) { - case -1 : print_msg(PRT_ERR,"%s","Can not start fork()!\n"); + case -1 : print_msg(PRT_ERR,"%s","Can not fork()!\n"); Exit(18); break; case 0 : break; @@ -481,7 +481,7 @@ static int read_param_file(char *FileName) if (opt_dat != NULL) { - print_msg(PRT_ERR,"Can not more than one option file (file %s)!\n", FileName); + print_msg(PRT_ERR, "Only one option file allowed (file %s)!\n", FileName); return -1; } diff --git a/isdnlog/isdnlog/processor.c b/isdnlog/isdnlog/processor.c index 47c23c33..1e0c8f84 100644 --- a/isdnlog/isdnlog/processor.c +++ b/isdnlog/isdnlog/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.2 1997/03/20 22:42:33 akool Exp $ +/* $Id: processor.c,v 1.3 1997/03/29 09:24:25 akool Exp $ * * ISDN accounting for isdn4linux. (log-module) * @@ -19,6 +19,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: processor.c,v $ + * Revision 1.3 1997/03/29 09:24:25 akool + * CLIP presentation enhanced, new ILABEL/OLABEL operators + * * Revision 1.2 1997/03/20 22:42:33 akool * Some minor enhancements. * @@ -376,7 +379,7 @@ static int facility(int type, int l) switch(type) { case AOC_INITIAL : ID = OP = EH = MP = 0; -#if 0 +#if 0 if (asnp == NULL) return(AOC_OTHER); #endif @@ -386,7 +389,7 @@ static int facility(int type, int l) case 0x91 : aoc_debug(c, "Remote Operation Protocol"); break; case 0x92 : aoc_debug(c, "CMIP Protocol"); break; case 0x93 : aoc_debug(c, "ACSE Protocol"); break; - default : aoc_debug(c, "UNKNOWN Protocol"); + default : aoc_debug(c, "UNKNOWN Protocol"); return(AOC_OTHER); } /* switch */ @@ -520,7 +523,7 @@ static int facility(int type, int l) } /* switch */ aoc_debug(c, px1); - + c = strtol(asnp += 3, NIL, 16); sprintf(s, "Enumeration type BasicService=%d", c); aoc_debug(c, s); @@ -543,7 +546,7 @@ static int facility(int type, int l) } /* switch */ aoc_debug(c, px2); - + c = strtol(asnp += 3, NIL, 16); sprintf(s, "SEQUENCE, Address (Zieladresse)=%d", c); aoc_debug(c, s); @@ -564,7 +567,7 @@ static int facility(int type, int l) aoc_debug(l, s); c = strtol(asnp += 3, NIL, 16); - sprintf(s, "Aufz„hlungstyp, PublicTypeOfNumber=%d", c); + sprintf(s, "Aufzaehlungstyp, PublicTypeOfNumber=%d", c); aoc_debug(c, s); l = strtol(asnp += 3, NIL, 16); @@ -580,7 +583,7 @@ static int facility(int type, int l) case 0x05 : px3 = "abbreviated Number"; break; default : px3 = "UNKNOWN PublicTypeOfNumber"; break; } /* switch */ - + aoc_debug(c, px3); break; @@ -692,7 +695,7 @@ static int facility(int type, int l) c = strtol(asnp += 3, NIL, 16); sprintf(s, "ServedUserNr=%d", c); aoc_debug(c, s); - + l = strtol(asnp += 3, NIL, 16); sprintf(s, "length=%d", l); aoc_debug(l, s); @@ -1183,7 +1186,7 @@ static void buildnumber(char *num, int oc3, int oc3a, char *result, int version) switch (oc3 & 0x70) { /* Calling party number Information element, Octet 3 - Table 4-11/Q.931 */ case 0x00 : if (*num) { /* 000 Unknown */ char *amt = amtsholung; - + while (amt && *amt) { int len = strchr(amt, ':') ? strchr(amt, ':') - amt : strlen(amt); @@ -1200,7 +1203,7 @@ static void buildnumber(char *num, int oc3, int oc3a, char *result, int version) #endif break; } /* if */ - + amt += len + (strchr(amt, ':') ? 1 : 0); } /* while */ @@ -1301,7 +1304,7 @@ static void chargemaxAction(int chan, double charge_overflow) sprintf(cmd, "%s/dontstop", confdir()); - + if (access(cmd, F_OK)) { sprintf(cmd, "%s/%s", confdir(), STOPCMD); @@ -1518,14 +1521,14 @@ static void decode(int chan, register char *p, int type, int version) switch (c & 0xf0) { case 0x00 : - case 0x80 : sprintf(ps, "CCITT standartisierte Codierung"); break; + case 0x80 : sprintf(ps, "CCITT standartisierte Codierung"); break; case 0x20 : - case 0xa0 : sprintf(ps, "Reserve"); break; + case 0xa0 : sprintf(ps, "Reserve"); break; case 0x40 : - case 0xc0 : sprintf(ps, "reserviert fr nationale Standards"); break; + case 0xc0 : sprintf(ps, "reserviert fuer nationale Standards"); break; case 0x60 : - case 0xe0 : sprintf(ps, "Standard bzgl. Localierung"); break; - default : sprintf(ps, "UNKNOWN #%d", c & 0xf0); break; + case 0xe0 : sprintf(ps, "Standard bzgl. Localierung"); break; + default : sprintf(ps, "UNKNOWN #%d", c & 0xf0); break; } /* switch */ Q931dump(TYPE_STRING, c, s, version); @@ -1559,7 +1562,7 @@ static void decode(int chan, register char *p, int type, int version) case 0x0a : py = "Network beyond inter-working point"; break; default : py = ""; break; } /* switch */ - + c = strtol(p + 6, NIL, 16); call[chan].cause = c & 0x7f; @@ -1972,31 +1975,41 @@ static void decode(int chan, register char *p, int type, int version) if (*call[chan].onum[CALLING]) /* another Calling-party? */ if (strcmp(call[chan].onum[CALLING], s)) /* different! */ if ((call[chan].screening == 3) && ((oc3a & 3) < 3)) { /* we believe the first one! */ - strcpy(call[6].onum[CALLING], s); - buildnumber(s, oc3, oc3a, call[6].num[CALLING], version); - strcpy(call[6].vnum[CALLING], vnum(6, CALLING)); + strcpy(call[chan].onum[CLIP], s); + buildnumber(s, oc3, oc3a, call[chan].num[CLIP], version); + strcpy(call[chan].vnum[CLIP], vnum(6, CLIP)); #ifdef Q931 - if (q931dmp && (*call[chan].vnum[CALLING] != '?') && *call[chan].vorwahl[CALLING] && oc3 && ((oc3 & 0x70) != 0x40)) { + if (q931dmp && (*call[chan].vnum[CLIP] != '?') && *call[chan].vorwahl[CLIP] && oc3 && ((oc3 & 0x70) != 0x40)) { auto char s[BUFSIZ]; sprintf(s, "%s %s/%s, %s", - call[6].areacode[CALLING], - call[6].vorwahl[CALLING], - call[6].rufnummer[CALLING], - call[6].area[CALLING]); + call[chan].areacode[CLIP], + call[chan].vorwahl[CLIP], + call[chan].rufnummer[CLIP], + call[chan].area[CLIP]); Q931dump(TYPE_STRING, -2, s, version); } /* if */ #endif - sprintf(s1, "CLIP %s", call[6].vnum[CALLING]); + sprintf(s1, "CLIP %s", call[chan].vnum[CLIP]); info(chan, PRT_SHOWNUMBERS, STATE_RING, s1); break; } else { warn = 1; - strcpy(call[6].vnum[CALLING], call[chan].vnum[CALLING]); + + strcpy(call[chan].onum[CLIP], call[chan].onum[CALLING]); + strcpy(call[chan].num[CLIP], call[chan].num[CALLING]); + strcpy(call[chan].vnum[CLIP], call[chan].vnum[CALLING]); + call[chan].confentry[CLIP] = call[chan].confentry[CALLING]; + strcpy(call[chan].areacode[CLIP], call[chan].areacode[CALLING]); + strcpy(call[chan].vorwahl[CLIP], call[chan].vorwahl[CALLING]); + strcpy(call[chan].rufnummer[CLIP], call[chan].rufnummer[CALLING]); + strcpy(call[chan].alias[CLIP], call[chan].alias[CALLING]); + strcpy(call[chan].area[CLIP], call[chan].area[CALLING]); + /* fall thru, and overwrite ... */ } /* else */ @@ -2021,9 +2034,10 @@ static void decode(int chan, register char *p, int type, int version) #endif if (warn) { - sprintf(s1, "CLIP %s", call[6].vnum[CALLING]); + sprintf(s1, "CLIP %s", call[chan].vnum[CLIP]); info(chan, PRT_SHOWNUMBERS, STATE_RING, s1); } /* if */ + break; @@ -2093,7 +2107,7 @@ static void decode(int chan, register char *p, int type, int version) if (version != VERSION_1TR6) { if (call[chan].knock) info(chan, PRT_SHOWNUMBERS, STATE_RING, "********************"); - + sprintf(s, "RING (%s)", call[chan].service); info(chan, PRT_SHOWNUMBERS, STATE_RING, s); @@ -2101,7 +2115,7 @@ static void decode(int chan, register char *p, int type, int version) info(chan, PRT_SHOWNUMBERS, STATE_RING, "NO FREE B-CHANNEL !!"); info(chan, PRT_SHOWNUMBERS, STATE_RING, "********************"); } /* if */ - + if (sound) ringer(chan, RING_RING); } /* if */ @@ -2402,7 +2416,7 @@ escape: for (c = 0; c <= sxp; c++) px += sprintf(px, "CHANNEL: "); switch (c) { - case 0x80 : px += sprintf(px, "BRI, kein Kanal"); + case 0x80 : px += sprintf(px, "BRI, kein Kanal"); call[chan].knock = 1; break; case 0x81 : px += sprintf(px, "BRI, B1 bevorzugt"); break; diff --git a/isdnlog/tools/tools.c b/isdnlog/tools/tools.c index a2e3b0ff..2f0e5024 100644 --- a/isdnlog/tools/tools.c +++ b/isdnlog/tools/tools.c @@ -1,4 +1,4 @@ -/* $Id: tools.c,v 1.1 1997/03/16 20:59:24 luethje Exp $ +/* $Id: tools.c,v 1.2 1997/03/29 09:24:33 akool Exp $ * * ISDN accounting for isdn4linux. (Utilities) * @@ -19,6 +19,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: tools.c,v $ + * Revision 1.2 1997/03/29 09:24:33 akool + * CLIP presentation enhanced, new ILABEL/OLABEL operators + * * Revision 1.1 1997/03/16 20:59:24 luethje * Added the source code isdnlog. isdnlog is not working yet. * A workaround for that problem: @@ -189,7 +192,7 @@ char *num2nam(char *num, int si) /****************************************************************************/ -#ifdef _GNU_SOURCE +#ifdef GLIBC /* _GNU_SOURCE */ char *double2str(double n, int l, int d, int flags) { if (++retnum == MAXRET) @@ -548,12 +551,10 @@ int iprintf(char *obuf, int chan, register char *fmt, ...) register int c, i, who; register short int width, ndigit; register int ndfnd, ljust, zfill, lflag; - register long l; + register int unknown = !*call[chan].digits && !*call[chan].onum[OTHER]; register char *op = obuf; -#if 0 - auto int decpt, sign; -#endif auto char buf[MAXDIG + 1]; /* +1 for sign */ + auto char sx[BUFSIZ]; static char nul[] = "(null)"; auto va_list ap; @@ -637,64 +638,6 @@ int iprintf(char *obuf, int chan, register char *fmt, ...) who = OTHER; switch (c) { - case 'X' : lflag++; - case 'x' : c = 16; - goto oxu; - - case 'U' : lflag++; - case 'u' : c = 10; - goto oxu; - - case 'O' : lflag++; - case 'o' : c = 8; -oxu: - if (lflag) - p = ltoa((unsigned long)GETARG(long), p, c, 0); - else - p = itoa((unsigned int)GETARG(int), p, c, 0); - break; - - case 'D' : lflag++; - case 'd' : if (lflag) { - if ((l = GETARG(long)) < 0) { - *p++ = '-'; - l = -l; - } /* if */ - - p = ltoa((unsigned long)l, p, 10, 0); - } - else { - if ((i = GETARG(int)) < 0) { - *p++ = '-'; - i = -i; - } /* if */ - - p = itoa((unsigned int)i, p, 10, 0); - } /* else */ - break; -#if 0 - case 'e' : if (!ndfnd) - ndigit = 6; - - ndigit++; - p = ecvt(GETARG(double), ndigit, &decpt, &sign) + ndigit; - break; - - case 'f' : if (!ndfnd) - ndigit = 6; - p = fcvt(GETARG(double), ndigit, &decpt, &sign) + ndigit; - break; - - case 'g' : if (!ndfnd) - ndigit = 6; - p = gcvt(GETARG(double), ndigit, p) + ndigit; - break; -#endif - - case 'c' : zfill = ' '; - *p++ = GETARG(int); - break; - case 's' : zfill = ' '; if ((s = GETARG(char *)) == NULL) @@ -719,8 +662,18 @@ oxu: case 'B' : p = itoa(chan, p, 10, 0); break; - case 'n' : who = ME; - case 'N' : if (!ndigit) + case 'A' : s = sx; + if (*call[chan].onum[CLIP]) + sprintf(sx, " alias %s", call[chan].vnum[CLIP]); + else + *sx = 0; + p = s + strlen(s); + break; + + case 'n' : who = ME; goto go; + case 'c' : who = CLIP; goto go; + case 'N' : +go: if (!ndigit) ndigit = 32767; if (*fmt) { @@ -732,6 +685,7 @@ oxu: case '4' : s = call[chan].rufnummer[who]; break; case '5' : s = call[chan].alias[who]; break; case '6' : s = call[chan].area[who]; break; + case '7' : s = call[chan].areacode[who]; break; default : s = nul; break; } /* switch */ @@ -758,6 +712,14 @@ oxu: case 'T' : s = idate + 8; p = s + 8; break; + case ' ' : + case '(' : + case ')' : + case '/' : sprintf(sx, "%c", unknown ? 0 : c); + s = sx; + p = s + strlen(s); + break; + default : *p++ = c; break; } /* switch */ diff --git a/isdnlog/tools/tools.h b/isdnlog/tools/tools.h index d1e3ca6b..99dd594a 100644 --- a/isdnlog/tools/tools.h +++ b/isdnlog/tools/tools.h @@ -1,4 +1,4 @@ -/* $Id: tools.h,v 1.6 1997/03/23 23:12:05 luethje Exp $ +/* $Id: tools.h,v 1.7 1997/03/29 09:24:34 akool Exp $ * * ISDN accounting for isdn4linux. * @@ -19,6 +19,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: tools.h,v $ + * Revision 1.7 1997/03/29 09:24:34 akool + * CLIP presentation enhanced, new ILABEL/OLABEL operators + * * Revision 1.6 1997/03/23 23:12:05 luethje * improved performance * @@ -299,6 +302,7 @@ #define OTHER (call[chan].dialin ? CALLING : CALLED) #define ME (call[chan].dialin ? CALLED : CALLING) +#define CLIP 2 #define _OTHER(call) (call->dialin ? CALLING : CALLED) #define _ME(call) (call->dialin ? CALLED : CALLING) @@ -410,13 +414,13 @@ typedef struct { int bearer; int si1; /* Service Indicator entsprechend i4l convention */ int si11; /* if (si1 == 1) :: 0 = Telefon analog / 1 = Telefon digital */ - char onum[2][NUMSIZE]; + char onum[3][NUMSIZE]; int screening; - char num[2][NUMSIZE]; - char vnum[2][256]; + char num[3][NUMSIZE]; + char vnum[3][256]; char id[32]; char usage[16]; - int confentry[2]; + int confentry[3]; time_t time; time_t connect; time_t t_duration; @@ -429,11 +433,11 @@ typedef struct { long lobytes; double ibps; double obps; - char areacode[2][NUMSIZE]; - char vorwahl[2][NUMSIZE]; - char rufnummer[2][NUMSIZE]; - char alias[2][NUMSIZE]; - char area[2][128]; + char areacode[3][NUMSIZE]; + char vorwahl[3][NUMSIZE]; + char rufnummer[3][NUMSIZE]; + char alias[3][NUMSIZE]; + char area[3][128]; char money[64]; char currency[32]; char msg[128];