summaryrefslogtreecommitdiffstats
path: root/usr.sbin/i4b/isdnd
diff options
context:
space:
mode:
authorhm <hm@FreeBSD.org>2000-10-09 14:22:51 +0000
committerhm <hm@FreeBSD.org>2000-10-09 14:22:51 +0000
commit5ab5e2a391ce47dd5453a8592c99baf8e9b2a6f4 (patch)
tree26a8d414a4a8b7be8fb22e1e65e5ba4889daf0ae /usr.sbin/i4b/isdnd
parentf334879ea56c48ab237e6528968d81dd32e9f209 (diff)
downloadFreeBSD-src-5ab5e2a391ce47dd5453a8592c99baf8e9b2a6f4.zip
FreeBSD-src-5ab5e2a391ce47dd5453a8592c99baf8e9b2a6f4.tar.gz
update to i4b version 0.95.04
Diffstat (limited to 'usr.sbin/i4b/isdnd')
-rw-r--r--usr.sbin/i4b/isdnd/Makefile2
-rw-r--r--usr.sbin/i4b/isdnd/controller.c12
-rw-r--r--usr.sbin/i4b/isdnd/curses.c276
-rw-r--r--usr.sbin/i4b/isdnd/exec.c130
-rw-r--r--usr.sbin/i4b/isdnd/fsm.c6
-rw-r--r--usr.sbin/i4b/isdnd/holiday.c202
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.845
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.acct.53
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.h101
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.rates.512
-rw-r--r--usr.sbin/i4b/isdnd/isdnd.rc.5487
-rw-r--r--usr.sbin/i4b/isdnd/log.c4
-rw-r--r--usr.sbin/i4b/isdnd/main.c18
-rw-r--r--usr.sbin/i4b/isdnd/monitor.c2
-rw-r--r--usr.sbin/i4b/isdnd/msghdl.c130
-rw-r--r--usr.sbin/i4b/isdnd/pathnames.h13
-rw-r--r--usr.sbin/i4b/isdnd/pcause.c2
-rw-r--r--usr.sbin/i4b/isdnd/rates.c2
-rw-r--r--usr.sbin/i4b/isdnd/rc_config.c519
-rw-r--r--usr.sbin/i4b/isdnd/rc_parse.y61
-rw-r--r--usr.sbin/i4b/isdnd/rc_scan.l25
-rw-r--r--usr.sbin/i4b/isdnd/support.c243
-rw-r--r--usr.sbin/i4b/isdnd/timer.c28
23 files changed, 2007 insertions, 316 deletions
diff --git a/usr.sbin/i4b/isdnd/Makefile b/usr.sbin/i4b/isdnd/Makefile
index 53978b2..5c05b85 100644
--- a/usr.sbin/i4b/isdnd/Makefile
+++ b/usr.sbin/i4b/isdnd/Makefile
@@ -5,7 +5,7 @@ PROG = isdnd
SRCS = rc_parse.y rc_scan.l main.c rc_config.c log.c curses.c \
process.c rates.c msghdl.c fsm.c support.c timer.c \
exec.c dial.c monitor.c pcause.c controller.c alias.c \
- y.tab.h
+ y.tab.h holiday.c
COPTS += -I${.CURDIR}/../isdnmonitor -I${.CURDIR}/../isdntel -I${.OBJDIR}
diff --git a/usr.sbin/i4b/isdnd/controller.c b/usr.sbin/i4b/isdnd/controller.c
index 0880a7c..3da8274 100644
--- a/usr.sbin/i4b/isdnd/controller.c
+++ b/usr.sbin/i4b/isdnd/controller.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* i4b daemon - controller state support routines
* ----------------------------------------------
*
- * $Id: controller.c,v 1.19 1999/12/13 21:25:24 hm Exp $
+ * $Id: controller.c,v 1.23 2000/10/09 12:53:29 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:45:34 1999]
+ * last edit-date: [Mon Oct 9 14:37:34 2000]
*
*---------------------------------------------------------------------------*/
@@ -69,7 +69,11 @@ name_of_controller(int ctrl_type, int card_type)
"ELSA PCC-16",
"AVM Fritz!Card PnP",
"Siemens I-Surf 2.0 PnP",
- "Asuscom ISDNlink 128K PnP"
+ "Asuscom ISDNlink 128K PnP",
+ "ASUSCOM P-IN100-ST-D (Winbond W6692)",
+ "Teles S0/16.3c PnP",
+ "AcerISDN P10 PnP",
+ "TELEINT ISDN SPEED No. 1"
};
static char *daic_card[] = {
diff --git a/usr.sbin/i4b/isdnd/curses.c b/usr.sbin/i4b/isdnd/curses.c
index 0c50be2..cd4191f 100644
--- a/usr.sbin/i4b/isdnd/curses.c
+++ b/usr.sbin/i4b/isdnd/curses.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* i4b daemon - curses fullscreen output
* -------------------------------------
*
- * $Id: curses.c,v 1.29 1999/12/13 21:25:24 hm Exp $
+ * $Id: curses.c,v 1.36 2000/10/09 12:53:29 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:45:43 1999]
+ * last edit-date: [Thu Jun 1 16:24:43 2000]
*
*---------------------------------------------------------------------------*/
@@ -41,6 +41,10 @@
#define CHPOS(cfgp) (((cfgp)->isdncontrollerused*2) + (cfgp)->isdnchannelused)
+static void display_budget(void);
+static void display_cards(void);
+static void menuexit(WINDOW *menu_w);
+
/*---------------------------------------------------------------------------*
* init curses fullscreen display
*---------------------------------------------------------------------------*/
@@ -118,9 +122,6 @@ init_screen(void)
addstr(buffer);
standend();
- move(uheight+5, 0);
- addstr("Date Time Typ Information Description");
-
refresh();
for(i=0, j=0; i <= ncontroller; i++, j+=2)
@@ -161,8 +162,10 @@ do_menu(void)
{
"1 - (D)isplay refresh",
"2 - (H)angup (choose a channel)",
- "3 - (R)eread config file",
- "4 - (Q)uit the program",
+ "3 - (R)eread config file",
+ "4 - (S)how card types",
+ "5 - (B)udget information",
+ "6 - (Q)uit the program",
};
WINDOW *menu_w;
@@ -170,7 +173,7 @@ do_menu(void)
int mpos;
fd_set set;
struct timeval timeout;
-
+
/* create a new window in the lower screen area */
if((menu_w = newwin(WMENU_HGT, WMENU_LEN, WMENU_POSLN, WMENU_POSCO )) == NULL)
@@ -232,6 +235,12 @@ do_menu(void)
wstandend(menu_w);
break;
+ case ('0'+WBUDGET+1): /* display budget info */
+ case 'B':
+ case 'b':
+ display_budget();
+ goto mexit;
+
case ('0'+WREFRESH+1): /* display refresh */
case 'D':
case 'd':
@@ -241,6 +250,7 @@ do_menu(void)
case ('0'+WQUIT+1): /* quit program */
case 'Q':
case 'q':
+ menuexit(menu_w);
do_exit(0);
goto mexit;
@@ -256,6 +266,12 @@ do_menu(void)
rereadconfig(42);
goto mexit;
+ case ('0'+WSHOW+1): /* reread config file */
+ case 'S':
+ case 's':
+ display_cards();
+ goto mexit;
+
case '\n':
case '\r': /* exec highlighted option */
switch(mpos)
@@ -265,6 +281,7 @@ do_menu(void)
break;
case WQUIT:
+ menuexit(menu_w);
do_exit(0);
break;
@@ -275,6 +292,14 @@ do_menu(void)
case WREREAD:
rereadconfig(42);
break;
+
+ case WBUDGET:
+ display_budget();
+ break;
+
+ case WSHOW:
+ display_cards();
+ break;
}
goto mexit;
break;
@@ -286,14 +311,53 @@ do_menu(void)
}
mexit:
+ menuexit(menu_w);
+}
+
+static void
+menuexit(WINDOW *menu_w)
+{
+ int uheight = ncontroller * 2; /* cards * b-channels */
+ char buffer[512];
+
/* delete the menu window */
delwin(menu_w);
/* re-display the original lower window contents */
+ touchwin(mid_w);
+ wrefresh(mid_w);
+
touchwin(lower_w);
wrefresh(lower_w);
+
+ touchwin(upper_w);
+ wrefresh(upper_w);
+
+ move(1, 0);
+ /* 01234567890123456789012345678901234567890123456789012345678901234567890123456789 */
+ addstr("c tei b remote iface dir outbytes obps inbytes ibps units");
+
+ sprintf(buffer, "----- isdn userland interface state ------------------------------------------");
+ while(strlen(buffer) < COLS)
+ strcat(buffer, "-");
+
+ move(uheight+2, 0);
+ standout();
+ addstr(buffer);
+ standend();
+
+ sprintf(buffer, "----- isdnd logfile display --------------------------------------------------");
+ while(strlen(buffer) < COLS)
+ strcat(buffer, "-");
+
+ move(uheight+4, 0);
+ standout();
+ addstr(buffer);
+ standend();
+
+ refresh();
}
/*---------------------------------------------------------------------------*
@@ -630,6 +694,200 @@ display_chans(void)
delwin(chan_w);
}
+/*---------------------------------------------------------------------------*
+ * display card type information
+ *---------------------------------------------------------------------------*/
+static void
+display_cards(void)
+{
+ WINDOW *chan_w;
+ int nlines, ncols, pos_x, pos_y;
+ fd_set set;
+ struct timeval timeout;
+ int i;
+
+ nlines = 6+ncontroller;
+ ncols = 60;
+ pos_y = WMENU_POSLN;
+ pos_x = WMENU_POSCO;
+
+ /* create a new window in the lower screen area */
+
+ if((chan_w = newwin(nlines, ncols, pos_y, pos_x )) == NULL)
+ {
+ log(LL_WRN, "ERROR, curses init channel window!");
+ return;
+ }
+
+ /* create a border around the window */
+
+ box(chan_w, '|', '-');
+
+ /* add a title */
+
+ wstandout(chan_w);
+ mvwaddstr(chan_w, 0, (ncols / 2) - (strlen("Cards") / 2), "Cards");
+ wstandend(chan_w);
+
+ mvwprintw(chan_w, 2, 2, "ctrl description");
+ mvwprintw(chan_w, 3, 2, "---- ----------------------------------------------");
+ for (i = 0; i < ncontroller; i++)
+ {
+ mvwprintw(chan_w, 4+i, 2, " #%d %s", i,
+ name_of_controller(isdn_ctrl_tab[i].ctrl_type,
+ isdn_ctrl_tab[i].card_type));
+ }
+
+ wrefresh(chan_w);
+
+ FD_ZERO(&set);
+ FD_SET(STDIN_FILENO, &set);
+ timeout.tv_sec = WMTIMEOUT*2;
+ timeout.tv_usec = 0;
+
+ if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
+ {
+ delwin(chan_w);
+ return;
+ }
+
+ wgetch(chan_w);
+ delwin(chan_w);
+}
+
+/*---------------------------------------------------------------------------*
+ * display budget info
+ *---------------------------------------------------------------------------*/
+static void
+display_budget(void)
+{
+ WINDOW *bud_w;
+ int nlines, ncols, pos_x, pos_y;
+ fd_set set;
+ struct timeval timeout;
+ int i, j;
+ cfg_entry_t *cep;
+ time_t now;
+ double uptime;
+ int minutes;
+ int hours;
+ int days;
+
+ nlines = 0;
+ ncols = 73;
+ pos_y = WMENU_POSLN;
+ pos_x = WMENU_POSCO-3;
+
+ for(i=0, j=0; i < nentries; i++) /* walk thru all entries */
+ {
+ cep = &cfg_entry_tab[i]; /* get ptr to entry */
+
+ if(cep->budget_callbackperiod && cep->budget_callbackncalls)
+ nlines++;
+ if(cep->budget_calloutperiod && cep->budget_calloutncalls)
+ nlines++;
+ }
+
+ if(nlines == 0)
+ return;
+
+ nlines += 6;
+
+ /* create a new window in the lower screen area */
+
+ if((bud_w = newwin(nlines, ncols, pos_y, pos_x )) == NULL)
+ {
+ log(LL_WRN, "ERROR, curses init budget window!");
+ return;
+ }
+
+ now = time(NULL);
+ uptime = difftime(now, starttime);
+
+ minutes = (time_t) (uptime / 60) % 60;
+ hours = (time_t) (uptime / (60*60)) % (60*60);
+ days = (time_t) (uptime / (60*60*24)) % (60*60*24);
+
+ uptime = uptime / (60*60);
+
+ /* create a border around the window */
+
+ box(bud_w, '|', '-');
+
+ /* add a title */
+
+ wstandout(bud_w);
+ mvwaddstr(bud_w, 0, (ncols / 2) - (strlen("Budget") / 2), "Budget");
+ wstandend(bud_w);
+
+ mvwprintw(bud_w, 1, 2, "isdnd uptime: %d %s - %d %s - %d %s",
+ days,
+ days == 1 ? "day" : "days",
+ hours,
+ hours == 1 ? "hour" : "hours",
+ minutes,
+ minutes == 1 ? "minute" : "minutes");
+
+ mvwprintw(bud_w, 2, 2, "name t period rest ncall rest rqsts /hr rdone /hr rrjct /hr ");
+ mvwprintw(bud_w, 3, 2, "-------- - ------ ------ ----- ----- ----- ---- ----- ---- ----- ----");
+
+ for(i=0, j=4; i < nentries; i++) /* walk thru all entries */
+ {
+ cep = &cfg_entry_tab[i]; /* get ptr to enry */
+
+ if(cep->budget_calloutperiod && cep->budget_calloutncalls)
+ {
+ mvwprintw(bud_w, j, 2, "%-8s %c %-6d %-6ld %-5d %-5d %-5d %-4.1f %-5d %-4.1f %-5d %-4.1f",
+ cep->name,
+ 'o',
+ cep->budget_calloutperiod,
+ (long)(cep->budget_calloutperiod_time - now),
+ cep->budget_calloutncalls,
+ cep->budget_calloutncalls_cnt,
+ cep->budget_callout_req,
+ (double)cep->budget_callout_req / uptime,
+ cep->budget_callout_done,
+ (double)cep->budget_callout_done / uptime,
+ cep->budget_callout_rej,
+ (double)cep->budget_callout_rej / uptime);
+ j++;
+ }
+ if(cep->budget_callbackperiod && cep->budget_callbackncalls)
+ {
+ mvwprintw(bud_w, j, 2, "%-8s %c %-6d %-6ld %-5d %-5d %-5d %-4.1f %-5d %-4.1f %-5d %-4.1f",
+ (cep->budget_calloutperiod && cep->budget_calloutncalls) ? "" : cep->name,
+ 'b',
+ cep->budget_callbackperiod,
+ (long)(cep->budget_callbackperiod_time - now),
+ cep->budget_callbackncalls,
+ cep->budget_callbackncalls_cnt,
+ cep->budget_callback_req,
+ (double)cep->budget_callback_req / uptime,
+ cep->budget_callback_done,
+ (double)cep->budget_callback_done / uptime,
+ cep->budget_callback_rej,
+ (double)cep->budget_callback_rej / uptime);
+ j++;
+ }
+ }
+
+ wrefresh(bud_w);
+
+ FD_ZERO(&set);
+ FD_SET(STDIN_FILENO, &set);
+ timeout.tv_sec = WMTIMEOUT*3;
+ timeout.tv_usec = 0;
+
+ if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
+ {
+ delwin(bud_w);
+ return;
+ }
+
+ wgetch(bud_w);
+ delwin(bud_w);
+}
+
#endif
/* EOF */
diff --git a/usr.sbin/i4b/isdnd/exec.c b/usr.sbin/i4b/isdnd/exec.c
index ecde73a..db08e77 100644
--- a/usr.sbin/i4b/isdnd/exec.c
+++ b/usr.sbin/i4b/isdnd/exec.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* exec.h - supplemental program/script execution
* ----------------------------------------------
*
- * $Id: exec.c,v 1.13 1999/12/13 21:25:24 hm Exp $
+ * $Id: exec.c,v 1.23 2000/10/09 12:53:29 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:45:59 1999]
+ * last edit-date: [Wed Sep 27 09:39:22 2000]
*
*---------------------------------------------------------------------------*/
@@ -139,6 +139,19 @@ exec_prog(char *prog, char **arglist)
/* this is the child now */
+ /*
+ * close files used only by isdnd, e.g.
+ * 1. /dev/i4b
+ * 2. /var/log/isdnd.acct (or similar, when used)
+ * 3. /var/log/isdnd.log (or similar, when used)
+ */
+ close(isdnfd);
+ if(useacctfile)
+ fclose(acctfp);
+ if(uselogfile)
+ fclose(logfp);
+
+
if(execvp(path,arglist) < 0 )
_exit(127);
@@ -279,4 +292,115 @@ check_and_kill(cfg_entry_t *cep)
}
}
+/*---------------------------------------------------------------------------*
+ * update budget callout/callback statistics counter file
+ *---------------------------------------------------------------------------*/
+void
+upd_callstat_file(char *filename, int rotateflag)
+{
+ FILE *fp;
+ time_t s, l, now;
+ int n;
+ int ret;
+
+ now = time(NULL);
+
+ fp = fopen(filename, "r+");
+
+ if(fp == NULL)
+ {
+ /* file not there, create it and exit */
+
+ log(LL_WRN, "upd_callstat_file: creating %s", filename);
+
+ fp = fopen(filename, "w");
+ if(fp == NULL)
+ {
+ log(LL_ERR, "ERROR, upd_callstat_file: cannot create %s, %s", filename, strerror(errno));
+ return;
+ }
+
+ ret = fprintf(fp, "%ld %ld 1", now, now);
+ if(ret <= 0)
+ log(LL_ERR, "ERROR, upd_callstat_file: fprintf failed: %s", strerror(errno));
+
+ fclose(fp);
+ return;
+ }
+
+ /* get contents */
+
+ ret = fscanf(fp, "%ld %ld %d", &s, &l, &n);
+
+ /* reset fp */
+
+ rewind(fp);
+
+ if(ret != 3)
+ {
+ /* file corrupt ? anyway, initialize */
+
+ log(LL_WRN, "upd_callstat_file: initializing %s", filename);
+
+ s = l = now;
+ n = 0;
+ }
+
+ if(rotateflag)
+ {
+ struct tm *stmp;
+ int dom;
+
+ /* get day of month for last timestamp */
+ stmp = localtime(&l);
+ dom = stmp->tm_mday;
+
+ /* get day of month for just now */
+ stmp = localtime(&now);
+
+ if(dom != stmp->tm_mday)
+ {
+ FILE *nfp;
+ char buf[MAXPATHLEN];
+
+ /* new day, write last days stats */
+
+ sprintf(buf, "%s-%02d", filename, stmp->tm_mday);
+
+ nfp = fopen(buf, "w");
+ if(nfp == NULL)
+ {
+ log(LL_ERR, "ERROR, upd_callstat_file: cannot open for write %s, %s", buf, strerror(errno));
+ return;
+ }
+
+ ret = fprintf(nfp, "%ld %ld %d", s, l, n);
+ if(ret <= 0)
+ log(LL_ERR, "ERROR, upd_callstat_file: fprintf failed: %s", strerror(errno));
+
+ fclose(nfp);
+
+ /* init new days stats */
+ n = 0;
+ s = now;
+
+ log(LL_WRN, "upd_callstat_file: rotate %s, new s=%ld l=%ld n=%d", filename, s, l, n);
+ }
+ }
+
+ n++; /* increment call count */
+
+ /*
+ * the "%-3d" is necessary to overwrite any
+ * leftovers from previous contents!
+ */
+
+ ret = fprintf(fp, "%ld %ld %-3d", s, now, n);
+
+ if(ret <= 0)
+ log(LL_ERR, "ERROR, upd_callstat_file: fprintf failed: %s", strerror(errno));
+
+ fclose(fp);
+}
+
/* EOF */
diff --git a/usr.sbin/i4b/isdnd/fsm.c b/usr.sbin/i4b/isdnd/fsm.c
index 63a6229..0dcf345 100644
--- a/usr.sbin/i4b/isdnd/fsm.c
+++ b/usr.sbin/i4b/isdnd/fsm.c
@@ -27,7 +27,7 @@
* FSM for isdnd
* -------------
*
- * $Id: fsm.c,v 1.18 1999/12/13 21:25:24 hm Exp $
+ * $Id: fsm.c,v 1.19 2000/08/20 08:08:51 hm Exp $
*
* $FreeBSD$
*
@@ -212,7 +212,7 @@ F_DFL(cfg_entry_t *cep)
{
cep->dial_count++;
- if(cep->dial_count < cep->dialretries)
+ if(cep->dial_count < cep->dialretries || cep->dialretries == -1) /* Added by FST <mailto:fsteevie@dds.nl> for unlimited dialing (sorry, but I needed it) */
{
/* inside normal retry cycle */
@@ -290,7 +290,7 @@ F_ACBR(cfg_entry_t *cep)
{
cep->dial_count++;
- if(cep->dial_count < cep->dialretries)
+ if(cep->dial_count < cep->dialretries || cep->dialretries == -1) /* Added by FST <mailto:fsteevie@dds.nl> for unlimited dialing (sorry, but I needed it) */
{
/* inside normal retry cycle */
diff --git a/usr.sbin/i4b/isdnd/holiday.c b/usr.sbin/i4b/isdnd/holiday.c
new file mode 100644
index 0000000..7bcc0b0
--- /dev/null
+++ b/usr.sbin/i4b/isdnd/holiday.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2000, Hellmuth Michaelis. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *---------------------------------------------------------------------------
+ *
+ * isdnd - holiday file handling
+ * =============================
+ *
+ * $Id: holiday.c,v 1.1 2000/10/09 11:17:07 hm Exp $
+ *
+ * $FreeBSD$
+ *
+ * last edit-date: [Mon Oct 9 11:32:28 2000]
+ *
+ * Format:
+ *
+ * day.month.year optional comment (different day every year) or
+ * day.month optional comment (same day every year)
+ *
+ * i.e.:
+ *
+ * 23.4.2000 Ostersonntag
+ * 3.10 Tag der deutschen Einheit
+ *
+ *
+ *
+ *----------------------------------------------------------------------------*/
+
+#include "isdnd.h"
+
+struct holiday {
+ int day;
+ int month;
+ int year;
+ struct holiday *next;
+};
+
+static struct holiday *firsth = NULL;
+
+#define MAXBUFSZ 256
+
+static void free_holiday(struct holiday *ptr);
+
+/*---------------------------------------------------------------------------*
+ * read in and init holidayes
+ *---------------------------------------------------------------------------*/
+void
+init_holidays(char *filename)
+{
+ FILE *fp;
+ unsigned char buffer[MAXBUFSZ + 1];
+ struct holiday *newh = NULL;
+ struct holiday *lasth = NULL;
+ int ret;
+ int day, month, year;
+
+ firsth = NULL;
+
+ if((fp = fopen(filename, "r")) == NULL)
+ {
+ log(LL_ERR, "init_holiday: error opening holidayfile %s: %s!", filename, strerror(errno));
+ exit(1);
+ }
+
+ while((fgets(buffer, MAXBUFSZ, fp)) != NULL)
+ {
+ if(buffer[0] == '#' || buffer[0] == ' ' ||
+ buffer[0] == '\t' || buffer[0] == '\n')
+ {
+ continue;
+ }
+
+ ret = sscanf(buffer, "%d.%d.%d", &day, &month, &year);
+
+ if(ret != 3)
+ {
+ ret = sscanf(buffer, "%d.%d", &day, &month);
+ if(ret != 2)
+ {
+ log(LL_ERR, "init_holiday: parse error for string [%s]!", buffer);
+ exit(1);
+ }
+ year = 0;
+ }
+
+ if((newh = (struct holiday *) malloc(sizeof(struct holiday))) == NULL)
+ {
+ log(LL_ERR, "init_holiday: malloc failed for struct holiday!\n");
+ exit(1);
+ }
+
+ if(year)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "init_holidays: add %d.%d.%d", day, month, year)));
+ }
+ else
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "init_holidays: add %d.%d", day, month)));
+ }
+
+ newh->day = day;
+ newh->month = month;
+ newh->year = year;
+ newh->next = NULL;
+
+ if(firsth == NULL)
+ {
+ firsth = newh;
+ }
+ else
+ {
+ lasth->next = newh;
+ }
+ lasth = newh;
+ }
+ fclose(fp);
+}
+
+/*---------------------------------------------------------------------------*
+ * free all holidays
+ *---------------------------------------------------------------------------*/
+void
+free_holidays(void)
+{
+ free_holiday(firsth);
+}
+
+/*---------------------------------------------------------------------------*
+ * free holidayes
+ *---------------------------------------------------------------------------*/
+static void
+free_holiday(struct holiday *ptr)
+{
+
+ if(ptr == NULL)
+ return;
+
+ if(ptr->next != NULL)
+ free_holiday(ptr->next);
+
+ free(ptr);
+}
+
+/*---------------------------------------------------------------------------*
+ * check if date/month/year is a holiday
+ *---------------------------------------------------------------------------*/
+int
+isholiday(int d, int m, int y)
+{
+ struct holiday *ch = NULL;
+
+ if(firsth == NULL)
+ return(0);
+
+ ch = firsth;
+
+ for(;;)
+ {
+ if(ch->day == d && ch->month == m)
+ {
+ if(ch->year == 0)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isholiday: %d.%d is a holiday!", d, m)));
+ return(1);
+ }
+ else if(ch->year == y)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isholiday: %d.%d.%d is a holiday!", d, m, y)));
+ return(1);
+ }
+ }
+
+ if(ch->next == NULL)
+ break;
+
+ ch = ch->next;
+ }
+ return(0);
+}
+
+/* EOF */
diff --git a/usr.sbin/i4b/isdnd/isdnd.8 b/usr.sbin/i4b/isdnd/isdnd.8
index 69f06fa..34746c1 100644
--- a/usr.sbin/i4b/isdnd/isdnd.8
+++ b/usr.sbin/i4b/isdnd/isdnd.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+.\" Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -22,13 +22,13 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: isdnd.8,v 1.27 1999/12/13 22:11:55 hm Exp $
+.\" $Id: isdnd.8,v 1.29 2000/05/02 11:50:28 hm Exp $
.\"
.\" $FreeBSD$
.\"
-.\" last edit-date: [Mon Dec 13 22:57:10 1999]
+.\" last edit-date: [Tue May 2 13:45:12 2000]
.\"
-.Dd February 23, 1999
+.Dd May 2, 2000
.Dt ISDND 8
.Os
.Sh NAME
@@ -66,8 +66,7 @@ instead of the default file
If debugging support is compiled into
.Nm isdnd
this option is used to specify the debugging level, or better which kind
-of debugging messages are displayed.
-The debugging level is the sum of the
+of debugging messages are displayed. The debugging level is the sum of the
following values:
.Pp
.Bl -tag -width Ds -compact -offset indent
@@ -91,6 +90,8 @@ isdn4bsd kernel i/o calls.
controller and channel busy/free messages.
.It Ar 0x200
isdnd.rc configuration file processing.
+.It Ar 0x400
+outgoing call budget handling.
.El
.Pp
The value can be specified in any number base supported by the
@@ -103,16 +104,14 @@ disable displaying debug messages on the full-screen display.
.It Fl f
Specifying this option causes
.Nm isdnd
-to enter the full-screen mode of operation.
-When operating in this mode,
+to enter the full-screen mode of operation. When operating in this mode,
entering the control character
.Em Control-L
causes the display to be refreshed and entering
.Em Carriage-Return
or
.Em Enter
-will pop-up a command window.
-Because the
+will pop-up a command window. Because the
.Nm
daemon will not listen to messages while the command window is active,
this command window will disappear automatically after 5 seconds without
@@ -122,8 +121,7 @@ While the command window is active,
.Em Tab
or
.Em Space
-advances to the next menu item.
-To execute a command, press
+advances to the next menu item. To execute a command, press
.Em Return
or
.Em Enter
@@ -137,16 +135,13 @@ facility but instead is appended to a file.
.It Fl L
Specifies the name of the logfile which is used when the option
.Em -l
-is set.
-See also the keyword
+is set. See also the keyword
.Em rotatesuffix
in the system section of
.Xr isdnd.rc 5 .
.It Fl P
This option prints out the parsed and verified isdnd configuration in the same
-format as the isdnd.rc file.
-This output can be used as an isdnd.rc file.
-This
+format as the isdnd.rc file. This output can be used as an isdnd.rc file. This
feature is especially useful when debugging an isdnd.rc file to see, what the
default settings of options are when they are not set in the isdnd.rc input
file.
@@ -170,8 +165,7 @@ and on which the full-screen mode output is displayed.
This option may be used to specify the logging facility in case
.Xr syslog 3
logging is configured and another facility than the default LOCAL0
-facility shall be used.
-The facility is to be specified as an integer in
+facility shall be used. The facility is to be specified as an integer in
the range 0-11 or 16-23 (see the file /usr/include/syslog.h).
.It Fl t
In conjunction with the
@@ -183,8 +177,7 @@ options,
specifies a terminal type or termcap entry name (such as vt220) for the device
used for
.Nm isdnd
-full-screen output.
-This is useful if an unused (no getty running) tty line is
+full-screen output. This is useful if an unused (no getty running) tty line is
used for full-screen output for which no
.Li TERM
environment variable exists.
@@ -196,8 +189,7 @@ is set to
.Em cmdl .
.It Fl m
If the isdn daemon is compiled with local or remote monitoring support,
-this option disables all monitoring access.
-It overrides the config
+this option disables all monitoring access. It overrides the config
file option
.Em monitor-allowed .
.El
@@ -284,8 +276,7 @@ After getting the CDID, the daemon looks up several additional information
in its entry section of the configuration corresponding to that connection
and issues a
.Em I4B_CONNECT_REQ
-ioctl message to the kernel.
-The kernel now dials the remote side and
+ioctl message to the kernel. The kernel now dials the remote side and
if the remote side accepts the call, the kernel sends a
.Em MSG_CONNECT_ACTIVE_IND
to the daemon.
@@ -334,8 +325,7 @@ message and the CDID corresponding to the call is no longer valid.
Sending a HUP signal to
.Nm
causes all open connections to be terminated and the configuration file is
-reread.
-In case aliasfile handling was enabled, the aliasfile is also
+reread. In case aliasfile handling was enabled, the aliasfile is also
reread.
Sending a USR1 signal to
@@ -424,6 +414,7 @@ Exit status is 0 on success, 1 on error.
.Xr isdnd.rates 5 ,
.Xr i4bisppp 4 ,
.Xr i4bipr 4
+.Xr i4bing 4
.Sh BUGS
Still one or more left.
diff --git a/usr.sbin/i4b/isdnd/isdnd.acct.5 b/usr.sbin/i4b/isdnd/isdnd.acct.5
index 8813db8..3ee378b 100644
--- a/usr.sbin/i4b/isdnd/isdnd.acct.5
+++ b/usr.sbin/i4b/isdnd/isdnd.acct.5
@@ -64,8 +64,7 @@ is the time the connection was established in the format
.Dl Day.Month.Year Hour:Minutes:seconds
.Pp
.Em UNTIL
-is the time the connection was closed.
-The format is the same as
+is the time the connection was closed. The format is the same as
described for
.Em FROM
above.
diff --git a/usr.sbin/i4b/isdnd/isdnd.h b/usr.sbin/i4b/isdnd/isdnd.h
index 9565915..627744a 100644
--- a/usr.sbin/i4b/isdnd/isdnd.h
+++ b/usr.sbin/i4b/isdnd/isdnd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* i4b daemon - main header file
* -----------------------------
*
- * $Id: isdnd.h,v 1.72 1999/12/13 21:25:24 hm Exp $
+ * $Id: isdnd.h,v 1.82 2000/10/09 11:17:07 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:46:50 1999]
+ * last edit-date: [Wed Oct 4 14:11:46 2000]
*
*---------------------------------------------------------------------------*/
@@ -102,6 +102,7 @@
#define DL_DRVR 0x0080 /* messages related to kernel i4b msg i/o*/
#define DL_CNST 0x0100 /* messages related to controller state */
#define DL_RCCF 0x0200 /* messages related to isdnd.rc at boot */
+#define DL_BDGT 0x0400 /* messages related to budgets */
#ifdef DEBUG
#define DBGL(cond, dolog) if(cond & debug_flags) dolog
@@ -134,13 +135,15 @@
#define WMENU_TITLE "Command" /* title string */
#define WMENU_POSLN 10 /* menu position, line */
#define WMENU_POSCO 5 /* menu position, col */
-#define WMITEMS 4 /* no of menu items */
+#define WMITEMS 6 /* no of menu items */
#define WMENU_HGT (WMITEMS + 4) /* menu window height */
#define WREFRESH 0
#define WHANGUP 1
#define WREREAD 2
-#define WQUIT 3
+#define WSHOW 3
+#define WBUDGET 4
+#define WQUIT 5
#define WMTIMEOUT 5 /* timeout in seconds */
@@ -335,6 +338,49 @@ typedef struct cfg_entry {
#define DIR_INOUT 0
#define DIR_INONLY 1
#define DIR_OUTONLY 2
+
+ int budget_callbackperiod; /* length of a budget period (s)*/
+ int budget_callbackncalls; /* call budget for a period */
+ char *budget_callbacks_file; /* filename to store callback stats */
+ char budget_callbacksfile_rotate;
+
+ int budget_calloutperiod; /* length of a budget period (s)*/
+ int budget_calloutncalls; /* call budget for a period */
+ char *budget_callouts_file; /* filename to store callout stats */
+ char budget_calloutsfile_rotate;
+
+ int ppp_expect_auth;
+ int ppp_send_auth;
+#define AUTH_UNDEF 0
+#define AUTH_NONE 1
+#define AUTH_PAP 2
+#define AUTH_CHAP 3
+
+ int ppp_auth_flags;
+#define AUTH_RECHALLENGE 0x01
+#define AUTH_REQUIRED 0x02
+
+#define AUTHNAMELEN 32 /* AUTHNAMELEN must match in <machine/i4b_isppp.h> */
+#define AUTHKEYLEN 16
+ char ppp_expect_name[AUTHNAMELEN]; /* PPP PAP/CHAP login name */
+ char ppp_send_name[AUTHNAMELEN];
+
+ char ppp_expect_password[AUTHKEYLEN];
+ char ppp_send_password[AUTHKEYLEN];
+
+ int day; /* days valid */
+#define SU 0x01
+#define MO 0x02
+#define TU 0x04
+#define WE 0x08
+#define TH 0x10
+#define FR 0x20
+#define SA 0x40
+#define HD 0x80 /* holiday */
+ int fromhr; /* time valid */
+ int frommin;
+ int tohr;
+ int tomin;
/*===========================================================================*/
/*============ filled in after start, then dynamic ==========================*/
@@ -380,7 +426,7 @@ typedef struct cfg_entry {
#define N_STATES (ST_ILL+1) /* max number of states */
- int disc_cause; /* cause from disconnect */
+ cause_t disc_cause; /* cause from disconnect */
int local_disconnect; /* flag, who disconnected */
#define DISCON_LOC 0
@@ -435,6 +481,25 @@ typedef struct cfg_entry {
int alert_time; /* count down of alert time */
char display[DISPLAY_MAX];
+
+ time_t budget_callbackperiod_time; /* end of current period */
+ int budget_callbackncalls_cnt; /* amount of calls left */
+
+ int budget_callback_req; /* requests */
+ int budget_callback_done; /* call done */
+ int budget_callback_rej; /* call refused */
+
+ time_t budget_calloutperiod_time; /* end of current period */
+ int budget_calloutncalls_cnt; /* amount of calls left */
+
+ int budget_callout_req; /* requests */
+ int budget_callout_done; /* call done */
+ int budget_callout_rej; /* call refused */
+
+ int budget_calltype; /* type of call */
+#define BUDGET_TYPE_CBACK 1
+#define BUDGET_TYPE_COUT 2
+
} cfg_entry_t;
/*---------------------------------------------------------------------------*
@@ -563,11 +628,16 @@ int monitorport = -1;
int accepted = 0;
int isdntime = 0; /* flag, log time from exchange */
+int extcallattr = 0; /* flag, display extended caller attributes */
char tinainitprog[MAXPATHLEN] = TINA_FILE_DEF;
char rotatesuffix[MAXPATHLEN] = "";
+time_t starttime = 0;
+
+char holidayfile[MAXPATHLEN] = HOLIDAY_FILE_DEF; /* holiday filename */
+
#else /* !MAIN */
int isdnfd;
@@ -607,6 +677,7 @@ int nentries;
int uselogfile;
char logfile[MAXPATHLEN];
+FILE *logfp;
int logfacility;
int nregex;
struct rarr rarr[MAX_RE];
@@ -641,11 +712,16 @@ int monitorport;
int accepted;
int isdntime;
+int extcallattr;
char tinainitprog[MAXPATHLEN];
char rotatesuffix[MAXPATHLEN];
+time_t starttime;
+
+char holidayfile[MAXPATHLEN];
+
#endif /* MAIN */
char * bdrivername ( int drivertype );
@@ -684,6 +760,7 @@ cfg_entry_t * get_cep_by_cdid ( int cdid );
int get_current_rate ( cfg_entry_t *cep, int logit );
void handle_charge ( cfg_entry_t *cep );
void handle_recovery ( void );
+void handle_scrprs(int cdid, int scr, int prs, char *caller);
void if_up(cfg_entry_t *cep);
void if_down(cfg_entry_t *cep);
void init_controller ( void );
@@ -722,8 +799,8 @@ void select_next_dialno ( cfg_entry_t *cep );
void select_this_dialno ( cfg_entry_t *cep );
int sendm_alert_req ( cfg_entry_t *cep );
int sendm_connect_req ( cfg_entry_t *cep );
-int sendm_connect_resp ( cfg_entry_t *cep, int cdid, int response, int cause );
-int sendm_disconnect_req ( cfg_entry_t *cep, int cause );
+int sendm_connect_resp ( cfg_entry_t *cep, int cdid, int response, cause_t cause );
+int sendm_disconnect_req ( cfg_entry_t *cep, cause_t cause );
int set_channel_busy(int controller, int channel);
int set_channel_idle(int controller, int channel);
int setup_dialout(cfg_entry_t *cep);
@@ -788,4 +865,12 @@ void init_alias(char *filename);
void free_aliases(void);
char *get_alias(char *number);
+void upd_callstat_file(char *filename, int rotateflag);
+
+/* holiday.c */
+
+void init_holidays(char *filename);
+void free_holidays(void);
+int isholiday(int d, int m, int y);
+
#endif /* _ISDND_H_ */
diff --git a/usr.sbin/i4b/isdnd/isdnd.rates.5 b/usr.sbin/i4b/isdnd/isdnd.rates.5
index 3ad72d0..d57d703 100644
--- a/usr.sbin/i4b/isdnd/isdnd.rates.5
+++ b/usr.sbin/i4b/isdnd/isdnd.rates.5
@@ -38,8 +38,7 @@
The file
.Pa isdnd.rates
contains descriptions how long charging units last at a given time of day,
-day of week and the distance to the destination.
-If this file is available,
+day of week and the distance to the destination. If this file is available,
this information may be used by the
.Xr isdnd 8
ISDN connection management daemon to calculate the short hold time for a
@@ -72,12 +71,9 @@ start_hour.start_minutes-end_hour.end_minutes:charge_unit_length
.Ed
.Pp
Start_hour and start_minutes define the begin of a time section and end_hour
-and end_minutes define the end.
-Charge_unit_length define the length of a
-charging unit in the previously defined time section.
-No spaces or tabs are
-allowed inside this field.
-The hour and minutes specifications MUST have
+and end_minutes define the end. Charge_unit_length define the length of a
+charging unit in the previously defined time section. No spaces or tabs are
+allowed inside this field. The hour and minutes specifications MUST have
exactly 2 digits, in case just one digit is needed, a leading 0 must be used.
.Pp
For example,
diff --git a/usr.sbin/i4b/isdnd/isdnd.rc.5 b/usr.sbin/i4b/isdnd/isdnd.rc.5
index b52a65e..56c6190 100644
--- a/usr.sbin/i4b/isdnd/isdnd.rc.5
+++ b/usr.sbin/i4b/isdnd/isdnd.rc.5
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+.\" Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -22,13 +22,13 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: isdnd.rc.5,v 1.41 1999/12/13 22:11:55 hm Exp $
+.\" $Id: isdnd.rc.5,v 1.51 2000/10/09 11:17:07 hm Exp $
.\"
.\" $FreeBSD$
.\"
-.\" last edit-date: [Mon Dec 13 23:00:48 1999]
+.\" last edit-date: [Mon Oct 9 13:12:29 2000]
.\"
-.Dd October 11, 1999
+.Dd October 9, 2000
.Dt ISDND.RC 5
.Os
.Sh NAME
@@ -83,10 +83,8 @@ The following keywords are recognized by
.Bl -tag -width system -compact
.It Li system
-This keyword starts the system configuration section.
-It must not
-have a parameter and may be used only once.
-The keyword is mandatory.
+This keyword starts the system configuration section. It must not
+have a parameter and may be used only once. The keyword is mandatory.
The following keywords are valid in the system configuration section:
.Bl -tag -width useacctfile -compact
@@ -94,8 +92,7 @@ The following keywords are valid in the system configuration section:
If this parameter is set to
.Em on ,
accounting information is written even if the local site was not charged
-or no charging information is available or is not subscribed.
-(optional)
+or no charging information is available or is not subscribed. (optional)
.It Li acctfile
Specifies the name of the accounting file which is used when the keyword
@@ -104,44 +101,51 @@ Specifies the name of the accounting file which is used when the keyword
.Em on .
See also system keyword
.Em rotatesuffix .
-If this keyword is omitted the system default is used.
-(optional)
+If this keyword is omitted the system default is used. (optional)
.It Li aliasing
If this parameter is set to
.Em on ,
alias processing of telephone-number to name is enabled (see also the
.Em aliasfile
-keyword below). The default is off.
-(optional)
+keyword below). The default is off. (optional)
.It Li aliasfile
Specifies the name of the telephone number-to-name alias database file shared
with the
-.Xr isdntel 8
+.Xr isdntel 1
utility when alias processing is enabled via the
.Em aliasing
-keyword.
-(optional)
+keyword. (optional)
.It Li beepconnect
-In fullscreen mode, if this parameter is set to
+In full-screen mode, if this parameter is set to
.Em on ,
ring the bell when connecting or disconnecting a call.
+.It Li extcallattr
+If this parameter is set to
+.Em on ,
+the extended caller attributes "screening indicator" and "presentation
+indicator" are written to the log-file.
+The default is off. (optional)
+
+.It Li holidayfile
+Specifies the name of the holiday file containing the dates of holidays.
+This file is used in conjunction with the
+.Em valid
+keyword to lookup the dates of holidays. (optional)
+
.It Li isdntime
If this parameter is set to
.Em on ,
date/time information from the exchange (if provided) is written to the
-logfile.
-The default is off.
-(optional)
+log-file. The default is off. (optional)
.It Li mailer
This keyword is used to specify the path/name of a mail program which
which is able to use the "-s" flag to specify a subject on its
-command line.
-In case of a fatal error exit of
+command line. In case of a fatal error exit of
.Nm
this program is used to send mail to an administrator specified by
the keyword
@@ -173,8 +177,7 @@ This integer parameter is optional and is set to port 451 by default.
.It Li monitor
This keyword specifies a local socket name or a host or network for remote
-monitoring.
-The
+monitoring. The
.Em monitor
specification may either be:
.Pp
@@ -194,8 +197,7 @@ example: up-vision-net/24
.It Li monitor-access
This keyword specifies the access rights for a previously used
.Em monitor
-keyword.
-The supported access rights are:
+keyword. The supported access rights are:
.Pp
.Bl -tag -width Ds -compact -offset
.It Ar fullcmd
@@ -207,14 +209,11 @@ The supported access rights are:
.El
.It Li ratesfile
-Specifies the name of the ratesfile.
-If this keyword is omitted the system
-default is used.
-(optional)
+Specifies the name of the ratesfile. If this keyword is omitted the system
+default is used. (optional)
.It Li regexpr
-This keyword is used to specify regular expressions.
-It can be specified
+This keyword is used to specify regular expressions. It can be specified
more than once up to a compile time dependent value (currently set to 5 by
the MAX_RE definition in the source).
.Pp
@@ -247,21 +246,18 @@ which is prepended to the string specified as a parameter to this keyword.
(optional)
.It Li rotatesuffix
-Specifies a suffix for renaming the log- and the accountingfilename.
-In case
-rotatesuffix is used and a USR1 signal is sent to isdnd, the logfile and the
-accounting file is not only closed and reopened but the old logfile is also
+Specifies a suffix for renaming the log- and the accounting-filename. In case
+rotatesuffix is used and a USR1 signal is sent to isdnd, the log-file and the
+accounting file is not only closed and reopened but the old log-file is also
renamed to the former filename with the rotatesuffix string appended.
-If this keyword is omitted, the logfiles are just closed and reopened; this
-is also the default behaviour.
-(optional)
+If this keyword is omitted, the log-files are just closed and reopened; this
+is also the default behavior. (optional)
.It Li rtprio
-Specifies the realtime priority
+Specifies the real-time priority
.Nm isdnd
runs at as an integer value in the range 0...31 with 0 being the highest
-priority.
-This keyword is optional; if not specified the process priority of
+priority. This keyword is optional; if not specified the process priority of
.Nm isdnd
is not touched in any way.
( See also
@@ -275,25 +271,20 @@ was compiled with -DUSE_RTPRIO.
If this parameter is set to
.Em on
charging (if available) and accounting information is written to the
-accounting file.
-(optional)
+accounting file. (optional)
.El
.It Li controller
-This keyword starts the controller configuration section.
-It must not
-have a parameter and may be used once for every controller.
-The keyword
-is optional.
-The following keywords are valid in a controller
+This keyword starts the controller configuration section. It must not
+have a parameter and may be used once for every controller. The keyword
+is optional. The following keywords are valid in a controller
configuration section:
.Bl -tag -width useacctfile -compact
.It Li protocol
This keyword is used to set the D-channel protocol for the S0-bus a
-controller is connected to.
-The following parameters are currently
+controller is connected to. The following parameters are currently
supported:
.Pp
.Bl -tag -width calledback -compact -offset
@@ -306,8 +297,7 @@ An ISDN leased line with a single B-channel (called D64S in Germany).
.El
.It Li entry
-This keyword starts one configuration entry.
-It must not have a parameter.
+This keyword starts one configuration entry. It must not have a parameter.
This keyword must be used at least once.
The following keywords are valid in an entry section:
.Bl -tag -width unitlengthsrc -compact
@@ -316,8 +306,7 @@ The following keywords are valid in an entry section:
This keyword is used to specify the name of a program which is run in
case an incoming telephone connection specified
.Em answer
-in its configuration entry.
-The default name is
+in its configuration entry. The default name is
.Em answer .
.Nm Isdnd
expects to find this program beneath the path
@@ -326,18 +315,15 @@ which is prepended to the string specified as a parameter to this keyword.
(optional)
.It Li alert
-is used to specify a time in seconds to wait before accepting a call.
-This
+is used to specify a time in seconds to wait before accepting a call. This
keyword is only usable for incoming telephone calls (dialin-reaction = answer).
It is used to have a chance to accept an incoming call on the phone before
-the answering machine starts to run.
-The minimum value for the alert parameter
+the answering machine starts to run. The minimum value for the alert parameter
is 5 seconds and the maximum parameter allowed is 180 seconds.
(optional)
.It Li b1protocol
-The B channel layer 1 protocol used for this connection.
-The keyword is mandatory.
+The B channel layer 1 protocol used for this connection. The keyword is mandatory.
The currently configurable values are:
.Pp
.Bl -tag -width Ds -compact -offset
@@ -347,15 +333,67 @@ HDLC framing.
No framing at all (used for telephony).
.El
+.It Li budget-calloutperiod
+is used to specify a time period in seconds. Within this period, the number of calls
+specified by
+.Em budget-calloutncalls
+are allowed to succeed, any further attempt to call out will be blocked for the rest
+of the time left in the time period. (optional)
+
+.It Li budget-calloutncalls
+The number of outgoing calls allowed within the time period specified by
+.Em budget-calloutperiod. (optional)
+
+.It Li budget-calloutsfile
+A path/filename to which the number of successfull callouts are written.
+The contents of the file is preserved when it exists during startup of isdnd.
+The format of this file is: start time, last update time, number of calls.
+(optional)
+
+.It Li budget-calloutsfile-rotate
+If set to
+.Em on
+rotate budget-calloutsfile every night when an attempt is made to update
+the file on a new day. The statistics for the previous day are witten to
+a file with the filename specified by budget-calloutsfile to which a hyphen
+and the new day's (!) day of month number is appended. (optional)
+
+.It Li budget-callbackperiod
+.It Li budget-callbackncalls
+.It Li budget-callbacksfile
+.It Li budget-calloutsfile-rotate
+See
+.Em budget-calloutperiod,
+.Em budget-calloutncalls and
+.Em budget-calloutsfile
+.Em budget-calloutsfile-rotate
+above. These are used to specify the budgets for calling back a remote site.
+
.It Li callbackwait
The time in seconds to wait between hanging up the call from a remote site
-and calling back the remote site.
-(optional)
+and calling back the remote site. (optional)
.It Li calledbackwait
The time in seconds to wait for a remote site calling back the local site
-after a call from the local site to the remote site has been made.
-(optional)
+after a call from the local site to the remote site has been made. (optional)
+
+.It Li connectprog
+specifies a program run every time after a connection is established and
+address negotiation is complete (i.e.: the connection is usable).
+.Nm Isdnd
+expects to find the program below the path
+.Pa /etc/isdn
+which is prepended to the string specified as a parameter to this keyword.
+The programs specified by connect and disconnect will get the following
+command line arguments: -d (device) -f (flag) [ -a (addr) ] where
+.Em device
+is the name of device, e.g. "isp0",
+.Em flag
+will be "up" if connection just got up, or "down" if interface changed to down
+state and
+.Em addr
+the address that got assigned to the interface as a dotted-quad ip address
+(optional, only if it can be figured out by isdnd). (optional)
.It Li dialin-reaction
Used to specify what to do when an incoming connection request is received.
@@ -372,7 +410,7 @@ Ignore an incoming call.
.It Ar answer
Start telephone answering for an incoming voice call.
.It Ar callback
-When a remote site calls, hangup and call back the remote site.
+When a remote site calls, hang up and call back the remote site.
.El
.It Li dialout-type
@@ -397,7 +435,9 @@ each time it dials because the other side is also dialing.
.It Li dialretries
The number of dialing retries before giving up.
-(optional)
+Setting this to
+.Em -1
+gives an unlimited number of retries! (optional)
.It Li direction
This keyword is used to configure if incoming and outgoing, incoming-only or
@@ -417,6 +457,14 @@ Only incoming connections are possible.
Only outgoing connections are possible.
.El
+.It Li disconnectprog
+specifies a program run every time after a connection was shut down.
+.Nm Isdnd
+expects to find the program below the path
+.Pa /etc/isdn
+which is prepended to the string specified as a parameter to this keyword.
+(optional)
+
.It Li downtries
is used to configure the number of unsuccessful tries (= retry cycles!) before
the interface is disabled (for
@@ -436,14 +484,12 @@ further up).
This keyword is optional and is set to 60 seconds by default.
.It Li earlyhangup
-A (safety) time in seconds which specifies the time to hangup before an
-expected next charging unit will occur.
-(optional)
+A (safety) time in seconds which specifies the time to hang up before an
+expected next charging unit will occur. (optional)
.It Li idle-algorithm-outgoing
The algorithm used to determine when to hang up an outgoing call when the
-line becomes idle.
-The current algorithms are:
+line becomes idle. The current algorithms are:
.Pp
.Bl -tag -width calledback -compact -offset
@@ -481,75 +527,184 @@ than the requested channel!
.It Li isdntxdel-incoming
A delay value suitable for the
.Em timeout()
-kernel subroutine to delay the transmittion of the first packet after a
-successfull connection is made by this value for
+kernel subroutine to delay the transmission of the first packet after a
+successful connection is made by this value for
.Em incoming
-ISDN connections.
-The specification unit is 1/100 second.
-A zero (0) disables
-this feature and is the default value.
-This feature is implemented (and makes
+ISDN connections. The specification unit is 1/100 second. A zero (0) disables
+this feature and is the default value. This feature is implemented (and makes
sense only) for the
.Xr i4bipr 4
-IP over raw HDLC ISDN driver.
-(optional)
+IP over raw HDLC ISDN driver. (optional)
.It Li isdntxdel-outgoing
A delay value suitable for the
.Em timeout()
-kernel subroutine to delay the transmittion of the first packet after a
-successfull connection is made by this value for
+kernel subroutine to delay the transmission of the first packet after a
+successful connection is made by this value for
.Em outgoing
-ISDN connections.
-The specification unit is 1/100 second.
-A zero (0) disables
-this feature and is the default value.
-This feature is implemented (and makes
+ISDN connections. The specification unit is 1/100 second. A zero (0) disables
+this feature and is the default value. This feature is implemented (and makes
sense only) for the
.Xr i4bipr 4
-IP over raw HDLC ISDN driver.
-(optional)
+IP over raw HDLC ISDN driver. (optional)
.It Li local-phone-dialout
-The local telephone number used when the local site dials out.
-When dialing
+The local telephone number used when the local site dials out. When dialing
out to a remote site, the number specified here is put into the
.Em "Calling Party Number Information Element" .
.Pp
This keyword is mandatory for the
.Em ipr
-userland interfaces.
+user-land interfaces.
.It Li local-phone-incoming
The local telephone number used for verifying the destination of incoming
-calls.
-When a remote site dials in, this number is used to verify that it
-is the local site which the remote site wants to connect to.
-It is compared
+calls. When a remote site dials in, this number is used to verify that it
+is the local site which the remote site wants to connect to. It is compared
with the
.Em "Called Party Number Information Element"
got from the telephone exchange.
.Pp
-This keyword is mandatory for the ipr interfaces.
+This keyword is mandatory for the
+.Em ipr
+interfaces.
.It Li name
-Defines a symbolic name for this configuration entry.
-It's purpose is to
+Defines a symbolic name for this configuration entry. Its purpose is to
use this name in the full-screen display for easy identification of a link
-to a remote site and for accounting purposes.
-(mandatory)
+to a remote site and for accounting purposes. (mandatory)
+
+.It Li ppp-auth-paranoid
+If set to
+.Em no ,
+the remote site is not required to prove its authentity for connections
+that are initiated by the local site.
+The default is
+.Em yes
+and requires the remote site to always authenticate.
+.Pp
+This keyword is only used if
+.Em ppp-send-auth
+has been set to pap or chap for an
+.Em isp
+PPP interface.
+(optional)
-.It Li ratetype
-The rate entry used from the rates file.
+.It Li ppp-auth-rechallenge
+Set to
+.Em no ,
+if the other side does not support re-challenging for chap.
+The default is
+.Em yes ,
+which causes verification of the remote site's authentity once in a while.
+.Pp
+This keyword is only used if
+.Em ppp-expect-auth
+has been set to chap for an
+.Em isp
+PPP interface.
+(optional)
+
+.It Li ppp-expect-auth
+The local site expects the authentity of the remote site to be proved by
+the specified method.
+The supported methods are:
+.Pp
+.Bl -tag -width Ds -compact -offset
+.It Ar none
+Do not require the other side to authenticate. Typical uses are dial-out to an ISP
+(many ISPs do not authenticate themselves to clients)
+or offering anonymous dial-in at the local site.
+.It Ar chap
+The preferred authentication method, which does not require a password to be sent
+in the clear.
+.It Ar pap
+The unprotected authentication method, which allows anybody watching the wire
+to grab name and password.
+.El
+.Pp
+If
+.Em ppp-auth-paranoid
+is set to
+.Em no
+(the default is
+.Em yes )
+outgoing connections will not require the remote site to authenticate itself.
+.Pp
+This keyword is only used for the
+.Em isp
+PPP interfaces.
+(optional)
+
+.It Li ppp-expect-name
+The name that has to be provided by the remote site to prove its authentity.
+.Pp
+This keyword is only used if
+.Em ppp-expect-auth
+has been set to pap or chap for an
+.Em isp
+PPP interface.
+(optional)
+
+.It Li ppp-expect-password
+The secret that has to be provided by the remote site to prove its authentity.
+.Pp
+This keyword is only used if
+.Em ppp-expect-auth
+has been set to pap or chap for an
+.Em isp
+PPP interface.
(optional)
+
+.It Li ppp-send-auth
+The authentication method required by the remote site.
+The currently supported parameters are:
+.Pp
+.Bl -tag -width Ds -compact -offset
+.It Ar none
+The remote site does not expect or support authentication.
+.It Ar chap
+The preferred authentication method, which does not require a password to be sent
+in the clear.
+.It Ar pap
+The unprotected authentication method, which allows anybody watching the wire
+to grab name and password.
+.El
+.Pp
+This keyword is only used for the
+.Em isp
+PPP interfaces.
+(optional)
+
+.It Li ppp-send-name
+The authentication name sent to the remote site.
+.Pp
+This keyword is only used if
+.Em ppp-send-auth
+has been set to pap or chap for an
+.Em isp
+PPP interface.
+(optional)
+
+.It Li ppp-send-password
+The secret used to prove the local site's authentity to the remote site.
+.Pp
+This keyword is only used if
+.Em ppp-send-auth
+has been set to pap or chap for an
+.Em isp
+PPP interface.
+(optional)
+
+.It Li ratetype
+The rate entry used from the rates file. (optional)
.br
For example, ratetype=0 selects lines beginning "ra0" in /etc/isdn/isdnd.rates;
(typically ra0 lines are a set of tables for local call rates on different
days of the week & times per day).
.It Li recoverytime
-The time in seconds to wait between dial retries.
-(optional)
+The time in seconds to wait between dial retries. (optional)
.It Li remdial-handling
is used to specify the dialout behavior in case more than one outgoing
@@ -568,23 +723,19 @@ follows the last one used.
.El
.It Li remote-phone-dialout
-The remote telephone number used when the local site dials out.
-When dialing
+The remote telephone number used when the local site dials out. When dialing
out to a remote site, the number specified here is put into the
.Em "Called Party Number Information Element" .
.Pp
This keyword is mandatory for the
.Em ipr
-interfaces.
-It may be specified more than once to try to dial to several
+interfaces. It may be specified more than once to try to dial to several
numbers until one succeeds.
.It Li remote-phone-incoming
-The remote telephone number used to verify an incoming call.
-When a remote site
+The remote telephone number used to verify an incoming call. When a remote site
dials in, this number is used to verify that it is the correct remote site
-which is herewith authorized to connect into the local system.
-This parameter
+which is herewith authorized to connect into the local system. This parameter
is compared against the
.Em "Calling Party Number Information Element"
got from the telephone exchange.
@@ -594,22 +745,19 @@ This keyword is mandatory for the ipr interfaces.
This keyword may have a wildcard parameter '*' to permit anyone dialing in.
.It Li unitlength
-The length of a charging unit in seconds.
-This is used in conjunction with
-the idletime to decide when to hangup a connection.
-(optional)
+The length of a charging unit in seconds. This is used in conjunction with
+the idletime to decide when to hang up a connection. (optional)
.It Li unitlengthsrc
This keyword is used to specify from which source
.Xr isdnd 8
-takes the unitlength for shorthold mode.
-The currently configurable values are:
+takes the unitlength for short-hold mode. The currently configurable values are:
.Pp
.Bl -tag -width Ds -compact -offset
.It Ar none
Then unitlength is not specified anywhere.
.It Ar cmdl
-Use the unitlength specified on the commandline.
+Use the unitlength specified on the command line.
.It Ar conf
Use the unitlength specified in the configuration file with the keyword
.Em unitlength .
@@ -619,16 +767,14 @@ file with the keyword
.Em ratetype .
.It Ar aocd
Use a dynamically calculated unitlength in case AOCD is subscribed on
-the ISDN line.
-(AOCD is an acronym for ``Advice Of Charge During the call''
+the ISDN line. (AOCD is an acronym for ``Advice Of Charge During the call''
which is a service provided by the telecommunications (ie phone) provider,
to indicate billable units).
.El
.It Li usrdevicename
-Specifies the userland interface which is used for interfacing ISDN B channel
-data to the userland.
-The keyword is mandatory.
+Specifies the user-land interface which is used for interfacing ISDN B channel
+data to the user-land. The keyword is mandatory.
This keyword accepts the following parameters:
.Pp
.Bl -tag -width Ds -compact -offset
@@ -640,6 +786,8 @@ This parameter configures a synchronous PPP over ISDN interface.
This specifies a Raw B CHannel access interface.
.It Ar tel
ISDN telephony.
+.It Ar ing
+configures a ISDN B-channel to NetGraph interface.
.El
.It Li usrdeviceunit
@@ -659,36 +807,56 @@ This parameter is optional and is set to
.Em off
by default.
-.It Li connectprog
-specifies a program run everytime after a connection is established and
-address negotiation is complete (i.e.: the connection is useable).
-.Nm Isdnd
-expects to find the program below the path
-.Pa /etc/isdn
-which is prepended to the string specified as a parameter to this keyword.
-The programs specified by connect and disconnect will get the following
-command line arguments: -d (device) -f (flag) [ -a (addr) ] where
-.Em device
-is the name of device, e.g. "isp0",
-.Em flag
-will be "up" if connection just got up, or "down" if interface changed to down
-state and
-.Em addr
-the address that got assigned to the interface as a dotted-quad ip address
-(optional, only if it can be figured out by isdnd). (optional)
+.It Li valid
+.Em Note:
+this feature is considered experimental!
+The parameter to this keyword is a string specifying a time range within
+which this entry is valid.
+The time specification consists of a list of weekdays and/or a holiday
+indicator ( see also the
+.Em holidayfile
+keyword in the system section ) separated by commas followed by an optional
+daytime range specification in the form hh:mm-hh:mm.
+The weekdays are specified as numbers from 0 to 6 and the number 7 for
+holidays:
+.Pp
+.Bl -tag -width Ds -compact -offset
+.It Ar 0
+Sunday
+.It Ar 1
+Monday
+.It Ar 2
+Tuesday
+.It Ar 3
+Wednesday
+.It Ar 4
+Thursday
+.It Ar 5
+Friday
+.It Ar 6
+Saturday
+.It Ar 7
+a Holiday
+.El
-.It Li disconnectprog
-specifies a program run everytime after a connection was shut down.
-.Nm Isdnd
-expects to find the program below the path
-.Pa /etc/isdn
-which is prepended to the string specified as a parameter to this keyword.
-(optional)
+.Pp
+The following examples describe the "T-ISDN xxl" tariff of the german Telekom:
+.Bl -tag -width Ds -compact -offset
+.It Ar 1,2,3,4,5,6,09:00-18:00
+Monday through Saturday, daytime 9:00 to 18:00
+.It Ar 1,2,3,4,5,6,18:00-9:00
+Monday through Saturday, nighttime 18:00 to 9:00
+.It Ar 0,7
+Sunday and on holidays, all 24 hours
+.El
+
+.Pp
+The use of this keyword is optional.
.El
.El
-.Sh IDLETIME CALCULATION AND SHORTHOLD MODE
+.Sh IDLETIME CALCULATION AND SHORT-HOLD MODE
.Bl -tag -width incoming calls -compact
.It Li incoming calls
It is assumed that the calling side knows most about charging structures and
@@ -752,13 +920,10 @@ must be greater than 0 (zero);
.Ed
During the unchecked window which is (unitlength - (idle-time+earlyhangup))
-in length, no idle check is done.
-After the unchecked window has ended,
-the line is checked for idle-time length if no traffic takes place.
-In case
+in length, no idle check is done. After the unchecked window has ended,
+the line is checked for idle-time length if no traffic takes place. In case
there was traffic detected in the check-window, the same procedure is restarted
-at the beginning of the next unit.
-In case no traffic was detected during
+at the beginning of the next unit. In case no traffic was detected during
the check-window, the line is closed at the end of the check window.
.Pp
Notice:
@@ -788,8 +953,8 @@ For example British Telecom bill this way.
Each call is divided into two periods, the first is the
.Em unchecked
period and the second is the
-.Em checked
-. The
+.Em checked .
+The
.Em checked
period starts 1 second before the first units time expires.
.Pp
diff --git a/usr.sbin/i4b/isdnd/log.c b/usr.sbin/i4b/isdnd/log.c
index 01fa70e..34f68d4 100644
--- a/usr.sbin/i4b/isdnd/log.c
+++ b/usr.sbin/i4b/isdnd/log.c
@@ -27,7 +27,7 @@
* i4b daemon - logging routines
* -----------------------------
*
- * $Id: log.c,v 1.23 1999/12/13 21:25:25 hm Exp $
+ * $Id: log.c,v 1.25 2000/10/09 12:53:29 hm Exp $
*
* $FreeBSD$
*
@@ -174,7 +174,7 @@ log(int what, const char *fmt, ...)
#warning "FreeBSD ncurses is buggy: write to last column = auto newline!"
COLS-((strlen(dp))+(strlen(logtab[what].text))+3), buffer);
#else
- COLS-((strlen(dp))+(strlen(logtab[what].text))+2), buffer);
+ (int)(COLS-((strlen(dp))+(strlen(logtab[what].text))+2)), buffer);
#endif
wrefresh(lower_w);
}
diff --git a/usr.sbin/i4b/isdnd/main.c b/usr.sbin/i4b/isdnd/main.c
index fb519df..9c172e0 100644
--- a/usr.sbin/i4b/isdnd/main.c
+++ b/usr.sbin/i4b/isdnd/main.c
@@ -27,11 +27,11 @@
* i4b daemon - main program entry
* -------------------------------
*
- * $Id: main.c,v 1.49 1999/12/13 21:25:25 hm Exp $
+ * $Id: main.c,v 1.54 2000/10/09 12:53:29 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:47:35 1999]
+ * last edit-date: [Mon Oct 2 22:57:08 2000]
*
*---------------------------------------------------------------------------*/
@@ -89,7 +89,7 @@ usage(void)
fprintf(stderr, " general = 0x%04x, rates = 0x%04x, timing = 0x%04x\n", DL_MSG, DL_RATES, DL_TIME);
fprintf(stderr, " state = 0x%04x, retry = 0x%04x, dial = 0x%04x\n", DL_STATE, DL_RCVRY, DL_DIAL);
fprintf(stderr, " process = 0x%04x, kernio = 0x%04x ctrlstat = 0x%04x\n", DL_PROC, DL_DRVR, DL_CNST);
- fprintf(stderr, " rc-file = 0x%04x\n", DL_RCCF);
+ fprintf(stderr, " rc-file = 0x%04x, budget = 0x%04x\n", DL_RCCF, DL_BDGT);
fprintf(stderr, " -dn no debug output on fullscreen display\n");
#endif
fprintf(stderr, " -f fullscreen status display\n");
@@ -126,14 +126,10 @@ main(int argc, char **argv)
setlocale (LC_ALL, "");
- while ((i = getopt(argc, argv, "bmc:d:fFlL:Pr:s:t:u:")) != -1)
+ while ((i = getopt(argc, argv, "mc:d:fFlL:Pr:s:t:u:")) != -1)
{
switch (i)
{
- case 'b':
- do_bell = 1;
- break;
-
#ifdef I4B_EXTERNAL_MONITOR
case 'm':
inhibit_monitor = 1;
@@ -365,6 +361,10 @@ main(int argc, char **argv)
if(aliasing)
init_alias(aliasfile);
+ /* init holidays */
+
+ init_holidays(holidayfile);
+
/* init remote monitoring */
#ifdef I4B_EXTERNAL_MONITOR
@@ -405,6 +405,8 @@ main(int argc, char **argv)
}
#endif
+ starttime = time(NULL); /* get starttime */
+
srandom(580403); /* init random number gen */
mloop( /* enter loop of no return .. */
diff --git a/usr.sbin/i4b/isdnd/monitor.c b/usr.sbin/i4b/isdnd/monitor.c
index 876d22b..2b73066 100644
--- a/usr.sbin/i4b/isdnd/monitor.c
+++ b/usr.sbin/i4b/isdnd/monitor.c
@@ -33,7 +33,7 @@
* i4b daemon - network monitor server module
* ------------------------------------------
*
- * $Id: monitor.c,v 1.29 1999/12/13 21:25:25 hm Exp $
+ * $Id: monitor.c,v 1.30 2000/10/09 12:53:29 hm Exp $
*
* $FreeBSD$
*
diff --git a/usr.sbin/i4b/isdnd/msghdl.c b/usr.sbin/i4b/isdnd/msghdl.c
index 265eb6e..a671954 100644
--- a/usr.sbin/i4b/isdnd/msghdl.c
+++ b/usr.sbin/i4b/isdnd/msghdl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* i4b daemon - message from kernel handling routines
* --------------------------------------------------
*
- * $Id: msghdl.c,v 1.71 1999/12/13 21:25:25 hm Exp $
+ * $Id: msghdl.c,v 1.78 2000/09/21 11:29:51 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:47:54 1999]
+ * last edit-date: [Thu Sep 21 11:11:48 2000]
*
*---------------------------------------------------------------------------*/
@@ -66,10 +66,17 @@ msg_connect_ind(msg_connect_ind_t *mp)
#define SRC (aliasing == 0 ? mp->src_telno : src_tela)
#define DST (aliasing == 0 ? mp->dst_telno : dst_tela)
+ if(aliasing)
+ {
+ src_tela = get_alias(mp->src_telno);
+ dst_tela = get_alias(mp->dst_telno);
+ }
+
if((cep = find_matching_entry_incoming(mp)) == NULL)
{
/* log message generated in find_matching_entry_incoming() */
sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
+ handle_scrprs(mp->header.cdid, mp->scr_ind, mp->prs_ind, SRC);
return;
}
@@ -103,17 +110,12 @@ msg_connect_ind(msg_connect_ind_t *mp)
}
}
- if(aliasing)
- {
- src_tela = get_alias(mp->src_telno);
- dst_tela = get_alias(mp->dst_telno);
- }
-
if(cep->inout == DIR_OUTONLY)
{
log(LL_CHD, "%05d %s incoming call from %s to %s not allowed by configuration!",
mp->header.cdid, cep->name, SRC, DST);
sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
+ handle_scrprs(mp->header.cdid, mp->scr_ind, mp->prs_ind, SRC);
return;
}
@@ -176,6 +178,7 @@ msg_connect_ind(msg_connect_ind_t *mp)
break;
case REACT_CALLBACK:
+
#ifdef NOTDEF
/*XXX reserve channel ??? */ decr_free_channels(mp->controller);
#endif
@@ -184,15 +187,42 @@ msg_connect_ind(msg_connect_ind_t *mp)
log(LL_CHD, "%05d %s reserved: incoming call from %s to %s",
mp->header.cdid, cep->name, SRC, DST);
sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
+#if 0
(CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
+#else
+ (CAUSET_I4B << 8) | CAUSE_I4B_REJECT);
+#endif
/* no state change */
}
else
{
- log(LL_CHD, "%05d %s callback: incoming call from %s to %s",
- mp->header.cdid, cep->name, SRC, DST);
sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
+#if 0
(CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
+#else
+ (CAUSET_I4B << 8) | CAUSE_I4B_REJECT);
+#endif
+ if(cep->budget_callbackperiod && cep->budget_callbackncalls)
+ {
+ cep->budget_callback_req++;
+ cep->budget_calltype = 0;
+ if(cep->budget_callbackncalls_cnt == 0)
+ {
+ log(LL_CHD, "%05d %s no budget: call from %s to %s",
+ mp->header.cdid, cep->name, SRC, DST);
+ cep->cdid = CDID_UNUSED;
+ cep->budget_callback_rej++;
+ break;
+ }
+ else
+ {
+ cep->budget_calltype = BUDGET_TYPE_CBACK;
+ }
+ }
+
+ log(LL_CHD, "%05d %s callback: incoming call from %s to %s",
+ mp->header.cdid, cep->name, SRC, DST);
+
cep->last_release_time = time(NULL);
cep->cdid = CDID_RESERVED;
next_state(cep, EV_CBRQ);
@@ -204,6 +234,7 @@ msg_connect_ind(msg_connect_ind_t *mp)
sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
break;
}
+ handle_scrprs(mp->header.cdid, mp->scr_ind, mp->prs_ind, SRC);
#undef SRC
#undef DST
}
@@ -250,6 +281,29 @@ msg_connect_active_ind(msg_connect_active_ind_t *mp)
cep->cdid, cep->name,
cep->isdncontrollerused, cep->isdnchannelused,
bdrivername(cep->usrdevicename), cep->usrdeviceunit);
+
+ if(cep->budget_calltype)
+ {
+ if(cep->budget_calltype == BUDGET_TYPE_CBACK)
+ {
+ cep->budget_callback_done++;
+ cep->budget_callbackncalls_cnt--;
+ DBGL(DL_BDGT, (log(LL_DBG, "%s: new cback-budget = %d",
+ cep->name, cep->budget_callbackncalls_cnt)));
+ if(cep->budget_callbacks_file != NULL)
+ upd_callstat_file(cep->budget_callbacks_file, cep->budget_callbacksfile_rotate);
+ }
+ else if(cep->budget_calltype == BUDGET_TYPE_COUT)
+ {
+ cep->budget_callout_done++;
+ cep->budget_calloutncalls_cnt--;
+ DBGL(DL_BDGT, (log(LL_DBG, "%s: new cout-budget = %d",
+ cep->name, cep->budget_calloutncalls_cnt)));
+ if(cep->budget_callouts_file != NULL)
+ upd_callstat_file(cep->budget_callouts_file, cep->budget_calloutsfile_rotate);
+ }
+ cep->budget_calltype = 0;
+ }
}
else
{
@@ -735,7 +789,25 @@ msg_dialout(msg_dialout_ind_t *mp)
dialresponse(cep, DSTAT_INONLY);
return;
}
-
+
+ if(cep->budget_calloutperiod && cep->budget_calloutncalls)
+ {
+ cep->budget_calltype = 0;
+ cep->budget_callout_req++;
+
+ if(cep->budget_calloutncalls_cnt == 0)
+ {
+ log(LL_CHD, "%05d %s no budget for calling out", 0, cep->name);
+ cep->budget_callout_rej++;
+ dialresponse(cep, DSTAT_TFAIL);
+ return;
+ }
+ else
+ {
+ cep->budget_calltype = BUDGET_TYPE_COUT;
+ }
+ }
+
if((cep->cdid = get_cdid()) == 0)
{
DBGL(DL_DRVR, (log(LL_DBG, "msg_dialout: get_cdid() returned 0!")));
@@ -770,6 +842,24 @@ msg_dialoutnumber(msg_dialoutnumber_ind_t *mp)
return;
}
+ if(cep->budget_calloutperiod && cep->budget_calloutncalls)
+ {
+ cep->budget_calltype = 0;
+ cep->budget_callout_req++;
+
+ if(cep->budget_calloutncalls_cnt == 0)
+ {
+ log(LL_CHD, "%05d %s no budget for calling out", 0, cep->name);
+ cep->budget_callout_rej++;
+ dialresponse(cep, DSTAT_TFAIL);
+ return;
+ }
+ else
+ {
+ cep->budget_calltype = BUDGET_TYPE_COUT;
+ }
+ }
+
if((cep->cdid = get_cdid()) == 0)
{
DBGL(DL_DRVR, (log(LL_DBG, "msg_dialoutnumber: get_cdid() returned 0!")));
@@ -922,6 +1012,9 @@ strapp(char *buf, const char *txt)
return buf;
}
+/*---------------------------------------------------------------------------*
+ * handle incoming MSG_PACKET_IND message
+ *---------------------------------------------------------------------------*/
static char *
ipapp(char *buf, unsigned long a )
{
@@ -935,6 +1028,9 @@ ipapp(char *buf, unsigned long a )
return buf;
}
+/*---------------------------------------------------------------------------*
+ * handle incoming MSG_PACKET_IND message
+ *---------------------------------------------------------------------------*/
void
msg_packet_ind(msg_packet_ind_t *mp)
{
@@ -1093,7 +1189,7 @@ sendm_connect_req(cfg_entry_t *cep)
* send message "connect response" to kernel
*---------------------------------------------------------------------------*/
int
-sendm_connect_resp(cfg_entry_t *cep, int cdid, int response, int cause)
+sendm_connect_resp(cfg_entry_t *cep, int cdid, int response, cause_t cause)
{
msg_connect_resp_t mcr;
int ret;
@@ -1105,6 +1201,7 @@ sendm_connect_resp(cfg_entry_t *cep, int cdid, int response, int cause)
if(response == SETUP_RESP_REJECT)
{
mcr.cause = cause;
+ DBGL(DL_DRVR, (log(LL_DBG, "sendm_connect_resp: reject, cause=0x%x", cause)));
}
else if(response == SETUP_RESP_ACCEPT)
{
@@ -1118,6 +1215,8 @@ sendm_connect_resp(cfg_entry_t *cep, int cdid, int response, int cause)
mcr.driver_unit = cep->usrdeviceunit;
mcr.max_idle_time = cep->idle_time_in;
+
+ DBGL(DL_DRVR, (log(LL_DBG, "sendm_connect_resp: accept")));
}
if((ret = ioctl(isdnfd, I4B_CONNECT_RESP, &mcr)) < 0)
@@ -1125,9 +1224,6 @@ sendm_connect_resp(cfg_entry_t *cep, int cdid, int response, int cause)
log(LL_ERR, "sendm_connect_resp: ioctl I4B_CONNECT_RESP failed: %s", strerror(errno));
error_exit(1, "sendm_connect_resp: ioctl I4B_CONNECT_RESP failed: %s", strerror(errno));
}
-
- DBGL(DL_DRVR, (log(LL_DBG, "sendm_connect_resp: sent CONNECT_RESP")));
-
return(ret);
}
@@ -1135,7 +1231,7 @@ sendm_connect_resp(cfg_entry_t *cep, int cdid, int response, int cause)
* send message "disconnect request" to kernel
*---------------------------------------------------------------------------*/
int
-sendm_disconnect_req(cfg_entry_t *cep, int cause)
+sendm_disconnect_req(cfg_entry_t *cep, cause_t cause)
{
msg_discon_req_t mcr;
int ret = 0;
diff --git a/usr.sbin/i4b/isdnd/pathnames.h b/usr.sbin/i4b/isdnd/pathnames.h
index eaabf14..44f9c6d 100644
--- a/usr.sbin/i4b/isdnd/pathnames.h
+++ b/usr.sbin/i4b/isdnd/pathnames.h
@@ -27,11 +27,11 @@
* i4b daemon - location of files
* ------------------------------
*
- * $Id: pathnames.h,v 1.10 1999/12/13 21:25:25 hm Exp $
+ * $Id: pathnames.h,v 1.11 2000/10/09 11:17:07 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:48:01 1999]
+ * last edit-date: [Mon Oct 2 22:55:28 2000]
*
*---------------------------------------------------------------------------*/
@@ -41,17 +41,18 @@
#define I4BDEVICE "/dev/i4b"
#define ETCPATH "/etc/isdn"
+
#define CONFIG_FILE_DEF "/etc/isdn/isdnd.rc"
+
#define RATES_FILE_DEF "/etc/isdn/isdnd.rates"
+#define HOLIDAY_FILE_DEF "/etc/isdn/holidays"
+
#define TINA_FILE_DEF "/etc/isdn/tinainitprog"
#define LOG_FILE_DEF "/var/log/isdnd.log"
-#ifdef __bsdi__
+
#define ACCT_FILE_DEF "/var/log/isdnd.acct"
-#else
-#define ACCT_FILE_DEF "/var/account/isdnd.acct"
-#endif
#define PIDFILE "/var/run/isdnd.pid"
diff --git a/usr.sbin/i4b/isdnd/pcause.c b/usr.sbin/i4b/isdnd/pcause.c
index a91e66e..99aa089 100644
--- a/usr.sbin/i4b/isdnd/pcause.c
+++ b/usr.sbin/i4b/isdnd/pcause.c
@@ -27,7 +27,7 @@
* printing cause values
* ---------------------
*
- * $Id: pcause.c,v 1.12 1999/12/13 21:25:25 hm Exp $
+ * $Id: pcause.c,v 1.13 2000/10/09 12:53:29 hm Exp $
*
* $FreeBSD$
*
diff --git a/usr.sbin/i4b/isdnd/rates.c b/usr.sbin/i4b/isdnd/rates.c
index 127d630..29aaef4 100644
--- a/usr.sbin/i4b/isdnd/rates.c
+++ b/usr.sbin/i4b/isdnd/rates.c
@@ -35,7 +35,7 @@
* i4b daemon - charging rates description file handling
* -----------------------------------------------------
*
- * $Id: rates.c,v 1.10 1999/12/13 21:25:25 hm Exp $
+ * $Id: rates.c,v 1.11 2000/10/09 12:53:29 hm Exp $
*
* $FreeBSD$
*
diff --git a/usr.sbin/i4b/isdnd/rc_config.c b/usr.sbin/i4b/isdnd/rc_config.c
index 9968d21..814774b 100644
--- a/usr.sbin/i4b/isdnd/rc_config.c
+++ b/usr.sbin/i4b/isdnd/rc_config.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* i4b daemon - config file processing
* -----------------------------------
*
- * $Id: rc_config.c,v 1.49 1999/12/13 21:25:25 hm Exp $
+ * $Id: rc_config.c,v 1.60 2000/10/09 11:17:07 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:48:38 1999]
+ * last edit-date: [Fri Oct 6 10:08:09 2000]
*
*---------------------------------------------------------------------------*/
@@ -40,6 +40,21 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <sys/callout.h>
+#include <sys/ioctl.h>
+
+#include <net/if.h>
+#ifdef __NetBSD__
+#include <net/if_sppp.h>
+#else
+#if __FreeBSD__ == 3
+#include <sys/param.h>
+#include <sys/mbuf.h>
+#endif
+#include <net/if_var.h>
+#include <machine/i4b_isppp.h>
+#endif
+
#include "isdnd.h"
#include "y.tab.h"
@@ -56,6 +71,7 @@ extern int yyparse();
static void set_config_defaults(void);
static void check_config(void);
static void print_config(void);
+static void parse_valid(int entrycount, char *dt);
static int nregexpr = 0;
static int nregprog = 0;
@@ -202,6 +218,12 @@ set_config_defaults(void)
cep->inout = DIR_INOUT;
+ cep->ppp_expect_auth = AUTH_UNDEF;
+
+ cep->ppp_send_auth = AUTH_UNDEF;
+
+ cep->ppp_auth_flags = AUTH_RECHALLENGE | AUTH_REQUIRED;
+
/* ======== filled in after start, then dynamic */
cep->cdid = CDID_UNUSED;
@@ -223,6 +245,113 @@ cfg_set_controller_default()
isdn_ctrl_tab[controllercount].protocol = PROTOCOL_DSS1;
}
+#define PPP_PAP 0xc023
+#define PPP_CHAP 0xc223
+
+static void
+set_isppp_auth(int entry)
+{
+ cfg_entry_t *cep = &cfg_entry_tab[entry]; /* ptr to config entry */
+
+ struct ifreq ifr;
+ struct spppreq spr;
+ int s;
+ int doioctl = 0;
+
+ if(cep->usrdevicename != BDRV_ISPPP)
+ return;
+
+ if(cep->ppp_expect_auth == AUTH_UNDEF
+ && cep->ppp_send_auth == AUTH_UNDEF)
+ return;
+
+ if(cep->ppp_expect_auth == AUTH_NONE
+ || cep->ppp_send_auth == AUTH_NONE)
+ doioctl = 1;
+
+ if ((cep->ppp_expect_auth == AUTH_CHAP
+ || cep->ppp_expect_auth == AUTH_PAP)
+ && cep->ppp_expect_name[0] != 0
+ && cep->ppp_expect_password[0] != 0)
+ doioctl = 1;
+
+ if ((cep->ppp_send_auth == AUTH_CHAP || cep->ppp_send_auth == AUTH_PAP)
+ && cep->ppp_send_name[0] != 0
+ && cep->ppp_send_password[0] != 0)
+ doioctl = 1;
+
+ if(!doioctl)
+ return;
+
+ snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "isp%d", cep->usrdeviceunit);
+
+ /* use a random AF to create the socket */
+ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ log(LL_ERR, "ERROR opening control socket at line %d!", lineno);
+ config_error_flag++;
+ return;
+ }
+ spr.cmd = (int)SPPPIOGDEFS;
+ ifr.ifr_data = (caddr_t)&spr;
+
+ if (ioctl(s, SIOCGIFGENERIC, &ifr) == -1) {
+ log(LL_ERR, "ERROR fetching active PPP authentication info for %s at line %d!", ifr.ifr_name, lineno);
+ close(s);
+ config_error_flag++;
+ return;
+ }
+ if (cep->ppp_expect_auth != AUTH_UNDEF)
+ {
+ if(cep->ppp_expect_auth == AUTH_NONE)
+ {
+ spr.defs.myauth.proto = 0;
+ }
+ else if ((cep->ppp_expect_auth == AUTH_CHAP
+ || cep->ppp_expect_auth == AUTH_PAP)
+ && cep->ppp_expect_name[0] != 0
+ && cep->ppp_expect_password[0] != 0)
+ {
+ spr.defs.myauth.proto = cep->ppp_expect_auth == AUTH_PAP ? PPP_PAP : PPP_CHAP;
+ strncpy(spr.defs.myauth.name, cep->ppp_expect_name, AUTHNAMELEN);
+ strncpy(spr.defs.myauth.secret, cep->ppp_expect_password, AUTHKEYLEN);
+ }
+ }
+ if (cep->ppp_send_auth != AUTH_UNDEF)
+ {
+ if(cep->ppp_send_auth == AUTH_NONE)
+ {
+ spr.defs.hisauth.proto = 0;
+ }
+ else if ((cep->ppp_send_auth == AUTH_CHAP
+ || cep->ppp_send_auth == AUTH_PAP)
+ && cep->ppp_send_name[0] != 0
+ && cep->ppp_send_password[0] != 0)
+ {
+ spr.defs.hisauth.proto = cep->ppp_send_auth == AUTH_PAP ? PPP_PAP : PPP_CHAP;
+ strncpy(spr.defs.hisauth.name, cep->ppp_send_name, AUTHNAMELEN);
+ strncpy(spr.defs.hisauth.secret, cep->ppp_send_password, AUTHKEYLEN);
+
+ if(cep->ppp_auth_flags & AUTH_REQUIRED)
+ spr.defs.hisauth.flags &= ~AUTHFLAG_NOCALLOUT;
+ else
+ spr.defs.hisauth.flags |= AUTHFLAG_NOCALLOUT;
+
+ if(cep->ppp_auth_flags & AUTH_RECHALLENGE)
+ spr.defs.hisauth.flags &= ~AUTHFLAG_NORECHALLENGE;
+ else
+ spr.defs.hisauth.flags |= AUTHFLAG_NORECHALLENGE;
+ }
+ }
+
+ spr.cmd = (int)SPPPIOSDEFS;
+
+ if (ioctl(s, SIOCSIFGENERIC, &ifr) == -1) {
+ log(LL_ERR, "ERROR setting new PPP authentication parameters for %s at line %d!", ifr.ifr_name, lineno);
+ config_error_flag++;
+ }
+ close(s);
+}
+
/*---------------------------------------------------------------------------*
* extract values from config and fill table
*---------------------------------------------------------------------------*/
@@ -297,6 +426,128 @@ cfg_setval(int keyword)
DBGL(DL_RCCF, (log(LL_DBG, "system: beepconnect = %d", yylval.booln)));
break;
+ case BUDGETCALLBACKPERIOD:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: budget-callbackperiod = %d", entrycount, yylval.num)));
+ cfg_entry_tab[entrycount].budget_callbackperiod = yylval.num;
+ break;
+
+ case BUDGETCALLBACKNCALLS:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: budget-callbackncalls = %d", entrycount, yylval.num)));
+ cfg_entry_tab[entrycount].budget_callbackncalls = yylval.num;
+ break;
+
+ case BUDGETCALLOUTPERIOD:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: budget-calloutperiod = %d", entrycount, yylval.num)));
+ cfg_entry_tab[entrycount].budget_calloutperiod = yylval.num;
+ break;
+
+ case BUDGETCALLOUTNCALLS:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: budget-calloutncalls = %d", entrycount, yylval.num)));
+ cfg_entry_tab[entrycount].budget_calloutncalls = yylval.num;
+ break;
+
+ case BUDGETCALLBACKSFILEROTATE:
+ cfg_entry_tab[entrycount].budget_callbacksfile_rotate = yylval.booln;
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: budget-callbacksfile-rotate = %d", entrycount, yylval.booln)));
+ break;
+
+ case BUDGETCALLBACKSFILE:
+ {
+ FILE *fp;
+ int s, l;
+ int n;
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: budget-callbacksfile = %s", yylval.str)));
+ fp = fopen(yylval.str, "r");
+ if(fp != NULL)
+ {
+ if((fscanf(fp, "%d %d %d", (int *)&s, (int *)&l, &n)) != 3)
+ {
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: initializing budget-callbacksfile %s", entrycount, yylval.str)));
+ fclose(fp);
+ fp = fopen(yylval.str, "w");
+ if(fp != NULL)
+ fprintf(fp, "%d %d %d", (int)time(NULL), (int)time(NULL), 0);
+ fclose(fp);
+ }
+ }
+ else
+ {
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: creating budget-callbacksfile %s", entrycount, yylval.str)));
+ fp = fopen(yylval.str, "w");
+ if(fp != NULL)
+ fprintf(fp, "%d %d %d", (int)time(NULL), (int)time(NULL), 0);
+ fclose(fp);
+ }
+
+ fp = fopen(yylval.str, "r");
+ if(fp != NULL)
+ {
+ if((fscanf(fp, "%d %d %d", (int *)&s, (int *)&l, &n)) == 3)
+ {
+ if((cfg_entry_tab[entrycount].budget_callbacks_file = malloc(strlen(yylval.str)+1)) == NULL)
+ {
+ log(LL_ERR, "entry %d: budget-callbacksfile, malloc failed!", entrycount);
+ do_exit(1);
+ }
+ strcpy(cfg_entry_tab[entrycount].budget_callbacks_file, yylval.str);
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: using callbacksfile %s", entrycount, yylval.str)));
+ }
+ fclose(fp);
+ }
+ }
+ break;
+
+ case BUDGETCALLOUTSFILEROTATE:
+ cfg_entry_tab[entrycount].budget_calloutsfile_rotate = yylval.booln;
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: budget-calloutsfile-rotate = %d", entrycount, yylval.booln)));
+ break;
+
+ case BUDGETCALLOUTSFILE:
+ {
+ FILE *fp;
+ int s, l;
+ int n;
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: budget-calloutsfile = %s", entrycount, yylval.str)));
+ fp = fopen(yylval.str, "r");
+ if(fp != NULL)
+ {
+ if((fscanf(fp, "%d %d %d", (int *)&s, (int *)&l, &n)) != 3)
+ {
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: initializing budget-calloutsfile %s", entrycount, yylval.str)));
+ fclose(fp);
+ fp = fopen(yylval.str, "w");
+ if(fp != NULL)
+ fprintf(fp, "%d %d %d", (int)time(NULL), (int)time(NULL), 0);
+ fclose(fp);
+ }
+ }
+ else
+ {
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: creating budget-calloutsfile %s", entrycount, yylval.str)));
+ fp = fopen(yylval.str, "w");
+ if(fp != NULL)
+ fprintf(fp, "%d %d %d", (int)time(NULL), (int)time(NULL), 0);
+ fclose(fp);
+ }
+
+ fp = fopen(yylval.str, "r");
+ if(fp != NULL)
+ {
+ if((fscanf(fp, "%d %d %d", (int *)&s, (int *)&l, &n)) == 3)
+ {
+ if((cfg_entry_tab[entrycount].budget_callouts_file = malloc(strlen(yylval.str)+1)) == NULL)
+ {
+ log(LL_ERR, "entry %d: budget-calloutsfile, malloc failed!", entrycount);
+ do_exit(1);
+ }
+ strcpy(cfg_entry_tab[entrycount].budget_callouts_file, yylval.str);
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: using calloutsfile %s", entrycount, yylval.str)));
+ }
+ fclose(fp);
+ }
+ }
+ break;
+
case CALLBACKWAIT:
if(yylval.num < CALLBACKWAIT_MIN)
{
@@ -403,6 +654,16 @@ cfg_setval(int keyword)
cfg_entry_tab[entrycount].earlyhangup = yylval.num;
break;
+ case EXTCALLATTR:
+ DBGL(DL_RCCF, (log(LL_DBG, "system: extcallattr = %d", yylval.booln)));
+ extcallattr = yylval.booln;
+ break;
+
+ case HOLIDAYFILE:
+ strcpy(holidayfile, yylval.str);
+ DBGL(DL_RCCF, (log(LL_DBG, "system: holidayfile = %s", yylval.str)));
+ break;
+
case IDLE_ALG_OUT:
DBGL(DL_RCCF, (log(LL_DBG, "entry %d: idle-algorithm-outgoing = %s", entrycount, yylval.str)));
@@ -517,6 +778,82 @@ cfg_setval(int keyword)
strcpy(cfg_entry_tab[entrycount].name, yylval.str);
break;
+ case PPP_AUTH_RECHALLENGE:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: ppp-auth-rechallenge = %d", entrycount, yylval.booln)));
+ if(yylval.booln)
+ cfg_entry_tab[entrycount].ppp_auth_flags |= AUTH_RECHALLENGE;
+ else
+ cfg_entry_tab[entrycount].ppp_auth_flags &= ~AUTH_RECHALLENGE;
+ set_isppp_auth(entrycount);
+ break;
+
+ case PPP_AUTH_PARANOID:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: ppp-auth-paranoid = %d", entrycount, yylval.booln)));
+ if(yylval.booln)
+ cfg_entry_tab[entrycount].ppp_auth_flags |= AUTH_REQUIRED;
+ else
+ cfg_entry_tab[entrycount].ppp_auth_flags &= ~AUTH_REQUIRED;
+ set_isppp_auth(entrycount);
+ break;
+
+ case PPP_EXPECT_AUTH:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: ppp-expect-auth = %s", entrycount, yylval.str)));
+ if(!(strcmp(yylval.str, "none")))
+ cfg_entry_tab[entrycount].ppp_expect_auth = AUTH_NONE;
+ else if(!(strcmp(yylval.str, "pap")))
+ cfg_entry_tab[entrycount].ppp_expect_auth = AUTH_PAP;
+ else if(!(strcmp(yylval.str, "chap")))
+ cfg_entry_tab[entrycount].ppp_expect_auth = AUTH_CHAP;
+ else
+ {
+ log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"ppp-expect-auth\" at line %d!", lineno);
+ config_error_flag++;
+ break;
+ }
+ set_isppp_auth(entrycount);
+ break;
+
+ case PPP_EXPECT_NAME:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: ppp-expect-name = %s", entrycount, yylval.str)));
+ strncpy(cfg_entry_tab[entrycount].ppp_expect_name, yylval.str, sizeof(cfg_entry_tab[entrycount].ppp_expect_name) -1);
+ set_isppp_auth(entrycount);
+ break;
+
+ case PPP_EXPECT_PASSWORD:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: ppp-expect-password = %s", entrycount, yylval.str)));
+ strncpy(cfg_entry_tab[entrycount].ppp_expect_password, yylval.str, sizeof(cfg_entry_tab[entrycount].ppp_expect_password) -1);
+ set_isppp_auth(entrycount);
+ break;
+
+ case PPP_SEND_AUTH:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: ppp-send-auth = %s", entrycount, yylval.str)));
+ if(!(strcmp(yylval.str, "none")))
+ cfg_entry_tab[entrycount].ppp_send_auth = AUTH_NONE;
+ else if(!(strcmp(yylval.str, "pap")))
+ cfg_entry_tab[entrycount].ppp_send_auth = AUTH_PAP;
+ else if(!(strcmp(yylval.str, "chap")))
+ cfg_entry_tab[entrycount].ppp_send_auth = AUTH_CHAP;
+ else
+ {
+ log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"ppp-send-auth\" at line %d!", lineno);
+ config_error_flag++;
+ break;
+ }
+ set_isppp_auth(entrycount);
+ break;
+
+ case PPP_SEND_NAME:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: ppp-send-name = %s", entrycount, yylval.str)));
+ strncpy(cfg_entry_tab[entrycount].ppp_send_name, yylval.str, sizeof(cfg_entry_tab[entrycount].ppp_send_name) -1);
+ set_isppp_auth(entrycount);
+ break;
+
+ case PPP_SEND_PASSWORD:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: ppp-send-password = %s", entrycount, yylval.str)));
+ strncpy(cfg_entry_tab[entrycount].ppp_send_password, yylval.str, sizeof(cfg_entry_tab[entrycount].ppp_send_password) -1);
+ set_isppp_auth(entrycount);
+ break;
+
case PROTOCOL:
DBGL(DL_RCCF, (log(LL_DBG, "controller %d: protocol = %s", controllercount, yylval.str)));
if(!(strcmp(yylval.str, "dss1")))
@@ -743,6 +1080,8 @@ cfg_setval(int keyword)
else if(!strcmp(yylval.str, "ibc"))
cfg_entry_tab[entrycount].usrdevicename = BDRV_IBC;
#endif
+ else if(!strcmp(yylval.str, "ing"))
+ cfg_entry_tab[entrycount].usrdevicename = BDRV_ING;
else
{
log(LL_ERR, "ERROR parsing config file: unknown parameter for keyword \"usrdevicename\" at line %d!", lineno);
@@ -765,6 +1104,11 @@ cfg_setval(int keyword)
cfg_entry_tab[entrycount].usedown = yylval.booln;
break;
+ case VALID:
+ DBGL(DL_RCCF, (log(LL_DBG, "entry %d: valid = %s", entrycount, yylval.str)));
+ parse_valid(entrycount, yylval.str);
+ break;
+
default:
log(LL_ERR, "ERROR parsing config file: unknown keyword at line %d!", lineno);
config_error_flag++;
@@ -773,6 +1117,87 @@ cfg_setval(int keyword)
}
/*---------------------------------------------------------------------------*
+ * parse a date/time range
+ *---------------------------------------------------------------------------*/
+static void
+parse_valid(int entrycount, char *dt)
+{
+ /* a valid string consists of some days of week separated by
+ * commas, where 0=sunday, 1=monday .. 6=saturday and a special
+ * value of 7 which is a holiday from the holiday file.
+ * after the days comes an optional (!) time range in the form
+ * aa:bb-cc:dd, this format is fixed to be parsable by sscanf.
+ * Valid specifications looks like this:
+ * 1,2,3,4,5,09:00-18:00 Monday-Friday 9-18h
+ * 1,2,3,4,5,18:00-09:00 Monday-Friday 18-9h
+ * 6 Saturday (whole day)
+ * 0,7 Sunday and Holidays
+ */
+
+ int day = 0;
+ int fromhr = 0;
+ int frommin = 0;
+ int tohr = 0;
+ int tomin = 0;
+ int ret;
+
+ for(;;)
+ {
+ if( ( ((*dt >= '0') && (*dt <= '9')) && (*(dt+1) == ':') ) ||
+ ( ((*dt >= '0') && (*dt <= '2')) && ((*(dt+1) >= '0') && (*(dt+1) <= '9')) && (*(dt+2) == ':') ) )
+ {
+ /* dt points to time spec */
+ ret = sscanf(dt, "%d:%d-%d:%d", &fromhr, &frommin, &tohr, &tomin);
+ if(ret !=4)
+ {
+ log(LL_ERR, "ERROR parsing config file: timespec [%s] error at line %d!", *dt, lineno);
+ config_error_flag++;
+ return;
+ }
+
+ if(fromhr < 0 || fromhr > 24 || tohr < 0 || tohr > 24 ||
+ frommin < 0 || frommin > 59 || tomin < 0 || tomin > 59)
+ {
+ log(LL_ERR, "ERROR parsing config file: invalid time [%s] at line %d!", *dt, lineno);
+ config_error_flag++;
+ return;
+ }
+ break;
+ }
+ else if ((*dt >= '0') && (*dt <= '7'))
+ {
+ /* dt points to day spec */
+ day |= 1 << (*dt - '0');
+ dt++;
+ continue;
+ }
+ else if (*dt == ',')
+ {
+ /* dt points to delimiter */
+ dt++;
+ continue;
+ }
+ else if (*dt == '\0')
+ {
+ /* dt points to end of string */
+ break;
+ }
+ else
+ {
+ /* dt points to illegal character */
+ log(LL_ERR, "ERROR parsing config file: illegal character [%c=0x%x] in date/time spec at line %d!", *dt, *dt, lineno);
+ config_error_flag++;
+ return;
+ }
+ }
+ cfg_entry_tab[entrycount].day = day;
+ cfg_entry_tab[entrycount].fromhr = fromhr;
+ cfg_entry_tab[entrycount].frommin = frommin;
+ cfg_entry_tab[entrycount].tohr = tohr;
+ cfg_entry_tab[entrycount].tomin = tomin;
+}
+
+/*---------------------------------------------------------------------------*
* configuration validation and consistency check
*---------------------------------------------------------------------------*/
static void
@@ -806,8 +1231,7 @@ check_config(void)
if((cep->isdncontroller < 0) || (cep->isdncontroller > (ncontroller-1)))
{
- log(LL_ERR, "check_config: isdncontroller out of range in entry %d!", i);
- error++;
+ log(LL_ERR, "check_config: WARNING, isdncontroller out of range in entry %d!", i);
}
/* numbers used for dialout */
@@ -847,6 +1271,33 @@ check_config(void)
log(LL_ERR, "check_config: b1protocol not raw for telephony in entry %d!", i);
error++;
}
+
+ if((cep->ppp_send_auth == AUTH_PAP) || (cep->ppp_send_auth == AUTH_CHAP))
+ {
+ if(cep->ppp_send_name[0] == 0)
+ {
+ log(LL_ERR, "check_config: no remote authentification name in entry %d!", i);
+ error++;
+ }
+ if(cep->ppp_send_password[0] == 0)
+ {
+ log(LL_ERR, "check_config: no remote authentification password in entry %d!", i);
+ error++;
+ }
+ }
+ if((cep->ppp_expect_auth == AUTH_PAP) || (cep->ppp_expect_auth == AUTH_CHAP))
+ {
+ if(cep->ppp_expect_name[0] == 0)
+ {
+ log(LL_ERR, "check_config: no local authentification name in entry %d!", i);
+ error++;
+ }
+ if(cep->ppp_expect_password[0] == 0)
+ {
+ log(LL_ERR, "check_config: no local authentification secret in entry %d!", i);
+ error++;
+ }
+ }
}
if(error)
{
@@ -1165,6 +1616,64 @@ print_config(void)
}
}
+ if(cep->usrdevicename == BDRV_ISPPP)
+ {
+ char *s;
+ switch(cep->ppp_expect_auth)
+ {
+ case AUTH_NONE:
+ s = "none";
+ break;
+ case AUTH_PAP:
+ s = "pap";
+ break;
+ case AUTH_CHAP:
+ s = "chap";
+ break;
+ default:
+ s = NULL;
+ break;
+ }
+ if(s != NULL)
+ {
+ fprintf(PFILE, "ppp-expect-auth = %s\t\t# the auth protocol we expect to receive on dial-in (none,pap,chap)\n", s);
+ if(cep->ppp_expect_auth != AUTH_NONE)
+ {
+ fprintf(PFILE, "ppp-expect-name = %s\t\t# the user name allowed in\n", cep->ppp_expect_name);
+ fprintf(PFILE, "ppp-expect-password = %s\t\t# the key expected from the other side\n", cep->ppp_expect_password);
+ fprintf(PFILE, "ppp-auth-paranoid = %s\t\t# do we require remote to authenticate even if we dial out\n", cep->ppp_auth_flags & AUTH_REQUIRED ? "yes" : "no");
+ }
+ }
+ switch(cep->ppp_send_auth)
+ {
+ case AUTH_NONE:
+ s = "none";
+ break;
+ case AUTH_PAP:
+ s = "pap";
+ break;
+ case AUTH_CHAP:
+ s = "chap";
+ break;
+ default:
+ s = NULL;
+ break;
+ }
+ if(s != NULL)
+ {
+ fprintf(PFILE, "ppp-send-auth = %s\t\t# the auth protocol we use when dialing out (none,pap,chap)\n", s);
+ if(cep->ppp_send_auth != AUTH_NONE)
+ {
+ fprintf(PFILE, "ppp-send-name = %s\t\t# our PPP account used for dial-out\n", cep->ppp_send_name);
+ fprintf(PFILE, "ppp-send-password = %s\t\t# the key sent to the other side\n", cep->ppp_send_password);
+ }
+ }
+ if(cep->ppp_send_auth == AUTH_CHAP ||
+ cep->ppp_expect_auth == AUTH_CHAP) {
+ fprintf(PFILE, "ppp-auth-rechallenge = %s\t\t# rechallenge CHAP connections once in a while\n", cep->ppp_auth_flags & AUTH_RECHALLENGE ? "yes" : "no");
+ }
+ }
+
if(!((cep->inout == DIR_INONLY) || (cep->usrdevicename == BDRV_TEL)))
{
char *s;
diff --git a/usr.sbin/i4b/isdnd/rc_parse.y b/usr.sbin/i4b/isdnd/rc_parse.y
index bace84d..428adc0 100644
--- a/usr.sbin/i4b/isdnd/rc_parse.y
+++ b/usr.sbin/i4b/isdnd/rc_parse.y
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1997 Joerg Wunsch. All rights reserved.
*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,11 +30,11 @@
* i4b daemon - runtime configuration parser
* -----------------------------------------
*
- * $Id: rc_parse.y,v 1.24 1999/12/13 21:25:25 hm Exp $
+ * $Id: rc_parse.y,v 1.30 2000/10/09 11:17:07 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:48:48 1999]
+ * last edit-date: [Mon Oct 2 22:51:23 2000]
*
*---------------------------------------------------------------------------*/
@@ -81,6 +81,14 @@ int controllercount = -1;
%token ANSWERPROG
%token B1PROTOCOL
%token BEEPCONNECT
+%token BUDGETCALLOUTPERIOD
+%token BUDGETCALLOUTNCALLS
+%token BUDGETCALLOUTSFILE
+%token BUDGETCALLOUTSFILEROTATE
+%token BUDGETCALLBACKPERIOD
+%token BUDGETCALLBACKNCALLS
+%token BUDGETCALLBACKSFILE
+%token BUDGETCALLBACKSFILEROTATE
%token CALLBACKWAIT
%token CALLEDBACKWAIT
%token CALLIN
@@ -97,7 +105,9 @@ int controllercount = -1;
%token DOWNTRIES
%token EARLYHANGUP
%token ENTRY
+%token EXTCALLATTR
%token FULLCMD
+%token HOLIDAYFILE
%token IDLETIME_IN
%token IDLETIME_OUT
%token IDLE_ALG_OUT
@@ -119,6 +129,14 @@ int controllercount = -1;
%token NO
%token OFF
%token ON
+%token PPP_AUTH_RECHALLENGE
+%token PPP_AUTH_PARANOID
+%token PPP_EXPECT_AUTH
+%token PPP_EXPECT_NAME
+%token PPP_EXPECT_PASSWORD
+%token PPP_SEND_AUTH
+%token PPP_SEND_NAME
+%token PPP_SEND_PASSWORD
%token PROTOCOL
%token RATESFILE
%token RATETYPE
@@ -140,6 +158,7 @@ int controllercount = -1;
%token USEDOWN
%token USRDEVICENAME
%token USRDEVICEUNIT
+%token VALID
%token YES
@@ -150,7 +169,7 @@ int controllercount = -1;
%type <booln> boolean
%type <num> sysfilekeyword sysnumkeyword sysstrkeyword sysboolkeyword
-%type <num> numkeyword strkeyword boolkeyword monrights monright
+%type <num> filekeyword numkeyword strkeyword boolkeyword monrights monright
%type <num> cstrkeyword
%type <str> filename
@@ -316,6 +335,7 @@ boolean: NO { $$ = FALSE; }
sysfilekeyword: RATESFILE { $$ = RATESFILE; }
| ACCTFILE { $$ = ACCTFILE; }
| ALIASFNAME { $$ = ALIASFNAME; }
+ | HOLIDAYFILE { $$ = HOLIDAYFILE; }
| TINAINITPROG { $$ = TINAINITPROG; }
;
@@ -323,6 +343,7 @@ sysboolkeyword: USEACCTFILE { $$ = USEACCTFILE; }
| ALIASING { $$ = ALIASING; }
| ACCTALL { $$ = ACCTALL; }
| BEEPCONNECT { $$ = BEEPCONNECT; }
+ | EXTCALLATTR { $$ = EXTCALLATTR; }
| ISDNTIME { $$ = ISDNTIME; }
| MONITORSW { $$ = MONITORSW; }
;
@@ -354,13 +375,21 @@ entries: entry
| entries entry
;
-entry: strentry
+entry: fileentry
+ | strentry
| numentry
| boolentry
| nullentry
| error '\n'
;
+fileentry: filekeyword '=' filename '\n'
+ {
+ cfg_setval($1);
+ }
+ ;
+
+
strentry: strkeyword '=' STRING '\n'
{
cfg_setval($1);
@@ -385,6 +414,10 @@ numentry: numkeyword '=' NUMBERSTR '\n'
}
;
+filekeyword: BUDGETCALLBACKSFILE { $$ = BUDGETCALLBACKSFILE; }
+ | BUDGETCALLOUTSFILE { $$ = BUDGETCALLOUTSFILE; }
+ ;
+
strkeyword: ANSWERPROG { $$ = ANSWERPROG; }
| B1PROTOCOL { $$ = B1PROTOCOL; }
| CONNECTPROG { $$ = CONNECTPROG; }
@@ -395,15 +428,26 @@ strkeyword: ANSWERPROG { $$ = ANSWERPROG; }
| LOCAL_PHONE_INCOMING { $$ = LOCAL_PHONE_INCOMING; }
| LOCAL_PHONE_DIALOUT { $$ = LOCAL_PHONE_DIALOUT; }
| NAME { $$ = NAME; }
+ | PPP_EXPECT_AUTH { $$ = PPP_EXPECT_AUTH; }
+ | PPP_EXPECT_NAME { $$ = PPP_EXPECT_NAME; }
+ | PPP_EXPECT_PASSWORD { $$ = PPP_EXPECT_PASSWORD; }
+ | PPP_SEND_AUTH { $$ = PPP_SEND_AUTH; }
+ | PPP_SEND_NAME { $$ = PPP_SEND_NAME; }
+ | PPP_SEND_PASSWORD { $$ = PPP_SEND_PASSWORD; }
| REACTION { $$ = REACTION; }
| REMOTE_NUMBERS_HANDLING { $$ = REMOTE_NUMBERS_HANDLING; }
| REMOTE_PHONE_INCOMING { $$ = REMOTE_PHONE_INCOMING; }
| REMOTE_PHONE_DIALOUT { $$ = REMOTE_PHONE_DIALOUT; }
| UNITLENGTHSRC { $$ = UNITLENGTHSRC; }
| USRDEVICENAME { $$ = USRDEVICENAME; }
+ | VALID { $$ = VALID; }
;
numkeyword: ALERT { $$ = ALERT; }
+ | BUDGETCALLBACKPERIOD { $$ = BUDGETCALLBACKPERIOD; }
+ | BUDGETCALLBACKNCALLS { $$ = BUDGETCALLBACKNCALLS; }
+ | BUDGETCALLOUTPERIOD { $$ = BUDGETCALLOUTPERIOD; }
+ | BUDGETCALLOUTNCALLS { $$ = BUDGETCALLOUTNCALLS; }
| CALLBACKWAIT { $$ = CALLBACKWAIT; }
| CALLEDBACKWAIT { $$ = CALLEDBACKWAIT; }
| DIALRETRIES { $$ = DIALRETRIES; }
@@ -422,11 +466,14 @@ numkeyword: ALERT { $$ = ALERT; }
| DOWNTRIES { $$ = DOWNTRIES; }
;
-boolkeyword: DIALRANDINCR { $$ = DIALRANDINCR; }
+boolkeyword: BUDGETCALLBACKSFILEROTATE { $$ = BUDGETCALLBACKSFILEROTATE; }
+ | BUDGETCALLOUTSFILEROTATE { $$ = BUDGETCALLOUTSFILEROTATE; }
+ | DIALRANDINCR { $$ = DIALRANDINCR; }
+ | PPP_AUTH_RECHALLENGE { $$ = PPP_AUTH_RECHALLENGE; }
+ | PPP_AUTH_PARANOID { $$ = PPP_AUTH_PARANOID; }
| USEDOWN { $$ = USEDOWN; }
;
-
/* ================== */
/* controller section */
/* ================== */
diff --git a/usr.sbin/i4b/isdnd/rc_scan.l b/usr.sbin/i4b/isdnd/rc_scan.l
index e9d9814..198d269 100644
--- a/usr.sbin/i4b/isdnd/rc_scan.l
+++ b/usr.sbin/i4b/isdnd/rc_scan.l
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1997 Joerg Wunsch. All rights reserved.
*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,11 +30,11 @@
* i4b daemon - runtime configuration lexical analyzer
* ---------------------------------------------------
*
- * $Id: rc_scan.l,v 1.27 1999/12/13 21:25:25 hm Exp $
+ * $Id: rc_scan.l,v 1.33 2000/10/09 11:17:07 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:48:57 1999]
+ * last edit-date: [Mon Oct 2 22:49:40 2000]
*
*---------------------------------------------------------------------------*/
@@ -95,6 +95,14 @@ aliasfile { return ALIASFNAME; }
answerprog { return ANSWERPROG; }
b1protocol { return B1PROTOCOL; }
beepconnect { return BEEPCONNECT; }
+budget-callbackperiod { return BUDGETCALLBACKPERIOD; }
+budget-callbackncalls { return BUDGETCALLBACKNCALLS; }
+budget-callbacksfile { return BUDGETCALLBACKSFILE; }
+budget-callbacksfile-rotate { return BUDGETCALLBACKSFILEROTATE; }
+budget-calloutperiod { return BUDGETCALLOUTPERIOD; }
+budget-calloutncalls { return BUDGETCALLOUTNCALLS; }
+budget-calloutsfile { return BUDGETCALLOUTSFILE; }
+budget-calloutsfile-rotate { return BUDGETCALLOUTSFILEROTATE; }
callbackwait { return CALLBACKWAIT; }
calledbackwait { return CALLEDBACKWAIT; }
connectprog { return CONNECTPROG; }
@@ -109,6 +117,8 @@ downtries { return DOWNTRIES; }
downtime { return DOWNTIME; }
earlyhangup { return EARLYHANGUP; }
entry { return ENTRY; }
+extcallattr { return EXTCALLATTR; }
+holidayfile { return HOLIDAYFILE; }
idletime-incoming { return IDLETIME_IN; }
idletime-outgoing { return IDLETIME_OUT; }
idle-algorithm-outgoing { return IDLE_ALG_OUT; }
@@ -135,6 +145,14 @@ name { return NAME; }
no { return NO; }
off { return OFF; }
on { return ON; }
+ppp-auth-rechallenge { return PPP_AUTH_RECHALLENGE; }
+ppp-auth-paranoid { return PPP_AUTH_PARANOID; }
+ppp-expect-auth { return PPP_EXPECT_AUTH; }
+ppp-expect-name { return PPP_EXPECT_NAME; }
+ppp-expect-password { return PPP_EXPECT_NAME; }
+ppp-send-auth { return PPP_SEND_AUTH; }
+ppp-send-name { return PPP_SEND_NAME; }
+ppp-send-password { return PPP_SEND_PASSWORD; }
protocol { return PROTOCOL; }
ratesfile { return RATESFILE; }
ratetype { return RATETYPE; }
@@ -154,6 +172,7 @@ useacctfile { return USEACCTFILE; }
usrdevicename { return USRDEVICENAME; }
usrdeviceunit { return USRDEVICEUNIT; }
usedown { return USEDOWN; }
+valid { return VALID; }
yes { return YES; }
\n { lineno++; return '\n'; }
diff --git a/usr.sbin/i4b/isdnd/support.c b/usr.sbin/i4b/isdnd/support.c
index 07a40f4..d8c7896 100644
--- a/usr.sbin/i4b/isdnd/support.c
+++ b/usr.sbin/i4b/isdnd/support.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,15 +27,17 @@
* i4b daemon - misc support routines
* ----------------------------------
*
- * $Id: support.c,v 1.63 1999/12/13 21:25:25 hm Exp $
+ * $Id: support.c,v 1.66 2000/10/09 11:17:07 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:49:05 1999]
+ * last edit-date: [Wed Oct 4 18:24:27 2000]
*
*---------------------------------------------------------------------------*/
#include "isdnd.h"
+
+static int isvalidtime(cfg_entry_t *cep);
/*---------------------------------------------------------------------------*
* find an active entry by driver type and driver unit
@@ -56,6 +58,14 @@ find_active_entry_by_driver(int drivertype, int driverunit)
continue;
}
+ /* check time interval */
+
+ if(isvalidtime(cep) == 0)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "find_active_entry_by_driver: entry %d, time not valid!", i)));
+ continue;
+ }
+
/* found */
if(cep->cdid == CDID_UNUSED)
@@ -96,6 +106,14 @@ find_by_device_for_dialout(int drivertype, int driverunit)
continue;
}
+ /* check time interval */
+
+ if(isvalidtime(cep) == 0)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialout: entry %d, time not valid!", i)));
+ continue;
+ }
+
/* found, check if already reserved */
if(cep->cdid == CDID_RESERVED)
@@ -151,6 +169,14 @@ find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, cha
continue;
}
+ /* check time interval */
+
+ if(isvalidtime(cep) == 0)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_dialoutnumber: entry %d, time not valid!", i)));
+ continue;
+ }
+
/* found, check if already reserved */
if(cep->cdid == CDID_RESERVED)
@@ -275,6 +301,14 @@ get_cep_by_driver(int drivertype, int driverunit)
continue;
}
+ /* check time interval */
+
+ if(isvalidtime(cep) == 0)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "get_cep_by_driver: entry %d, time not valid!", i)));
+ continue;
+ }
+
DBGL(DL_MSG, (log(LL_DBG, "get_cep_by_driver: found entry %d!", i)));
return(cep);
}
@@ -347,35 +381,6 @@ find_matching_entry_incoming(msg_connect_ind_t *mp)
}
if (n >= cep->incoming_numbers_count)
continue;
-
- /* screening indicator XXX */
-
- switch(mp->scr_ind)
- {
- case SCR_NONE:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - no screening indicator", mp->src_telno)));
- break;
-
- case SCR_USR_NOSC:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - screening user provided, not screened", mp->src_telno)));
- break;
-
- case SCR_USR_PASS:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - screening user provided, verified & passed", mp->src_telno)));
- break;
-
- case SCR_USR_FAIL:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - screening user provided, verified & failed", mp->src_telno)));
- break;
-
- case SCR_NET:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: %s - screening network provided", mp->src_telno)));
- break;
-
- default:
- DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: ERROR %s - invalid screening indicator!", mp->src_telno)));
- break;
- }
/* check b protocol */
@@ -476,13 +481,21 @@ find_matching_entry_incoming(msg_connect_ind_t *mp)
break;
}
+ /* check time interval */
+
+ if(isvalidtime(cep) == 0)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, time not valid!", i)));
+ continue;
+ }
+
/* found a matching entry */
cep->cdid = mp->header.cdid;
cep->isdncontrollerused = mp->controller;
cep->isdnchannelused = mp->channel;
/*XXX*/ cep->disc_cause = 0;
-
+
/* cp number to real one used */
strcpy(cep->real_phone_incoming, mp->src_telno);
@@ -589,10 +602,11 @@ bdrivername(int drivertype)
"tel",
"ipr",
"isp",
- "ibc"
+ "ibc",
+ "ing"
};
- if(drivertype >= BDRV_RBCH && drivertype <= BDRV_IBC)
+ if(drivertype >= BDRV_RBCH && drivertype <= BDRV_ING)
return(bdtab[drivertype]);
else
return("unknown");
@@ -849,5 +863,162 @@ dialresponse(cfg_entry_t *cep, int dstat)
DBGL(DL_DRVR, (log(LL_DBG, "dialresponse: sent [%s]", stattab[dstat])));
}
-/* EOF */
+/*--------------------------------------------------------------------------*
+ * screening/presentation indicator
+ *--------------------------------------------------------------------------*/
+void
+handle_scrprs(int cdid, int scr, int prs, char *caller)
+{
+ /* screening indicator */
+
+ if(scr < SCR_NONE || scr > SCR_NET)
+ {
+ log(LL_ERR, "msg_connect_ind: invalid screening indicator value %d!", scr);
+ }
+ else
+ {
+ static char *scrtab[] = {
+ "no screening indicator",
+ "sreening user provided, not screened",
+ "screening user provided, verified & passed",
+ "screening user provided, verified & failed",
+ "screening network provided", };
+
+ if(extcallattr)
+ {
+ log(LL_CHD, "%05d %s %s", cdid, caller, scrtab[scr]);
+ }
+ else
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "%s - %s", caller, scrtab[scr])));
+ }
+ }
+
+ /* presentation indicator */
+
+ if(prs < PRS_NONE || prs > PRS_RESERVED)
+ {
+ log(LL_ERR, "msg_connect_ind: invalid presentation indicator value %d!", prs);
+ }
+ else
+ {
+ static char *prstab[] = {
+ "no presentation indicator",
+ "presentation allowed",
+ "presentation restricted",
+ "number not available due to interworking",
+ "reserved presentation value" };
+
+ if(extcallattr)
+ {
+ log(LL_CHD, "%05d %s %s", cdid, caller, prstab[prs]);
+ }
+ else
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "%s - %s", caller, prstab[prs])));
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*
+ * check if the time is valid for an entry
+ *--------------------------------------------------------------------------*/
+static int
+isvalidtime(cfg_entry_t *cep)
+{
+ time_t t;
+ struct tm *tp;
+
+ if(cep->day == 0)
+ return(1);
+
+ t = time(NULL);
+ tp = localtime(&t);
+
+ if(cep->day & HD)
+ {
+ if(isholiday(tp->tm_mday, (tp->tm_mon)+1, (tp->tm_year)+1900))
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isvalidtime: holiday %d.%d.%d", tp->tm_mday, (tp->tm_mon)+1, (tp->tm_year)+1900)));
+ goto dayok;
+ }
+ }
+
+ if(cep->day & (1 << tp->tm_wday))
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isvalidtime: day match")));
+ goto dayok;
+ }
+
+ return(0);
+
+dayok:
+ if(cep->fromhr==0 && cep->frommin==0 && cep->tohr==0 && cep->tomin==0)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isvalidtime: no time specified, match!")));
+ return(1);
+ }
+
+ if(cep->tohr < cep->fromhr)
+ {
+ /* before 00:00 */
+
+ if( (tp->tm_hour > cep->fromhr) ||
+ (tp->tm_hour == cep->fromhr && tp->tm_min > cep->frommin) )
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isvalidtime: t<f-1, spec=%02d:%02d-%02d:%02d, curr=%02d:%02d, match!",
+ cep->fromhr, cep->frommin,
+ cep->tohr, cep->tomin,
+ tp->tm_hour, tp->tm_min)));
+
+ return(1);
+ }
+
+ /* after 00:00 */
+
+ if( (tp->tm_hour < cep->tohr) ||
+ (tp->tm_hour == cep->tohr && tp->tm_min < cep->tomin) )
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isvalidtime: t<f-2, spec=%02d:%02d-%02d:%02d, curr=%02d:%02d, match!",
+ cep->fromhr, cep->frommin,
+ cep->tohr, cep->tomin,
+ tp->tm_hour, tp->tm_min)));
+
+ return(1);
+ }
+ }
+ else if(cep->fromhr == cep->tohr)
+ {
+ if(tp->tm_min >= cep->frommin && tp->tm_min < cep->tomin)
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isvalidtime: f=t, spec=%02d:%02d-%02d:%02d, curr=%02d:%02d, match!",
+ cep->fromhr, cep->frommin,
+ cep->tohr, cep->tomin,
+ tp->tm_hour, tp->tm_min)));
+
+ return(1);
+ }
+ }
+ else
+ {
+ if((tp->tm_hour > cep->fromhr && tp->tm_hour < cep->tohr) ||
+ (tp->tm_hour == cep->fromhr && tp->tm_min >= cep->frommin) ||
+ (tp->tm_hour == cep->tohr && tp->tm_min < cep->tomin) )
+ {
+ DBGL(DL_MSG, (log(LL_DBG, "isvalidtime: t>f, spec=%02d:%02d-%02d:%02d, curr=%02d:%02d, match!",
+ cep->fromhr, cep->frommin,
+ cep->tohr, cep->tomin,
+ tp->tm_hour, tp->tm_min)));
+ return(1);
+ }
+ }
+ DBGL(DL_MSG, (log(LL_DBG, "isvalidtime: spec=%02d:%02d-%02d:%02d, curr=%02d:%02d, no match!",
+ cep->fromhr, cep->frommin,
+ cep->tohr, cep->tomin,
+ tp->tm_hour, tp->tm_min)));
+
+ return(0);
+}
+
+/* EOF */
diff --git a/usr.sbin/i4b/isdnd/timer.c b/usr.sbin/i4b/isdnd/timer.c
index 34dea3a..b2b7630 100644
--- a/usr.sbin/i4b/isdnd/timer.c
+++ b/usr.sbin/i4b/isdnd/timer.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* i4b daemon - timer/timing support routines
* ------------------------------------------
*
- * $Id: timer.c,v 1.19 1999/12/13 21:25:25 hm Exp $
+ * $Id: timer.c,v 1.21 2000/05/03 09:32:38 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:49:13 1999]
+ * last edit-date: [Tue May 2 15:58:31 2000]
*
*---------------------------------------------------------------------------*/
@@ -142,6 +142,28 @@ handle_recovery(void)
{
cep = &cfg_entry_tab[i]; /* ptr to config entry */
+ if(cep->budget_callbackperiod && cep->budget_callbackncalls)
+ {
+ if(cep->budget_callbackperiod_time <= now)
+ {
+ DBGL(DL_BDGT, (log(LL_DBG, "%s: new cback-budget-period (%d s, %d left)",
+ cep->name, cep->budget_callbackperiod, cep->budget_callbackncalls_cnt)));
+ cep->budget_callbackperiod_time = now + cep->budget_callbackperiod;
+ cep->budget_callbackncalls_cnt = cep->budget_callbackncalls;
+ }
+ }
+
+ if(cep->budget_calloutperiod && cep->budget_calloutncalls)
+ {
+ if(cep->budget_calloutperiod_time <= now)
+ {
+ DBGL(DL_BDGT, (log(LL_DBG, "%s: new cout-budget-period (%d s, %d left)",
+ cep->name, cep->budget_calloutperiod, cep->budget_calloutncalls_cnt)));
+ cep->budget_calloutperiod_time = now + cep->budget_calloutperiod;
+ cep->budget_calloutncalls_cnt = cep->budget_calloutncalls;
+ }
+ }
+
switch(cep->cdid)
{
case CDID_UNUSED: /* entry unused */
OpenPOWER on IntegriCloud