First step to let isdnlog generate his own AOCD messages

This commit is contained in:
akool 1998-06-21 11:52:43 +00:00
parent 44c4eb8692
commit 7bdc3d2320
7 changed files with 203 additions and 25 deletions

View File

@ -1,4 +1,4 @@
/* $Id: functions.c,v 1.12 1998/06/14 15:33:48 akool Exp $
/* $Id: functions.c,v 1.13 1998/06/21 11:52:43 akool Exp $
*
* ISDN accounting for isdn4linux. (log-module)
*
@ -19,6 +19,9 @@
* along with this program; if not, write to the Free Software
*
* $Log: functions.c,v $
* Revision 1.13 1998/06/21 11:52:43 akool
* First step to let isdnlog generate his own AOCD messages
*
* Revision 1.12 1998/06/14 15:33:48 akool
* AVM B1 support (Layer 3)
* Telekom's new currency DEM 0,121 supported
@ -205,6 +208,7 @@ void set_time_str(void)
day = tm_time->tm_mday;
month = tm_time->tm_mon + 1;
hour = tm_time->tm_hour;
} /* set_time_str */
/*****************************************************************************/
@ -536,7 +540,7 @@ int is_sondernummer(char *num)
if (*num)
for (i = 0; i < nSN; i++)
if (!strcmp(num, SN[i].msn))
if (!strncmp(num, SN[i].msn, strlen(SN[i].msn)))
return(i);
return(-1);

View File

