2 * Copyright (c) 1997, 2001 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 *---------------------------------------------------------------------------
27 * i4b daemon - main header file
28 * -----------------------------
30 * $FreeBSD: src/usr.sbin/i4b/isdnd/isdnd.h,v 1.6.2.5 2002/04/24 18:50:07 joerg Exp $
32 * last edit-date: [Mon Dec 31 12:42:58 2001]
34 *---------------------------------------------------------------------------*/
59 #include <sys/queue.h> /* TAILQ_ macros */
60 #include <sys/param.h>
63 #include <sys/types.h>
64 #include <sys/ioctl.h>
67 #include <sys/rtprio.h>
70 #include <net/if_sppp.h>
72 #include <machine/i4b_ioctl.h>
73 #include <machine/i4b_cause.h>
75 #include "config.h" /* compile time configuration */
76 #include "pathnames.h" /* location of files */
77 #include "alias.h" /* alias file processing */
79 /*---------------------------------------------------------------------------*
80 * some general definitions
81 *---------------------------------------------------------------------------*/
82 #define GOOD 0 /* general "good" or "ok" return*/
83 #define ERROR (-1) /* general error return */
84 #define WARNING (-2) /* warning return */
85 #define INVALID (-1) /* an invalid integer */
87 /*---------------------------------------------------------------------------*
89 *---------------------------------------------------------------------------*/
90 #define RTPRIO_NOTUSED (-1) /* rtprio is not used for isdnd */
92 /*---------------------------------------------------------------------------*
94 *---------------------------------------------------------------------------*/
95 #define DL_MSG 0x0001 /* general debug messages */
96 #define DL_RATES 0x0002 /* messages related to rates */
97 #define DL_TIME 0x0004 /* messages related to timing */
98 #define DL_STATE 0x0008 /* messages related to states changes */
99 #define DL_RCVRY 0x0010 /* messages related to dial recovery */
100 #define DL_DIAL 0x0020 /* messages related to dial recovery */
101 #define DL_PROC 0x0040 /* messages related to process handling */
102 #define DL_DRVR 0x0080 /* messages related to kernel i4b msg i/o*/
103 #define DL_CNST 0x0100 /* messages related to controller state */
104 #define DL_RCCF 0x0200 /* messages related to isdnd.rc at boot */
105 #define DL_BDGT 0x0400 /* messages related to budgets */
106 #define DL_VALID 0x0800 /* messages related to valid keyword */
109 #define DBGL(cond, dolog) if(cond & debug_flags) dolog
111 #define DBGL(cond, dolog)
114 /*---------------------------------------------------------------------------*
115 * curses fullscreen display definitions
116 *---------------------------------------------------------------------------*/
118 /* window dimensions */
119 #define UPPER_B 2 /* upper window start */
121 /* horizontal positions for upper window */
122 #define H_CNTL 0 /* controller */
123 #define H_TEI 2 /* TEI */
124 #define H_CHAN (H_TEI+4) /* channel */
125 #define H_TELN (H_CHAN+2) /* telephone number */
126 #define H_IFN (H_TELN+23) /* interfacename */
127 #define H_IO (H_IFN+7) /* incoming or outgoing */
128 #define H_OUT (H_IO+4) /* # of bytes out */
129 #define H_OUTBPS (H_OUT+11) /* bytes per second out */
130 #define H_IN (H_OUTBPS+5) /* # of bytes in */
131 #define H_INBPS (H_IN+11) /* bytes per second in */
132 #define H_UNITS (H_INBPS+6) /* # of charging units */
134 /* fullscreen mode menu window */
135 #define WMENU_LEN 35 /* width of menu window */
136 #define WMENU_TITLE "Command" /* title string */
137 #define WMENU_POSLN 10 /* menu position, line */
138 #define WMENU_POSCO 5 /* menu position, col */
139 #define WMITEMS 6 /* no of menu items */
140 #define WMENU_HGT (WMITEMS + 4) /* menu window height */
149 #define WMTIMEOUT 5 /* timeout in seconds */
151 /*---------------------------------------------------------------------------*
153 *---------------------------------------------------------------------------*/
154 #define NDAYS 7 /* number of days in a week */
155 #define NRATES 4 /* number of rate structures supported */
157 /* struct for rates - each day has one or more */
160 int start_time; /* hour and min at which this rate starts, e.g. 12:20 12*60+20*/
161 int end_time; /* hour and min at which this rate ends, e.g. 19:10 19*60+10*/
162 int rate; /* how long can I telephone at this price, seconds */
166 /*---------------------------------------------------------------------------*
167 * the internal identifiers for isdnd log levels. CAUTION: this has to stay
168 * in sync with the loglevel to text and sysloglevel table in log.c !!
169 *---------------------------------------------------------------------------*/
172 LL_ERR, /* error conditions - everything which caused an error */
173 LL_WRN, /* warning conditions - nonfatal abnormal conditions */
174 LL_DMN, /* normal but significant condition - status of daemon */
175 LL_CHD, /* informational - everything regarding call handling */
176 LL_DBG, /* debug messages - everything which helps debugging */
177 LL_MER, /* monitor error messages - not sent to remote */
178 LL_PKT /* packet logging - log the first few packets */
181 /*---------------------------------------------------------------------------*
182 * state machine events
183 *---------------------------------------------------------------------------*/
186 /* incoming messages */
188 EV_MCI, /* MSG_CONNECT_IND */
189 EV_MCAI, /* MSG_CONNECT_ACTIVE_IND */
190 EV_MDI, /* MSG_DISCONNECT_IND */
191 EV_MDO, /* MSG_DIALOUT */
195 EV_TIMO, /* timer expired */
196 EV_DRQ, /* disconnect request */
197 EV_CBRQ, /* callback request */
198 EV_ALRT, /* alerting request */
202 EV_ILL /* illegal event */
205 #define N_EVENTS (EV_ILL+1) /* no of possible events */
207 /*---------------------------------------------------------------------------*
208 * this struct describes the numbers to try to dial out
209 *---------------------------------------------------------------------------*/
211 char number[TELNO_MAX]; /* remote number to dial */
212 int flag; /* usage flag */
214 #define RNF_SUCC 1 /* last dial was ok */
217 /*---------------------------------------------------------------------------*
218 * this struct describes numbers allowed to dial in
219 *---------------------------------------------------------------------------*/
221 char number[TELNO_MAX]; /* calling party number */
224 /*---------------------------------------------------------------------------*
225 * this structure describes a prematurely aborted called-back dialout
226 *---------------------------------------------------------------------------*/
228 int cdid; /* call handle */
229 int controller; /* the controller used to dial out */
230 int channel; /* the channel assigned to the outgoing call */
231 /* XXX - timeout handling and error recovery? */
234 /*---------------------------------------------------------------------------*
235 * this struct describes one complete configuration entry
236 *---------------------------------------------------------------------------*/
237 typedef struct cfg_entry {
239 /* ====== filled in at startup configuration, then static ===========*/
241 char name[32]; /* id for this entry */
243 int isdncontroller; /* controller to use 0 ... n */
244 int isdnchannel; /* channel to use */
246 int isdntxdelin; /* tx delay, incoming connections */
247 int isdntxdelout; /* tx delay, outgoing connections */
249 int usrdevicename; /* userland device to use */
250 int usrdeviceunit; /* userland unit to use */
252 int remote_numbers_count; /* number of remote numbers */
253 #define MAXRNUMBERS 8 /* max remote numbers */
255 remote_number_t remote_numbers[MAXRNUMBERS]; /* remote numbers to dial */
257 int remote_numbers_handling; /* how to handle the remote dialing */
258 #define RNH_NEXT 0 /* use next number after last successfull */
259 #define RNH_LAST 1 /* use last successfull for next call */
260 #define RNH_FIRST 2 /* always use first number for next call */
262 char local_phone_dialout[TELNO_MAX]; /* our number to tell remote*/
263 char local_phone_incoming[TELNO_MAX]; /* answer calls for this local number */
265 #define MAX_INCOMING 8
266 int incoming_numbers_count; /* number of incoming allowed numbers */
267 incoming_number_t remote_phone_incoming[MAX_INCOMING]; /* answer calls from this remote machine */
269 int dialin_reaction; /* what to do with incoming calls */
270 #define REACT_ACCEPT 0
271 #define REACT_REJECT 1
272 #define REACT_IGNORE 2
273 #define REACT_ANSWER 3
274 #define REACT_CALLBACK 4
276 int b1protocol; /* hdlc / raw */
278 int idle_time_in; /* max idle time incoming calls */
279 int idle_time_out; /* max idle time outgoing calls */
281 int shorthold_algorithm; /* shorthold algorithm */
283 int unitlength; /* length of a charging unit */
284 #define UNITLENGTH_DEFAULT 60 /* last resort unit length */
286 int earlyhangup; /* time in seconds to hangup */
287 /* before the next expected */
289 #define EARLYHANGUP_DEFAULT 5
291 int ratetype; /* type of rate */
292 #define NO_RATE (NRATES+1)
293 #define INVALID_RATE (-1)
295 int unitlengthsrc; /* where we get the unit length from */
296 #define ULSRC_NONE 0 /* nowhere specified */
297 #define ULSRC_CMDL 1 /* specified on commandline */
298 #define ULSRC_CMDLMIN 5 /* minimum value from cmdl */
299 #define ULSRC_CMDLMAX 3600 /* minimum value from cmdl */
300 #define ULSRC_CONF 2 /* get it from config file */
301 #define ULSRC_RATE 3 /* get it dynamic from ratesfile*/
302 #define ULSRC_DYN 4 /* dynamic calculated from AOCD */
304 char *answerprog; /* program to use for answering */
305 char *connectprog; /* program run after negotiation finished */
306 char *disconnectprog; /* program run after shutdown is complete */
308 int callbackwait; /* time to wait before calling back */
309 #define CALLBACKWAIT_MIN 1
311 int calledbackwait; /* time to wait for remote callback */
312 #define CALLEDBACKWAIT_MIN 2
314 int dialretries; /* no. of dial tries */
315 #define DIALRETRIES_DEF 1
317 int recoverytime; /* time between 2 dial tries */
318 #define RECOVERYTIME_MIN 1
320 int dialrandincr; /* use random dial time incr */
322 int usedown; /* set interface down yes/no */
323 int downtries; /* retries before i/f is set down */
324 #define DOWN_TRIES_MIN 2
325 #define DOWN_TRIES_MAX 20
326 int downtime; /* time i/f is down */
327 #define DOWN_TIME_MIN 10 /* 10 seconds */
328 #define DOWN_TIME_MAX 3600 /* 1 hour */
330 int dialouttype; /* type of outgoing connection */
331 #define DIALOUT_NORMAL 0 /* normal dialout behaviour */
332 #define DIALOUT_CALLEDBACK 1 /* remote is expected to callback */
334 int alert; /* alert time in sec if nonzero */
335 #define MINALERT 5 /* 5 secs min */
336 #define MAXALERT (3*60) /* 3 minutes max */
338 int inout; /* in/out, in-only or out-only */
341 #define DIR_OUTONLY 2
343 int budget_callbackperiod; /* length of a budget period (s)*/
344 int budget_callbackncalls; /* call budget for a period */
345 char *budget_callbacks_file; /* filename to store callback stats */
346 char budget_callbacksfile_rotate;
348 int budget_calloutperiod; /* length of a budget period (s)*/
349 int budget_calloutncalls; /* call budget for a period */
350 char *budget_callouts_file; /* filename to store callout stats */
351 char budget_calloutsfile_rotate;
361 #define AUTH_RECHALLENGE 0x01
362 #define AUTH_REQUIRED 0x02
364 char ppp_expect_name[AUTHNAMELEN]; /* PPP PAP/CHAP login name */
365 char ppp_send_name[AUTHNAMELEN];
367 char ppp_expect_password[AUTHKEYLEN];
368 char ppp_send_password[AUTHKEYLEN];
370 int day; /* days valid */
378 #define HD 0x80 /* holiday */
379 int fromhr; /* time valid */
384 time_t maxconnecttime; /* maximum connection time */
386 /*===========================================================================*/
387 /*============ filled in after start, then dynamic ==========================*/
388 /*===========================================================================*/
390 int cdid; /* cdid for call */
391 #define CDID_RESERVED (-1)
393 int isdncontrollerused; /* the one we are using */
394 int isdnchannelused; /* the one we are using */
396 int fs_position; /* fullscreen position */
398 int state; /* state of connection */
399 #define ST_IDLE 0 /* connection is idle / disconnected */
401 /* normal dial out to remote */
402 #define ST_DIAL 1 /* dialing */
403 #define ST_DIALRTMRCHD 2 /* wait for dial retry time reached */
404 #define ST_DIALRETRY 3 /* last/first dialing failed, retry */
406 /* PCB: passive callback, i'm being called back */
407 #define ST_PCB_DIAL 4 /* dialing, trigger a callback */
408 #define ST_PCB_DIALFAIL 5 /* dialing failed triggering a callbk */
409 #define ST_PCB_WAITCALL 6 /* waiting for callback from remote */
411 /* ACB: active callback, i'm calling back */
412 #define ST_ACB_WAITDISC 7 /* got call, wait for disconnect */
413 #define ST_ACB_WAITDIAL 8 /* wait until allowed to callback */
414 #define ST_ACB_DIAL 9 /* callback to remote */
415 #define ST_ACB_DIALFAIL 10 /* callback to remote failed */
417 /* normal non-dialling states */
418 #define ST_ACCEPTED 11 /* remote accepted */
419 #define ST_CONNECTED 12 /* connected with remote */
420 #define ST_WAITDISCI 13 /* tx disc req, wait for disc ind */
421 #define ST_DOWN 14 /* interface is down */
422 #define ST_ALERT 15 /* interface is waiting for alert time*/
424 /* illegal and pseudo states */
425 #define ST_ILL 16 /* illegal state */
426 #define ST_SUSE 17 /* subroutine sets new state */
428 #define N_STATES (ST_ILL+1) /* max number of states */
430 cause_t disc_cause; /* cause from disconnect */
432 int local_disconnect; /* flag, who disconnected */
436 int timerval; /* value for timer, 0 if inactive */
437 int timerremain; /* remaining time */
439 int hangup; /* flag, hangup connection asap */
441 char real_phone_incoming[TELNO_MAX]; /* real remote telno in case of wildcard */
443 int last_remote_number; /* index of last used dialout number*/
445 char remote_phone_dialout[TELNO_MAX]; /* used remote number to dial */
447 int direction; /* incoming or outgoing */
451 int charge; /* charge in units */
452 int last_charge; /* last charge in units */
454 int inbytes; /* # of bytes from remote */
455 int iinbytes; /* # of bytes from remote on the line */
456 int inbps; /* bytes/sec from remote */
457 int outbytes; /* # of bytes to remote */
458 int ioutbytes; /* # of bytes to remote on the line */
459 int outbps; /* bytes/sec to remote */
461 time_t connect_time; /* time connection was established */
463 time_t aoc_last; /* last AOCD timestamp */
464 time_t aoc_now; /* current AOCD timestamp */
465 time_t aoc_diff; /* current unit length */
466 time_t aoc_lastdiff; /* last charge unit length */
467 int aoc_valid; /* flag: time diff is valid */
468 #define AOC_INVALID 0 /* aoc_diff is NOT valid */
469 #define AOC_VALID 1 /* aoc_diff is valid */
471 time_t last_dial_time; /* time of last dialing */
472 time_t last_release_time; /* time of last hangup */
474 int dial_count; /* number of dialout tries */
475 int randomtime; /* random() part of recoverytime*/
476 #define RANDOM_MASK 0x04 /* bits used from randomtime */
478 int down_retry_count; /* retry cycle count for usedown*/
479 time_t went_down_time; /* time i/f went down */
480 phantom_t saved_call; /* outgoing call state if called
483 int alert_time; /* count down of alert time */
484 char display[DISPLAY_MAX];
486 time_t budget_callbackperiod_time; /* end of current period */
487 int budget_callbackncalls_cnt; /* amount of calls left */
489 int budget_callback_req; /* requests */
490 int budget_callback_done; /* call done */
491 int budget_callback_rej; /* call refused */
493 time_t budget_calloutperiod_time; /* end of current period */
494 int budget_calloutncalls_cnt; /* amount of calls left */
496 int budget_callout_req; /* requests */
497 int budget_callout_done; /* call done */
498 int budget_callout_rej; /* call refused */
500 int budget_calltype; /* type of call */
501 #define BUDGET_TYPE_CBACK 1
502 #define BUDGET_TYPE_COUT 2
504 char keypad[KEYPAD_MAX]; /* keypad string */
507 /*---------------------------------------------------------------------------*
508 * this struct describes state of controller with MAX_BCHAN b channels
509 *---------------------------------------------------------------------------*/
510 typedef struct isdn_ctrl_state {
511 int ctrl_type; /* type: active/passive */
512 int card_type; /* manufacturer (CARD_XXXX) */
513 int protocol; /* ISDN D-channel protocol */
514 char* firmware; /* loadable fimrware file name */
516 int state; /* controller state */
517 #define CTRL_DOWN 0 /* controller inoparable */
518 #define CTRL_UP 1 /* controller may be used */
520 int stateb[MAX_BCHAN]; /* b channel state */
521 #define CHAN_IDLE 0 /* channel is free for usage */
522 #define CHAN_RUN 1 /* channel is occupied */
523 int nbch; /* number of b channels */
524 int freechans; /* number of unused channels */
525 int tei; /* tei or -1 if invalid */
526 int l1stat; /* layer 1 state */
527 int l2stat; /* layer 2 state */
530 /*---------------------------------------------------------------------------*
531 * this struct describes a logging regular expression
532 *---------------------------------------------------------------------------*/
534 int re_flg; /* valid entry flag */
535 char *re_expr; /* plain text expression */
536 regex_t re; /* compiled expression */
537 char *re_prog; /* the program to be executed */
540 #ifdef I4B_EXTERNAL_MONITOR
541 /* for each rights entry we keep one of this structures around: */
542 struct monitor_rights {
543 TAILQ_ENTRY(monitor_rights) list; /* a list of this structures */
544 char name[FILENAME_MAX]; /* net/host spec or filename */
545 int rights; /* bitmask of allowed acces rights */
546 u_int32_t net; /* net/host address (host byte order!) */
547 u_int32_t mask; /* bitmask 1 = network, 0 = host (host byte order!) */
548 int local; /* zero if remote access via tcp/ip */
552 /*---------------------------------------------------------------------------*
553 * global variables, storage allocation
554 *---------------------------------------------------------------------------*/
557 int isdnfd; /* file handle, /dev/i4b */
559 char mailto[MAXPATHLEN] = ""; /* panic mail address */
560 char mailer[MAXPATHLEN] = ""; /* panic mail address */
562 char *configfile = CONFIG_FILE_DEF; /* configuration filename */
563 int config_error_flag = 0; /* error counter */
566 int do_debug = 0; /* debug mode flag */
567 int debug_flags = 0; /* debug options */
568 int debug_noscreen = 0; /* not on fullscreen */
571 int do_bell = 0; /* bell on connect/disconnect */
573 int do_fork = 1; /* run as daemon/foreground */
575 int do_ttytype = 0; /* got new terminal type */
576 char *ttype = ""; /* termcap entry name string */
578 int do_rdev = 0; /* redirect output */
579 char *rdev = ""; /* new device string */
581 int do_print = 0; /* config file printout */
583 int got_unitlen = 0; /* flag, got length of a unit */
584 time_t unit_length; /* length of a unit */
586 cfg_entry_t cfg_entry_tab[CFG_ENTRY_MAX]; /* configuration table */
587 isdn_ctrl_state_t isdn_ctrl_tab[ISDN_CTRL_MAX]; /* controller states table */
589 int ncontroller = 0; /* # of controllers available */
590 int nentries = 0; /* # of entries in config tab */
592 int uselogfile = 0; /* flag, use a logfile */
593 char logfile[MAXPATHLEN] = LOG_FILE_DEF; /* log filename */
594 FILE *logfp = NULL; /* log file pointer */
595 int logfacility = LOG_LOCAL0; /* the syslog facility used */
596 int nregex = 0; /* number of reg expr */
597 struct rarr rarr[MAX_RE]; /* regexpr & progs table */
599 char ratesfile[MAXPATHLEN] = RATES_FILE_DEF; /* rates filename */
600 char *rate_error = NULL; /* errorcase: error string */
601 int got_rate = 0; /* flag, ratesfile found */
602 struct rates *rates[NRATES][NDAYS]; /* the rates structure */
604 int useacctfile = 0; /* flag, write accounting */
605 char acctfile[MAXPATHLEN] = ACCT_FILE_DEF; /* accounting filename */
606 FILE *acctfp = NULL; /* accounting file pointer */
607 int acct_all = 1; /* account all connections */
609 int aliasing = 0; /* enable alias processing */
610 char aliasfile[MAXPATHLEN] = ALIASFILE; /* alias file location */
612 int do_fullscreen = 0; /* fullscreen log */
613 int curses_ready = 0; /* curses initialized */
616 WINDOW *upper_w; /* curses upper window pointer */
617 WINDOW *mid_w; /* curses mid window pointer */
618 WINDOW *lower_w; /* curses lower window pointer */
621 int rt_prio = RTPRIO_NOTUSED; /* realtime priority */
623 /* monitor via network */
626 int inhibit_monitor = 0;
627 #ifdef I4B_EXTERNAL_MONITOR
628 int monitorport = DEF_MONPORT;
630 int monitorport = -1;
634 int isdntime = 0; /* flag, log time from exchange */
635 int extcallattr = 0; /* flag, display extended caller attributes */
637 char tinainitprog[MAXPATHLEN] = TINA_FILE_DEF;
639 char rotatesuffix[MAXPATHLEN] = "";
641 time_t starttime = 0;
643 char holidayfile[MAXPATHLEN] = HOLIDAY_FILE_DEF; /* holiday filename */
649 char mailto[MAXPATHLEN];
650 char mailer[MAXPATHLEN];
653 int config_error_flag;
676 cfg_entry_t cfg_entry_tab[CFG_ENTRY_MAX]; /* configuration table */
677 isdn_ctrl_state_t isdn_ctrl_tab[ISDN_CTRL_MAX]; /* controller states table */
683 char logfile[MAXPATHLEN];
687 struct rarr rarr[MAX_RE];
689 char ratesfile[MAXPATHLEN];
692 struct rates *rates[NRATES][NDAYS];
695 char acctfile[MAXPATHLEN];
700 char aliasfile[MAXPATHLEN];
721 char tinainitprog[MAXPATHLEN];
723 char rotatesuffix[MAXPATHLEN];
727 char holidayfile[MAXPATHLEN];
731 char * bdrivername ( int drivertype );
732 void cfg_setval ( int keyword );
733 void check_and_kill ( cfg_entry_t *cep );
734 void check_pid ( void );
735 void close_allactive ( void );
736 void configure ( char *filename, int reread );
737 void daemonize ( void );
738 void dialresponse(cfg_entry_t *cep, int dstat);
739 void display_acct ( cfg_entry_t *cep );
740 void display_bell ( void );
741 void display_ccharge ( cfg_entry_t *cep, int units );
742 void display_chans ( void );
743 void display_charge ( cfg_entry_t *cep );
744 void display_connect ( cfg_entry_t *cep );
745 void display_disconnect ( cfg_entry_t *cep );
746 void display_l12stat(int controller, int layer, int state);
747 void display_tei(int controller, int tei);
748 void display_updown ( cfg_entry_t *cep, int updown );
749 void do_exit ( int exitval );
750 void do_menu ( void );
751 int exec_answer ( cfg_entry_t *cep );
752 int exec_connect_prog ( cfg_entry_t *cep, const char *prog, int link_down );
753 pid_t exec_prog ( char *prog, char **arglist );
754 cfg_entry_t * find_by_device_for_dialout ( int drivertype, int driverunit );
755 cfg_entry_t *find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, char *cmd);
756 cfg_entry_t *find_by_device_for_keypad(int drivertype, int driverunit, int cmdlen, char *cmd);
757 cfg_entry_t * find_matching_entry_incoming ( msg_connect_ind_t *mp );
758 cfg_entry_t * find_active_entry_by_driver ( int drivertype, int driverunit );
759 void finish_log ( void );
760 char * getlogdatetime ( void );
761 int get_cdid ( void );
762 cfg_entry_t * get_cep_by_cc ( int ctrlr, int chan );
763 cfg_entry_t * get_cep_by_driver ( int drivertype, int driverunit );
764 cfg_entry_t * get_cep_by_cdid ( int cdid );
765 int get_current_rate ( cfg_entry_t *cep, int logit );
766 void handle_charge ( cfg_entry_t *cep );
767 void handle_recovery ( void );
768 void handle_scrprs(int cdid, int scr, int prs, char *caller);
769 void if_up(cfg_entry_t *cep);
770 void if_down(cfg_entry_t *cep);
771 void init_controller ( void );
772 void init_controller_protocol ( void );
773 void init_log ( void );
774 void init_screen ( void );
775 void log ( int what, const char *fmt, ... );
776 int main ( int argc, char **argv );
777 void msg_accounting ( msg_accounting_ind_t *mp );
778 void msg_alert_ind ( msg_alert_ind_t *mp );
779 void msg_charging_ind ( msg_charging_ind_t *mp );
780 void msg_connect_active_ind ( msg_connect_active_ind_t *mp );
781 void msg_connect_ind ( msg_connect_ind_t *mp );
782 void msg_pdeact_ind(msg_pdeact_ind_t *md);
783 void msg_negcomplete_ind(msg_negcomplete_ind_t *ind);
784 void msg_ifstatechg_ind(msg_ifstatechg_ind_t *ind);
785 void msg_drvrdisc_req(msg_drvrdisc_req_t *mp);
786 void msg_dialout ( msg_dialout_ind_t *mp );
787 void msg_dialoutnumber(msg_dialoutnumber_ind_t *mp);
788 void msg_disconnect_ind ( msg_disconnect_ind_t *mp );
789 void msg_idle_timeout_ind ( msg_idle_timeout_ind_t *mp );
790 void msg_l12stat_ind(msg_l12stat_ind_t *ml);
791 void msg_teiasg_ind(msg_teiasg_ind_t *mt);
792 void msg_proceeding_ind ( msg_proceeding_ind_t *mp );
793 void msg_packet_ind( msg_packet_ind_t *mp );
794 const char * name_of_controller(int ctrl_type, int card_type);
795 void next_state ( cfg_entry_t *cep, int event );
796 char * print_i4b_cause( cause_t code );
797 char * printstate ( cfg_entry_t *cep );
798 int readrates ( char *filename );
799 int ret_channel_state(int controller, int channel);
800 void reopenfiles ( int dummy );
801 void rereadconfig ( int dummy );
802 void select_first_dialno ( cfg_entry_t *cep );
803 void select_next_dialno ( cfg_entry_t *cep );
804 void select_this_dialno ( cfg_entry_t *cep );
805 int sendm_alert_req ( cfg_entry_t *cep );
806 int sendm_connect_req ( cfg_entry_t *cep );
807 int sendm_connect_resp ( cfg_entry_t *cep, int cdid, int response, cause_t cause );
808 int sendm_disconnect_req ( cfg_entry_t *cep, cause_t cause );
809 int set_channel_busy(int controller, int channel);
810 int set_channel_idle(int controller, int channel);
811 int setup_dialout(cfg_entry_t *cep);
812 void sigchild_handler ( int sig );
813 void start_timer ( cfg_entry_t *cep, int seconds );
814 void stop_timer ( cfg_entry_t *cep );
815 void unitlen_chkupd( cfg_entry_t *cep );
816 void write_pid ( void );
817 void yyerror ( const char *msg );
819 void error_exit(int exitval, const char *fmt, ...);
821 /* montior server module */
824 void monitor_clear_rights();
825 void monitor_fixup_rights();
826 int monitor_start_rights(const char *clientspec);
827 void monitor_add_rights(int rights);
829 /* possible return codes from monitor_start_rights: */
830 #define I4BMAR_OK 0 /* rights added successfully */
831 #define I4BMAR_LENGTH 1 /* local socket name to long */
832 #define I4BMAR_DUP 2 /* entry already exists */
833 #define I4BMAR_CIDR 3 /* cidr netmask is invalid */
834 #define I4BMAR_NOIP 4 /* host/net could not be resolved */
836 int monitor_create_local_socket();
838 #ifndef I4B_NOTCPIP_MONITOR
839 int monitor_create_remote_socket(int portno);
842 void monitor_prepselect(fd_set *selset, int *max_fd);
843 void monitor_handle_input(fd_set *selset);
844 void monitor_handle_connect(int sockfd, int is_local);
845 void monitor_evnt_charge(cfg_entry_t *cep, int units, int estimated);
846 void monitor_evnt_connect(cfg_entry_t *cep);
847 void monitor_evnt_disconnect(cfg_entry_t *cep);
848 void monitor_evnt_updown(cfg_entry_t *cep, int up);
849 void monitor_evnt_log(int prio, const char * what, const char * msg);
851 void monitor_evnt_l12stat(int controller, int layer, int state);
852 void monitor_evnt_tei(int controller, int tei);
853 void monitor_evnt_acct(cfg_entry_t *cep);
857 void init_active_controller(void);
858 int set_controller_state(int controller, int state);
859 int get_controller_state(int controller);
860 int decr_free_channels(int controller);
861 int incr_free_channels(int controller);
862 int get_free_channels(int controller);
863 int set_channel_busy(int controller, int channel);
864 int set_channel_idle(int controller, int channel);
865 int ret_channel_state(int controller, int channel);
869 void init_alias(char *filename);
870 void free_aliases(void);
871 char *get_alias(char *number);
873 void upd_callstat_file(char *filename, int rotateflag);
877 void init_holidays(char *filename);
878 void free_holidays(void);
879 int isholiday(int d, int m, int y);
881 #endif /* _ISDND_H_ */