From 673bb12c8f6519e2a7f4c44816e22bf0dd47ba69 Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Wed, 3 Jan 1996 13:52:26 +0100 Subject: [PATCH] isdn-33 --- DOKU | 5 ++++- README | 6 ++++++ isdn_4/cf.c | 17 +++++++++++++++-- isdn_4/match.c | 13 ++++++------- isdn_4/work.c | 28 ++++++++++++++++++++++++---- timer/timer.c | 28 ++++++++++++++++++++-------- tools/isdn.conf | 18 +++++++++--------- 7 files changed, 84 insertions(+), 31 deletions(-) diff --git a/DOKU b/DOKU index 85eec1f..603263d 100644 --- a/DOKU +++ b/DOKU @@ -685,10 +685,13 @@ Alle Zeilentypen: "ab" "cd" -> leere Menge "ab" "xay" -> "a" "ab" "+x" -> leere Menge - "ab" "+bx" -> "b" + "ab" "+bx" -> "ab+bx" "ab" "+bx" "a" -> leere Menge Damit läßt sich sehr flexibel einstellen, wer auf welcher Leitung / Nummer mit welchen Parametern anrufen kann. + Das Ganze ist noch optimierbar, aber ich bin zu faul... + insbesondere ist das obige "ab+bx" zu "ab" reduzierbar + (weil nur einer der hinter dem + angegebenen Flags gesetzt ist). ist der vierstellige Name der ISDN-Karte, der dieser beim Laden des Treibers verpaßt wurde; üblich ist eine dreistellike Kennung des Kartentyps und eine fortlaufende Numerierung. diff --git a/README b/README index b7daadb..979f018 100644 --- a/README +++ b/README @@ -4,6 +4,12 @@ Die Anleitung und der ganze Kram findet sich in der Datei DOKU, oder README.isdn in den Kernelsourcen. +*** 1996-01-03 + +Update 33. Timer wieder umgestellt. Testcode für automatische Anpassung des +Timeouts, noch nicht ausreichend getestet. + + *** 1996-01-02 Update 32. WICHTIG UNBEDINGT INSTALLIEREN. Verbindungen werden nicht diff --git a/isdn_4/cf.c b/isdn_4/cf.c index df2cecc..d1326fa 100644 --- a/isdn_4/cf.c +++ b/isdn_4/cf.c @@ -250,7 +250,6 @@ read_file (FILE * ffile, char *errf) c->arg[strlen(c->arg)-1] = '\0'; if (isintime(c->arg) < 0) break; chkone(c); - do_subclass(c); c->cclass = str_enter(c->cclass); c->arg = str_enter(c->arg); app (&cf_TM, c); @@ -417,6 +416,7 @@ read_args (void *nix) seqnum = 0; for(conn=isdn4_conn; conn != NULL; conn = conn->next) { + char *fp; if((cg = conn->cg) == NULL) continue; cg->dl = NULL; @@ -443,10 +443,12 @@ read_args (void *nix) theclass = "*"; for(cft = cf_TM; cft != NULL; cft = cft->next) { if((nexttime = isintime(cft->arg)) > 0) { - theclass = cft->arg; + theclass = cft->cclass; break; } } + do_run_now++; + run_now(NULL); if((nexttime == 0) || (nexttime > 32767/HZ/60)) nexttime = 32767/HZ/60; @@ -454,6 +456,17 @@ read_args (void *nix) classtimer = #endif timeout(read_args_run,NULL,nexttime * 60 * HZ); + + conn = xmalloc(sizeof(*conn)); + if(conn != NULL) { + bzero(conn,sizeof(*conn)); + conn->seqnum = ++connseq; + conn->causeInfo = "config files read"; + conn->cause = ID_priv_Print; + conn->classname = theclass; + conn->next = isdn4_conn; isdn4_conn = conn; + dropconn(conn); + } } /* Read all the files and kick off the programs. */ diff --git a/isdn_4/match.c b/isdn_4/match.c index cd1377e..4cd8bd5 100644 --- a/isdn_4/match.c +++ b/isdn_4/match.c @@ -81,6 +81,7 @@ pmatch1 (cf prot, conngrab *cgm) car = wildmatch(cg->card, prot->card); if(car == NULL) return "5ERR Match CARD"; cla =classmatch(cg->cclass, prot->cclass); if(cla == NULL) return "4ERR Match CLASS"; sub = maskmatch(cg->mask, prot->mask); if(sub == 0) return "6ERR Match SUBCARD"; + if(!classmatch(cla,theclass)) return("2Not Now"); /* OK, that fits. Make a copy to assign the values to. */ cg = newgrab(cg); @@ -116,6 +117,7 @@ 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; sub = maskmatch(cg->mask, prot->mask); if(sub==0) continue; + if(!classmatch(cla,theclass)) continue; } /* Now make another copy for the parameters. If they don't fit we'll have to undo everything. This is stupid but there is no @@ -495,6 +497,7 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); /* I hate debugging. */ continue; if ((matsub = maskmatch (cg->mask, dl->mask)) == 0) continue; + if(!classmatch(matclass,theclass)) continue; if(!(cg->flags & F_LEASED)) { /* ... and a working dial prefix. */ char *crd; ulong_t sub; @@ -555,6 +558,7 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); /* I hate debugging. */ if((matcar = wildmatch(matcrd,d->card)) == NULL) continue; if((matcla = classmatch(matclass,d->cclass)) == NULL) continue; if((matsub = maskmatch(cg->mask,d->mask)) == 0) continue; + if(!classmatch(matcla,theclass)) continue; if(cg->d_level != d->num) { if((cg->d_level < d->num) && (cg->d_nextlevel < d->num)) cg->d_nextlevel = d->num; @@ -683,7 +687,7 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); /* I hate debugging. */ struct conninfo *conn; int naconn = 0; - if(classmatch(cg->cclass,cl->cclass) == NULL) + if(classmatch(theclass,classmatch(cg->cclass,cl->cclass)) == NULL) continue; if(wildmatch(cg->card, cl->card) == NULL) continue; @@ -706,7 +710,7 @@ if(0)printf("%s.%s.!.",cg->site,cg->card); /* I hate debugging. */ continue; if((sit = wildmatch(conn->cg->site, cl->site)) == NULL) continue; - if(classmatch(conn->cg->cclass, cl->cclass) == NULL) + if(classmatch(theclass,classmatch(conn->cg->cclass, cl->cclass)) == NULL) continue; if(maskmatch(conn->cg->mask,cl->mask) == 0) continue; @@ -765,11 +769,6 @@ findit (conngrab *foo, int ignbusy) if(cg == NULL) return "NoMemFoo"; - cg->cclass = classmatch(cg->cclass,theclass); - if(cg->cclass == NULL) { - dropgrab(cg); - return "0Not Now"; - } p = cg->par_in; if(p != NULL) { diff --git a/isdn_4/work.c b/isdn_4/work.c index 8810952..1349a33 100644 --- a/isdn_4/work.c +++ b/isdn_4/work.c @@ -84,7 +84,7 @@ pushprot (conngrab cg, int minor, int connref, char update) if (!wildmatch (cg->protocol, prot->protocol)) continue; if (!wildmatch (cg->card, prot->card)) continue; if (!maskmatch (cg->mask, prot->mask)) continue; - if (!classmatch (cg->cclass, prot->cclass)) continue; + if (!classmatch(theclass,classmatch (cg->cclass, prot->cclass))) continue; break; } if (prot == NULL) @@ -158,7 +158,7 @@ pushprot (conngrab cg, int minor, int connref, char update) if (!wildmatch (cg->protocol, cm->protocol)) continue; if (!wildmatch (cg->card, cm->card)) continue; if (!maskmatch (cg->mask, cm->mask)) continue; - if (!classmatch (cg->cclass, cm->cclass)) continue; + if (!classmatch(theclass, classmatch(cg->cclass, cm->cclass))) continue; if (!wildmatch (sp1, cm->arg)) continue; mz = allocsb (strlen (cm->args), (streamchar *)cm->args); @@ -1145,7 +1145,7 @@ run_rp(struct conninfo *conn, char what) if((pro = wildmatch(conn->cg->protocol,cfr->protocol)) == NULL) continue; if((car = wildmatch(conn->cg->card,cfr->card)) == NULL) continue; if((sub = maskmatch(conn->cg->mask,cfr->mask)) == 0) continue; - if((cla = classmatch(conn->cg->cclass,cfr->cclass)) == NULL) continue; + if((cla = classmatch(theclass,classmatch(conn->cg->cclass,cfr->cclass))) == NULL) continue; if((ids = strchr(cfr->type,'/')) != NULL) id = atoi(ids); @@ -1225,7 +1225,7 @@ run_now(void *nix) continue; if(strcmp(conn->cg->protocol,what->protocol)) continue; - if(!classmatch(conn->cg->cclass,what->cclass)) + if(!classmatch(theclass,classmatch(conn->cg->cclass,what->cclass))) continue; break; } @@ -1285,6 +1285,26 @@ run_now(void *nix) if(log_34 & 2) printf("exist %s:%s\n",conn->cg->site,conn->cg->protocol); if(conn->cg != NULL && conn->minor != 0 && conn->pid != 0) { + if(conn->cg->cclass != NULL) { + char *newclass = classmatch(conn->cg->cclass, theclass); + if((newclass == NULL) && (conn->state >= c_going_up)) { + mblk_t *mb = allocb(80,BPRI_MED); + + setconnstate(conn, c_down); + if(log_34 & 2)printf("DisM8 "); + if(mb != NULL) { + int xlen; + *mb->b_wptr++ = PREF_NOERR; + m_putid (mb, CMD_OFF); + m_putsx (mb, ARG_MINOR); + m_puti (mb, conn->minor); + xlen = mb->b_wptr - mb->b_rptr; + DUMPW (mb->b_rptr, xlen); + (void) strwrite (xs_mon, (uchar_t *) mb->b_rptr, xlen, 1); + freeb(mb); + } + } + } if(conn->state >= c_going_up) pushprot(conn->cg,conn->minor,conn->connref,PUSH_UPDATE); else diff --git a/timer/timer.c b/timer/timer.c index b17814e..e288c9a 100644 --- a/timer/timer.c +++ b/timer/timer.c @@ -24,15 +24,15 @@ #ifdef KERNEL #ifdef linux #include -#define TIME (jiffies/HZ) +#define TIME jiffies #else extern struct timeval time; -#define TIME time.tv_sec +#define TIME (time.tv_sec*HZ + time.tv_usec/(1000000/HZ)) #endif #else extern struct timeval Time; -#define TIME time.tv_sec +#define TIME (time.tv_sec*HZ + time.tv_usec/(1000000/HZ)) #define time Time #endif @@ -72,6 +72,7 @@ struct timer_ { #define TIMER_INCOMING 040 #define TIMER_IFDATA_IN 0100 #define TIMER_IFDATA_OUT 0200 + int lasttime; int interval; int pretime; int maxread, maxwrite; @@ -129,7 +130,7 @@ timer_timeout(struct timer_ *tim) #ifdef NEW_TIMEOUT tim->timer = #endif - timeout((void *)timer_timeout,tim,tim->interval); + timeout((void *)timer_timeout,tim,tim->interval-HZ); } /* Streams code to close the driver. */ @@ -174,6 +175,12 @@ timer_proto (queue_t * q, mblk_t * mp, char down) default: break; case PROTO_TICK: + if(tim->lasttime && (tim->lasttime < TIME)) { + if(tim->interval > TIME - tim->lasttime) /* shorter! */ + tim->interval = TIME - tim->lasttime; + /* if it gets longer we won't do a thing. */ + } + tim->lasttime = TIME; if(tim->flags & TIMER_TIMER) { #ifdef NEW_TIMEOUT untimeout(tim->timer); @@ -181,7 +188,10 @@ timer_proto (queue_t * q, mblk_t * mp, char down) untimeout(timer_timeout,tim); #endif - timer_timeout(tim); +#ifdef NEW_TIMEOUT + tim->timer = +#endif + timeout((void *)timer_timeout,tim,tim->interval-HZ); } break; case PROTO_INCOMING: @@ -202,12 +212,13 @@ timer_proto (queue_t * q, mblk_t * mp, char down) #ifdef NEW_TIMEOUT tim->timer = #endif - timeout((void *)timer_timeout,tim,tim->pretime); + timeout((void *)timer_timeout,tim,tim->pretime-HZ); tim->flags |= TIMER_TIMER; break; default: break; } + tim->lasttime = 0; break; case PROTO_DISCONNECT: case PROTO_INTERRUPT: @@ -275,6 +286,7 @@ timer_proto (queue_t * q, mblk_t * mp, char down) if(z < 1 || z > 24*60*60) goto err; tim->interval = z*HZ; + tim->lasttime = 0; /* for sync */ break; case TIMER_PRETIME: if ((error = m_geti (mp, &z)) != 0) @@ -288,14 +300,14 @@ timer_proto (queue_t * q, mblk_t * mp, char down) goto err; if (z < 2 || z >= 7*24*60*60) goto err; - tim->maxread = z; + tim->maxread = z*HZ; break; case TIMER_WRITEMAX: if ((error = m_geti (mp, &z)) != 0) goto err; if (z < 2 || z >= 7*24*60*60) goto err; - tim->maxwrite = z; + tim->maxwrite = z*HZ; break; } } diff --git a/tools/isdn.conf b/tools/isdn.conf index cfd7cd2..1eb3704 100644 --- a/tools/isdn.conf +++ b/tools/isdn.conf @@ -206,15 +206,15 @@ MP * * +I * - timer :tr 4 :tw 4 :ti 2 :to 3 :lo # Grmbl. Innerdeutsch 9 Uhr, ausserhalb 8 Uhr, USA 14 Uhr. # a-e: deutsch; fg: Euro1, hi: USA -TM +dgi Mo-Fr0500-0800 -TM +dfi Mo-Fr0800-0900 -TM +afi Mo-Fr0900-1200 -TM +bfi Mo-Fr1200-1400 -TM +bfh Mo-Fr1400-1800 -TM +cgh Mo-Fr1800-2100 -TM +dgh Mo-Fr2100-0200 -TM +egh Mo-Fr0200-0300 -TM +egi Mo-Fr0300-0500 +TM +dgi Wk0500-0800 +TM +dfi Wk0800-0900 +TM +afi Wk0900-1200 +TM +bfi Wk1200-1400 +TM +bfh Wk1400-1800 +TM +cgh Wk1800-2100 +TM +dgh Wk2100-0200 +TM +egh Wk0200-0300 +TM +egi Wk0300-0500 TM +cgi SaSu0500-1400 TM +cgh SaSu1400-2100 TM +dgh SaSu2100-0200