@ -1,4 +1,4 @@
/* $Id: isdnlog.c,v 1.20 1998/06/07 21:08:31 akool Exp $
/* $Id: isdnlog.c,v 1.21 1998/06/21 11:52:46 akool Exp $
*
* ISDN accounting for isdn4linux. (log-module)
*
@ -19,6 +19,9 @@
* along with this program; if not, write to the Free Software
*
* $Log: isdnlog.c,v $
* Revision 1.21 1998/06/21 11:52:46 akool
* First step to let isdnlog generate his own AOCD messages
*
* Revision 1.20 1998/06/07 21:08:31 akool
* - Accounting for the following new providers implemented:
* o.tel.o, Tele2, EWE TEL, Debitel, Mobilcom, Isis, NetCologne,
@ -259,6 +262,8 @@ static void loop(void)
now();
processcint();
for (Cnt = first_descr; Cnt < socket_size(sockets); Cnt++) {
if (X_FD_ISSET(sockets[Cnt].descriptor, &exceptmask)) {
if (sockets[Cnt].fp == NULL) {

View File

@ -1,4 +1,4 @@
/* $Id: isdnlog.h,v 1.8 1998/06/07 21:08:34 akool Exp $
/* $Id: isdnlog.h,v 1.9 1998/06/21 11:52:47 akool Exp $
*
* ISDN accounting for isdn4linux.
*
@ -20,6 +20,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdnlog.h,v $
* Revision 1.9 1998/06/21 11:52:47 akool
* First step to let isdnlog generate his own AOCD messages
*
* Revision 1.8 1998/06/07 21:08:34 akool
* - Accounting for the following new providers implemented:
* o.tel.o, Tele2, EWE TEL, Debitel, Mobilcom, Isis, NetCologne,
@ -297,6 +300,7 @@ _EXTERN IO io[ISDN_MAX_CHANNELS];
_EXTERN void dotrace(void);
_EXTERN int morectrl(int card);
_EXTERN void moreinfo(void);
_EXTERN void processcint(void);
_EXTERN void processrate(void);
_EXTERN void clearchan(int chan, int total);

View File

@ -1,4 +1,4 @@
/* $Id: processor.c,v 1.21 1998/06/16 15:05:31 paul Exp $
/* $Id: processor.c,v 1.22 1998/06/21 11:52:52 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.22 1998/06/21 11:52:52 akool
* First step to let isdnlog generate his own AOCD messages
*
* Revision 1.21 1998/06/16 15:05:31 paul
* isdnlog crashed with 1TR6 and "Unknown Codeset 7 attribute 3 size 5",
* i.e. IE 03 which is not Date/Time
@ -1940,7 +1943,7 @@ static void decode(int chan, register char *p, int type, int version)
if (message & PRT_SHOWTICKS)
sprintf(s, "%d.EH %s %s (%s %d) C=%s",
call[chan].aoce,
abs(call[chan].aoce),
currency,
double2str(call[chan].pay, 6, 2, DEB),
tx ? double2clock(tx) : "", (int)err,
@ -1948,13 +1951,13 @@ static void decode(int chan, register char *p, int type, int version)
else {
if (tx)
sprintf(s, "%d.EH %s %s (%s)",
call[chan].aoce,
abs(call[chan].aoce),
currency,
double2str(call[chan].pay, 6, 2, DEB),
double2clock(tx));
else
sprintf(s, "%d.EH %s %s",
call[chan].aoce,
abs(call[chan].aoce),
currency,
double2str(call[chan].pay, 6, 2, DEB));
} /* else */
@ -2032,7 +2035,7 @@ static void decode(int chan, register char *p, int type, int version)
if (message & PRT_SHOWTICKS)
sprintf(s, "%d.EH %s %s (%s %d %s?) C=%s",
call[chan].aoce,
abs(call[chan].aoce),
currency,
double2str(call[chan].pay, 6, 2, DEB),
tx ? double2clock(tx) : "", (int)err, px,
@ -2040,20 +2043,20 @@ static void decode(int chan, register char *p, int type, int version)
else {
if (tx)
sprintf(s, "%d.EH %s %s (%s)",
call[chan].aoce,
abs(call[chan].aoce),
currency,
double2str(call[chan].pay, 6, 2, DEB),
double2clock(tx));
else
sprintf(s, "%d.EH %s %s",
call[chan].aoce,
abs(call[chan].aoce),
currency,
double2str(call[chan].pay, 6, 2, DEB));
} /* else */
}
else {
sprintf(s, "%d.EH %s %s",
call[chan].aoce,
abs(call[chan].aoce),
currency,
double2str(call[chan].pay, 6, 2, DEB));
} /* else */
@ -3694,7 +3697,7 @@ static void how_expensive(int chan)
sprintf(sx, "WARNING: Wrong ZONE (%d), assuming %d", zone, zone2);
zone = zone2;
if (call[chan].sondernummer != -1)
if (call[chan].sondernummer == -1)
info(chan, PRT_SHOWHANGUP, STATE_HANGUP, sx);
} /* if */
} /* if */
@ -4246,15 +4249,19 @@ static void processctrl(int card, char *s)
} /* else */
if (!call[chan].dialin) {
auto int l;
auto char s[BUFSIZ], sx[BUFSIZ];
extern int taktlaenge(int provider, time_t connect, int zone, char *description);
extern float taktlaenge(int chan, char *description);
l = taktlaenge(call[chan].provider, call[chan].connect, area_diff(NULL, call[chan].num[1]), s);
sprintf(sx, "NEXT CHARGEINT %d s (%s)", l, s);
if ((call[chan].cint = taktlaenge(chan, s)) > 1) {
call[chan].cinth = hour;
call[chan].nextcint = call[chan].connect + (int)call[chan].cint;
call[chan].ctakt = 1;
sprintf(sx, "NEXT CHARGEINT IN %s (%s)", double2clock(call[chan].cint), s);
info(chan, PRT_SHOWCONNECT, STATE_CONNECT, sx);
} /* if */
} /* if */
if (sound)
ringer(chan, RING_CONNECT);
@ -4664,3 +4671,63 @@ void moreinfo()
ps = s;
} /* if */
} /* moreinfo */
/*****************************************************************************/
void processcint()
{
register int chan;
auto char s[BUFSIZ], sx[BUFSIZ];
auto float newcint;
auto double exp;
auto int dur;
extern float taktlaenge(int chan, char *description);
extern double pay(time_t ts, int dauer, int tarifz, int pro);
for (chan = 0; chan < 2; chan++) {
if (!call[chan].dialin && (call[chan].cint > 1)) {
if (call[chan].nextcint == cur_time) {
dur = cur_time - call[chan].connect;
if ((call[chan].cinth != hour) && ((hour == 5) ||
(hour == 9) ||
(hour == 12) ||
(hour == 18) ||
(hour == 21) ||
(hour == 2))) { /* Moeglicherweise Taktwechsel */
newcint = taktlaenge(chan, s);
call[chan].cint = newcint;
sprintf(sx, "NEXT CHARGEINT %sIN %s (%s)", (newcint == call[chan].cint) ? "STILL " : "", double2clock((double)call[chan].cint), s);
info(chan, PRT_SHOWCONNECT, STATE_CONNECT, sx);
} /* if */
call[chan].cinth = hour;
call[chan].ctakt++;
if (1 /* message & PRT_SHOWTICKS */) {
if ((call[chan].provider == -1) || (call[chan].provider == 33))
exp = call[chan].ctakt * currency_factor;
else
/* call pay() with duration + 1 to get the charge for the _next_ chargeint! */
exp = pay(call[chan].connect, dur + 1, call[chan].zone, call[chan].provider);
sprintf(sx, "START %d.CHARGEINT %s %s (%s)",
call[chan].ctakt,
currency,
double2str(exp, 6, 2, DEB),
double2clock((double)dur));
info(chan, PRT_SHOWCONNECT, STATE_CONNECT, sx);
} /* if */
call[chan].nextcint += (int)call[chan].cint;
} /* if */
} /* if */
} /* for */
} /* processcint */

View File

@ -1,4 +1,4 @@
/* $Id: takt.c,v 1.2 1998/06/14 15:33:58 akool Exp $
/* $Id: takt.c,v 1.3 1998/06/21 11:52:57 akool Exp $
*
* ISDN accounting for isdn4linux. (log-module)
*
@ -345,31 +345,111 @@ static float gebuehr[2][6][4][3] =
{ -1.0, 60.0, 60.0 }}}};
int taktlaenge(int provider, time_t connect, int zone, char *description)
float taktlaenge(int chan, char *description)
{
register int l;
register int c;
auto struct tm *tm;
auto char why[BUFSIZ];
auto int provider = call[chan].provider;
auto time_t connect = call[chan].connect;
auto int zone = -1, zone2 = -1;
auto float takt;
*description = 0;
if (!call[chan].dialin && *call[chan].num[1]) {
if ((provider == 11) || /* o.tel.o */
(provider == 13) || /* Tele2 */
(provider == 14) || /* EWE TEL */
(provider == 15) || /* */
(provider == 23) || /* Tesion */
(provider == 24) || /* TelePassport */
(provider == 30) || /* TelDaFax */
(provider == 39) || /* tesion */
(provider == 41) || /* HanseNet */
(provider == 46) || /* KomTel */
(provider == 49) || /* ACC */
(provider == 66) || /* Interoute */
(provider == 70) || /* Arcor */
(provider == 79) || /* Viatel */
(provider == 90) || /* Viag Interkom */
(provider == 98)) /* STAR Telecom */
return(1);
if (provider == 18) /* Debitel */
return(30);
if ((provider == 36) || /* Hutchison Telekom */
(provider == 50)) /* Talkline */
return(10);
if (provider == 43) /* Hutchison Telekom */
return(60);
if (provider == 9) /* ECONOphone - mindestens jedoch 30 Sekunden! */
return(6);
tm = localtime(&connect);
if (call[chan].sondernummer != -1) {
switch (SN[call[chan].sondernummer].tarif) {
case 0 : sprintf(description, "FreeCall"); /* Free of charge */
return(60 * 60 * 24); /* one day should be enough ;-) */
case 1 : zone = 1; /* CityCall */
break;
case -1 : if ((tm->tm_wday > 0) && (tm->tm_wday < 6)) {
if ((tm->tm_hour > 8) && (tm->tm_hour < 18))
takt = SN[call[chan].sondernummer].takt1; /* Werktag 9-18 Uhr */
else
takt = SN[call[chan].sondernummer].takt2; /* Restliche Zeit */
}
else
takt = SN[call[chan].sondernummer].takt2;
strcpy(description, SN[call[chan].sondernummer].sinfo);
return(takt);
break;
} /* switch */
} /* if */
if (zone == -1) {
zone2 = area_diff(NULL, call[chan].num[1]);
if ((zone2 == -1) && (c = call[chan].confentry[OTHER]) > -1)
zone = known[c]->zone;
else
zone = zone2;
} /* if */
if (zone != -1) {
if (provider == -1)
provider = 33;
call[chan].zone = zone;
zone--;
if ((zone < 0) || (zone > 3))
return(-1);
if ((provider == 19) || (provider == 33)) {
l = gebuehr[(provider == 33) ? DTAG : MOBILCOM][zeit[tm->tm_hour]][tarifzeit(tm, why)][zone];
takt = gebuehr[(provider == 33) ? DTAG : MOBILCOM][zeit[tm->tm_hour]][tarifzeit(tm, why)][zone];
sprintf(description, "%s, %s, %s", zeiten[zeit[tm->tm_hour]], why, zonen[zone]);
return(takt);
}
else
return(-1);
}
else
return(-1);
}
else
return(-1);
return(l);
} /* taktlaenge */

View File

@ -1,4 +1,4 @@
/* $Id: tools.c,v 1.12 1998/06/07 21:09:57 akool Exp $
/* $Id: tools.c,v 1.13 1998/06/21 11:53:23 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.13 1998/06/21 11:53:23 akool
* First step to let isdnlog generate his own AOCD messages
*
* Revision 1.12 1998/06/07 21:09:57 akool
* - Accounting for the following new providers implemented:
* o.tel.o, Tele2, EWE TEL, Debitel, Mobilcom, Isis, NetCologne,
@ -644,10 +647,12 @@ char *Providername(int number)
case 11 : return("o.tel.o");
case 13 : return("Tele2");
case 14 : return("EWE TEL");
case 15 : return("???");
case 18 : return("Debitel");
case 19 : return("Mobilcom");
case 20 : return("Isis");
case 22 : return("NetCologne");
case 23 : return("Tesion");
case 24 : return("TelePassport");
case 25 : return("Citykom Muenster");
case 30 : return("TelDaFax");
@ -655,15 +660,19 @@ char *Providername(int number)
case 36 : return("Hutchison Telekom");
case 39 : return("tesion))");
case 41 : return("HanseNet");
case 43 : return("???");
case 46 : return("KomTel");
case 49 : return("ACC");
case 50 : return("Talkline");
case 55 : return("Esprit");
case 66 : return("Interoute");
case 70 : return("Arcor");
case 79 : return("Viatel");
case 85 : return("WESTCom");
case 88 : return("WorldCom");
case 90 : return("Viag Interkom");
case 98 : return("STAR Telecom");
case 99 : return("ECONOphone/Telco");
default : return("UNKNOWN Provider");
} /* switch */
} /* Providername */

View File

@ -1,4 +1,4 @@
/* $Id: tools.h,v 1.18 1998/06/07 21:10:02 akool Exp $
/* $Id: tools.h,v 1.19 1998/06/21 11:53:27 akool Exp $
*
* ISDN accounting for isdn4linux.
*
@ -20,6 +20,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: tools.h,v $
* Revision 1.19 1998/06/21 11:53:27 akool
* First step to let isdnlog generate his own AOCD messages
*
* Revision 1.18 1998/06/07 21:10:02 akool
* - Accounting for the following new providers implemented:
* o.tel.o, Tele2, EWE TEL, Debitel, Mobilcom, Isis, NetCologne,
@ -556,6 +559,11 @@ typedef struct {
int takteChargeInt;
int card;
int knock;
time_t nextcint;
float cint;
int cinth;
int ctakt;
int zone;
} CALL;
/****************************************************************************/
@ -687,6 +695,7 @@ _EXTERN double bytemax;
_EXTERN int connectmaxmode;
_EXTERN int bytemaxmode;
_EXTERN char *currency;
_EXTERN int hour;
_EXTERN int day;
_EXTERN int month;
_EXTERN int retnum;