2 * Copyright (c) 1997, 1999 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 * $Id: isdnd.h,v 1.63 1999/05/20 13:30:36 hm Exp $
32 * last edit-date: [Thu May 20 14:44:18 1999]
34 *---------------------------------------------------------------------------*/
55 #include <sys/param.h>
58 #include <sys/types.h>
59 #include <sys/ioctl.h>
62 #include <sys/rtprio.h>
65 #include <machine/i4b_ioctl.h>
66 #include <machine/i4b_cause.h>
68 #include "config.h" /* compile time configuration */
69 #include "pathnames.h" /* location of files */
70 #include "alias.h" /* alias file processing */
72 /*---------------------------------------------------------------------------*
73 * some general definitions
74 *---------------------------------------------------------------------------*/
75 #define GOOD 0 /* general "good" or "ok" return*/
76 #define ERROR (-1) /* general error return */
77 #define WARNING (-2) /* warning return */
78 #define INVALID (-1) /* an invalid integer */
80 /*---------------------------------------------------------------------------*
82 *---------------------------------------------------------------------------*/
83 #define RTPRIO_NOTUSED (-1) /* rtprio is not used for isdnd */
85 /*---------------------------------------------------------------------------*
87 *---------------------------------------------------------------------------*/
88 #define DL_MSG 0x0001 /* general debug messages */
89 #define DL_RATES 0x0002 /* messages related to rates */
90 #define DL_TIME 0x0004 /* messages related to timing */
91 #define DL_STATE 0x0008 /* messages related to states changes */
92 #define DL_RCVRY 0x0010 /* messages related to dial recovery */
93 #define DL_DIAL 0x0020 /* messages related to dial recovery */
94 #define DL_PROC 0x0040 /* messages related to process handling */
95 #define DL_DRVR 0x0080 /* messages related to kernel i4b msg i/o*/
96 #define DL_CNST 0x0100 /* messages related to controller state */
97 #define DL_RCCF 0x0200 /* messages related to isdnd.rc at boot */
100 #define DBGL(cond, dolog) if(cond & debug_flags) dolog
102 #define DBGL(cond, dolog)
105 /*---------------------------------------------------------------------------*
106 * curses fullscreen display definitions
107 *---------------------------------------------------------------------------*/
109 /* window dimensions */
110 #define UPPER_B 2 /* upper window start */
112 /* horizontal positions for upper window */
113 #define H_CNTL 0 /* controller */
114 #define H_TEI 2 /* TEI */
115 #define H_CHAN (H_TEI+4) /* channel */
116 #define H_TELN (H_CHAN+2) /* telephone number */
117 #define H_IFN (H_TELN+23) /* interfacename */
118 #define H_IO (H_IFN+7) /* incoming or outgoing */
119 #define H_OUT (H_IO+4) /* # of bytes out */
120 #define H_OUTBPS (H_OUT+11) /* bytes per second out */
121 #define H_IN (H_OUTBPS+5) /* # of bytes in */
122 #define H_INBPS (H_IN+11) /* bytes per second in */
123 #define H_UNITS (H_INBPS+6) /* # of charging units */
125 /* fullscreen mode menu window */
126 #define WMENU_LEN 35 /* width of menu window */
127 #define WMENU_TITLE "Command" /* title string */
128 #define WMENU_POSLN 10 /* menu position, line */
129 #define WMENU_POSCO 5 /* menu position, col */
130 #define WMITEMS 4 /* no of menu items */
131 #define WMENU_HGT (WMITEMS + 4) /* menu window height */
138 #define WMTIMEOUT 5 /* timeout in seconds */
140 /*---------------------------------------------------------------------------*
142 *---------------------------------------------------------------------------*/
143 #define NDAYS 7 /* number of days in a week */
144 #define NRATES 4 /* number of rate structures supported */
146 /* struct for rates - each day has one or more */
149 int start_time; /* hour and min at which this rate starts, e.g. 12:20 12*60+20*/
150 int end_time; /* hour and min at which this rate ends, e.g. 19:10 19*60+10*/
151 int rate; /* how long can I telephone at this price, seconds */
155 /*---------------------------------------------------------------------------*
156 * the internal identifiers for isdnd log levels. CAUTION: this has to stay
157 * in sync with the loglevel to text and sysloglevel table in log.c !!
158 *---------------------------------------------------------------------------*/
161 LL_ERR, /* error conditions - everything which caused an error */
162 LL_WRN, /* warning conditions - nonfatal abnormal conditions */
163 LL_DMN, /* normal but significant condition - status of daemon */
164 LL_CHD, /* informational - everything regarding call handling */
165 LL_DBG /* debug messages - everything which helps debugging */
168 /*---------------------------------------------------------------------------*
169 * state machine events
170 *---------------------------------------------------------------------------*/
173 /* incoming messages */
175 EV_MCI, /* MSG_CONNECT_IND */
176 EV_MCAI, /* MSG_CONNECT_ACTIVE_IND */
177 EV_MDI, /* MSG_DISCONNECT_IND */
178 EV_MDO, /* MSG_DIALOUT */
182 EV_TIMO, /* timer expired */
183 EV_DRQ, /* disconnect request */
184 EV_CBRQ, /* callback request */
185 EV_ALRT, /* alerting request */
189 EV_ILL /* illegal event */
192 #define N_EVENTS (EV_ILL+1) /* no of possible events */
194 /*---------------------------------------------------------------------------*
195 * this struct describes the numbers to try to dial out
196 *---------------------------------------------------------------------------*/
198 char number[TELNO_MAX]; /* remote number to dial */
199 int flag; /* usage flag */
201 #define RNF_SUCC 1 /* last dial was ok */
204 /*---------------------------------------------------------------------------*
205 * this struct describes numbers allowed to dial in
206 *---------------------------------------------------------------------------*/
208 char number[TELNO_MAX]; /* calling party number */
211 /*---------------------------------------------------------------------------*
212 * this structure describes a prematurely aborted called-back dialout
213 *---------------------------------------------------------------------------*/
215 int cdid; /* call handle */
216 int controller; /* the controller used to dial out */
217 int channel; /* the channel assigned to the outgoing call */
218 /* XXX - timeout handling and error recovery? */
221 /*---------------------------------------------------------------------------*
222 * this struct describes one complete configuration entry
223 *---------------------------------------------------------------------------*/
224 typedef struct cfg_entry {
226 /* ====== filled in at startup configuration, then static ===========*/
228 char name[32]; /* id for this entry */
230 int isdncontroller; /* controller to use 0 ... n */
231 int isdnchannel; /* channel to use */
233 int isdntxdelin; /* tx delay, incoming connections */
234 int isdntxdelout; /* tx delay, outgoing connections */
236 int usrdevicename; /* userland device to use */
237 int usrdeviceunit; /* userland unit to use */
239 int remote_numbers_count; /* number of remote numbers */
240 #define MAXRNUMBERS 8 /* max remote numbers */
242 remote_number_t remote_numbers[MAXRNUMBERS]; /* remote numbers to dial */
244 int remote_numbers_handling; /* how to handle the remote dialing */
245 #define RNH_NEXT 0 /* use next number after last successfull */
246 #define RNH_LAST 1 /* use last successfull for next call */
247 #define RNH_FIRST 2 /* always use first number for next call */
249 char local_phone_dialout[TELNO_MAX]; /* our number to tell remote*/
250 char local_phone_incoming[TELNO_MAX]; /* answer calls for this local number */
252 #define MAX_INCOMING 8
253 int incoming_numbers_count; /* number of incoming allowed numbers */
254 incoming_number_t remote_phone_incoming[MAX_INCOMING]; /* answer calls from this remote machine */
256 int dialin_reaction; /* what to do with incoming calls */
257 #define REACT_ACCEPT 0
258 #define REACT_REJECT 1
259 #define REACT_IGNORE 2
260 #define REACT_ANSWER 3
261 #define REACT_CALLBACK 4
263 int b1protocol; /* hdlc / raw */
265 int idle_time_in; /* max idle time incoming calls */
266 int idle_time_out; /* max idle time outgoing calls */
268 int shorthold_algorithm; /* shorthold algorithm */
270 int unitlength; /* length of a charging unit */
271 #define UNITLENGTH_DEFAULT 60 /* last resort unit length */
273 int earlyhangup; /* time in seconds to hangup */
274 /* before the next expected */
276 #define EARLYHANGUP_DEFAULT 5
278 int ratetype; /* type of rate */
279 #define NO_RATE (NRATES+1)
280 #define INVALID_RATE (-1)
282 int unitlengthsrc; /* where we get the unit length from */
283 #define ULSRC_NONE 0 /* nowhere specified */
284 #define ULSRC_CMDL 1 /* specified on commandline */
285 #define ULSRC_CMDLMIN 5 /* minimum value from cmdl */
286 #define ULSRC_CMDLMAX 3600 /* minimum value from cmdl */
287 #define ULSRC_CONF 2 /* get it from config file */
288 #define ULSRC_RATE 3 /* get it dynamic from ratesfile*/
289 #define ULSRC_DYN 4 /* dynamic calculated from AOCD */
291 char *answerprog; /* program to use for answering */
292 char *connectprog; /* program run after negotiation finished */
293 char *disconnectprog; /* program run after shutdown is complete */
295 int callbackwait; /* time to wait before calling back */
296 #define CALLBACKWAIT_MIN 1
298 int calledbackwait; /* time to wait for remote callback */
299 #define CALLEDBACKWAIT_MIN 2
301 int dialretries; /* no. of dial tries */
302 #define DIALRETRIES_DEF 1
304 int recoverytime; /* time between 2 dial tries */
305 #define RECOVERYTIME_MIN 1
307 int dialrandincr; /* use random dial time incr */
309 int usedown; /* set interface down yes/no */
310 int downtries; /* retries before i/f is set down */
311 #define DOWN_TRIES_MIN 2
312 #define DOWN_TRIES_MAX 20
313 int downtime; /* time i/f is down */
314 #define DOWN_TIME_MIN 10 /* 10 seconds */
315 #define DOWN_TIME_MAX 3600 /* 1 hour */
317 int dialouttype; /* type of outgoing connection */
318 #define DIALOUT_NORMAL 0 /* normal dialout behaviour */
319 #define DIALOUT_CALLEDBACK 1 /* remote is expected to callback */
321 int alert; /* alert time in sec if nonzero */
322 #define MINALERT 5 /* 5 secs min */
323 #define MAXALERT (3*60) /* 3 minutes max */
325 int inout; /* in/out, in-only or out-only */
328 #define DIR_OUTONLY 2
330 /*===========================================================================*/
331 /*============ filled in after start, then dynamic ==========================*/
332 /*===========================================================================*/
334 int cdid; /* cdid for call */
335 #define CDID_RESERVED (-1)
337 int isdncontrollerused; /* the one we are using */
338 int isdnchannelused; /* the one we are using */
340 int fs_position; /* fullscreen position */
342 int state; /* state of connection */
343 #define ST_IDLE 0 /* connection is idle / disconnected */
345 /* normal dial out to remote */
346 #define ST_DIAL 1 /* dialing */
347 #define ST_DIALRTMRCHD 2 /* wait for dial retry time reached */
348 #define ST_DIALRETRY 3 /* last/first dialing failed, retry */
350 /* PCB: passive callback, i'm being called back */
351 #define ST_PCB_DIAL 4 /* dialing, trigger a callback */
352 #define ST_PCB_DIALFAIL 5 /* dialing failed triggering a callbk */
353 #define ST_PCB_WAITCALL 6 /* waiting for callback from remote */
355 /* ACB: active callback, i'm calling back */
356 #define ST_ACB_WAITDISC 7 /* got call, wait for disconnect */
357 #define ST_ACB_WAITDIAL 8 /* wait until allowed to callback */
358 #define ST_ACB_DIAL 9 /* callback to remote */
359 #define ST_ACB_DIALFAIL 10 /* callback to remote failed */
361 /* normal non-dialling states */
362 #define ST_ACCEPTED 11 /* remote accepted */
363 #define ST_CONNECTED 12 /* connected with remote */
364 #define ST_WAITDISCI 13 /* tx disc req, wait for disc ind */
365 #define ST_DOWN 14 /* interface is down */
366 #define ST_ALERT 15 /* interface is waiting for alert time*/
368 /* illegal and pseudo states */
369 #define ST_ILL 16 /* illegal state */
370 #define ST_SUSE 17 /* subroutine sets new state */
372 #define N_STATES (ST_ILL+1) /* max number of states */
374 int disc_cause; /* cause from disconnect */
376 int local_disconnect; /* flag, who disconnected */
380 int timerval; /* value for timer, 0 if inactive */
381 int timerremain; /* remaining time */
383 int hangup; /* flag, hangup connection asap */
385 char real_phone_incoming[TELNO_MAX]; /* real remote telno in case of wildcard */
387 int last_remote_number; /* index of last used dialout number*/
389 char remote_phone_dialout[TELNO_MAX]; /* used remote number to dial */
391 int direction; /* incoming or outgoing */
395 int charge; /* charge in units */
396 int last_charge; /* last charge in units */
398 int inbytes; /* # of bytes from remote */
399 int iinbytes; /* # of bytes from remote on the line */
400 int inbps; /* bytes/sec from remote */
401 int outbytes; /* # of bytes to remote */
402 int ioutbytes; /* # of bytes to remote on the line */
403 int outbps; /* bytes/sec to remote */
405 time_t connect_time; /* time connection was established */
407 time_t aoc_last; /* last AOCD timestamp */
408 time_t aoc_now; /* current AOCD timestamp */
409 time_t aoc_diff; /* current unit length */
410 time_t aoc_lastdiff; /* last charge unit length */
411 int aoc_valid; /* flag: time diff is valid */
412 #define AOC_INVALID 0 /* aoc_diff is NOT valid */
413 #define AOC_VALID 1 /* aoc_diff is valid */
415 time_t last_dial_time; /* time of last dialing */
416 time_t last_release_time; /* time of last hangup */
418 int dial_count; /* number of dialout tries */
419 int randomtime; /* random() part of recoverytime*/
420 #define RANDOM_MASK 0x04 /* bits used from randomtime */
422 int down_retry_count; /* retry cycle count for usedown*/
423 time_t went_down_time; /* time i/f went down */
424 phantom_t saved_call; /* outgoing call state if called
427 int alert_time; /* count down of alert time */
428 char display[DISPLAY_MAX];
431 /*---------------------------------------------------------------------------*
432 * this struct describes state of controller with 2 b channels
433 *---------------------------------------------------------------------------*/
434 typedef struct isdn_ctrl_state {
435 int ctrl_type; /* type: active/passive */
436 int card_type; /* manufacturer (CARD_XXXX) */
437 int state; /* controller state */
438 #define CTRL_DOWN 0 /* controller inoparable */
439 #define CTRL_UP 1 /* controller may be used */
440 int stateb1; /* B-channel 1 */
441 int stateb2; /* B-channel 2 */
442 #define CHAN_IDLE 0 /* channel is free for usage */
443 #define CHAN_RUN 1 /* channel is occupied */
444 int freechans; /* number of unused channels */
445 #define MAX_CHANCTRL 2 /* free channels per controller */
446 int tei; /* tei or -1 if invalid */
449 /*---------------------------------------------------------------------------*
450 * this struct describes a logging regular expression
451 *---------------------------------------------------------------------------*/
453 int re_flg; /* valid entry flag */
454 char *re_expr; /* plain text expression */
455 regex_t re; /* compiled expression */
456 char *re_prog; /* the program to be executed */
459 #ifdef I4B_EXTERNAL_MONITOR
460 /* for each rights entry we keep one of this structures around: */
461 struct monitor_rights {
462 char name[FILENAME_MAX]; /* net/host spec or filename */
463 int rights; /* bitmask of allowed acces rights */
464 u_int32_t net; /* net/host address (host byte order!) */
465 u_int32_t mask; /* bitmask 1 = network, 0 = host (host byte order!) */
466 int local; /* zero if remote access via tcp/ip */
470 /*---------------------------------------------------------------------------*
471 * global variables, storage allocation
472 *---------------------------------------------------------------------------*/
475 int isdnfd; /* file handle, /dev/i4b */
477 char *configfile = CONFIG_FILE_DEF; /* configuration filename */
478 int config_error_flag = 0; /* error counter */
481 int do_debug = 0; /* debug mode flag */
482 int debug_flags = 0; /* debug options */
483 int debug_noscreen = 0; /* not on fullscreen */
486 int do_bell = 0; /* bell on connect/disconnect */
488 int do_fork = 1; /* run as daemon/foreground */
490 int do_ttytype = 0; /* got new terminal type */
491 char *ttype = ""; /* termcap entry name string */
493 int do_rdev = 0; /* redirect output */
494 char *rdev = ""; /* new device string */
496 int do_print = 0; /* config file printout */
498 int got_unitlen = 0; /* flag, got length of a unit */
499 time_t unit_length; /* length of a unit */
501 cfg_entry_t cfg_entry_tab[CFG_ENTRY_MAX]; /* configuration table */
502 isdn_ctrl_state_t isdn_ctrl_tab[ISDN_CTRL_MAX]; /* controller states table */
504 int ncontroller = 0; /* # of controllers available */
505 int nentries = 0; /* # of entries in config tab */
507 int uselogfile = 0; /* flag, use a logfile */
508 char logfile[MAXPATHLEN] = LOG_FILE_DEF; /* log filename */
509 FILE *logfp = NULL; /* log file pointer */
510 int logfacility = LOG_LOCAL0; /* the syslog facility used */
511 int nregex = 0; /* number of reg expr */
512 struct rarr rarr[MAX_RE]; /* regexpr & progs table */
514 char ratesfile[MAXPATHLEN] = RATES_FILE_DEF; /* rates filename */
515 char *rate_error = NULL; /* errorcase: error string */
516 int got_rate = 0; /* flag, ratesfile found */
517 struct rates *rates[NRATES][NDAYS]; /* the rates structure */
519 int useacctfile = 0; /* flag, write accounting */
520 char acctfile[MAXPATHLEN] = ACCT_FILE_DEF; /* accounting filename */
521 FILE *acctfp = NULL; /* accounting file pointer */
522 int acct_all = 1; /* account all connections */
524 int aliasing = 0; /* enable alias processing */
525 char aliasfile[MAXPATHLEN] = ALIASFILE; /* alias file location */
527 int do_fullscreen = 0; /* fullscreen log */
528 int curses_ready = 0; /* curses initialized */
531 WINDOW *upper_w; /* curses upper window pointer */
532 WINDOW *mid_w; /* curses mid window pointer */
533 WINDOW *lower_w; /* curses lower window pointer */
536 int rt_prio = RTPRIO_NOTUSED; /* realtime priority */
538 /* monitor via network */
541 int inhibit_monitor = 0;
542 #ifdef I4B_EXTERNAL_MONITOR
543 int monitorport = DEF_MONPORT;
545 int monitorport = -1;
549 int isdntime = 0; /* flag, log time from exchange */
551 char tinainitprog[MAXPATHLEN] = TINA_FILE_DEF;
553 char rotatesuffix[MAXPATHLEN] = "";
560 int config_error_flag;
583 cfg_entry_t cfg_entry_tab[CFG_ENTRY_MAX]; /* configuration table */
584 isdn_ctrl_state_t isdn_ctrl_tab[ISDN_CTRL_MAX]; /* controller states table */
590 char logfile[MAXPATHLEN];
593 struct rarr rarr[MAX_RE];
595 char ratesfile[MAXPATHLEN];
598 struct rates *rates[NRATES][NDAYS];
601 char acctfile[MAXPATHLEN];
606 char aliasfile[MAXPATHLEN];
626 char tinainitprog[MAXPATHLEN];
628 char rotatesuffix[MAXPATHLEN];
632 char * bdrivername ( int drivertype );
633 void cfg_setval ( int keyword );
634 void check_and_kill ( cfg_entry_t *cep );
635 void check_pid ( void );
636 void close_allactive ( void );
637 void configure ( char *filename, int reread );
638 void daemonize ( void );
639 void dialresponse(cfg_entry_t *cep, int dstat);
640 void display_acct ( cfg_entry_t *cep );
641 void display_bell ( void );
642 void display_ccharge ( cfg_entry_t *cep, int units );
643 void display_chans ( void );
644 void display_charge ( cfg_entry_t *cep );
645 void display_connect ( cfg_entry_t *cep );
646 void display_disconnect ( cfg_entry_t *cep );
647 void display_l12stat(int controller, int layer, int state);
648 void display_tei(int controller, int tei);
649 void display_updown ( cfg_entry_t *cep, int updown );
650 void hangup_channel ( int channel );
651 void do_exit ( int exitval );
652 void do_menu ( void );
653 int exec_answer ( cfg_entry_t *cep );
654 int exec_connect_prog ( cfg_entry_t *cep, const char *prog, int link_down );
655 pid_t exec_prog ( char *prog, char **arglist );
656 cfg_entry_t * find_by_device_for_dialout ( int drivertype, int driverunit );
657 cfg_entry_t *find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, char *cmd);
658 cfg_entry_t * find_matching_entry_incoming ( msg_connect_ind_t *mp );
659 cfg_entry_t * find_active_entry_by_driver ( int drivertype, int driverunit );
660 void finish_log ( void );
661 char * getlogdatetime ( void );
662 int get_cdid ( void );
663 cfg_entry_t * get_cep_by_cc ( int ctrlr, int chan );
664 cfg_entry_t * get_cep_by_driver ( int drivertype, int driverunit );
665 cfg_entry_t * get_cep_by_cdid ( int cdid );
666 int get_current_rate ( cfg_entry_t *cep, int logit );
667 void handle_charge ( cfg_entry_t *cep );
668 void handle_recovery ( void );
669 void if_up(cfg_entry_t *cep);
670 void if_down(cfg_entry_t *cep);
671 void init_controller ( void );
672 void init_log ( void );
673 void init_screen ( void );
674 void log ( int what, const char *fmt, ... );
675 int main ( int argc, char **argv );
676 void msg_accounting ( msg_accounting_ind_t *mp );
677 void msg_alert_ind ( msg_alert_ind_t *mp );
678 void msg_charging_ind ( msg_charging_ind_t *mp );
679 void msg_connect_active_ind ( msg_connect_active_ind_t *mp );
680 void msg_connect_ind ( msg_connect_ind_t *mp );
681 void msg_pdeact_ind(msg_pdeact_ind_t *md);
682 void msg_negcomplete_ind(msg_negcomplete_ind_t *ind);
683 void msg_ifstatechg_ind(msg_ifstatechg_ind_t *ind);
684 void msg_drvrdisc_req(msg_drvrdisc_req_t *mp);
685 void msg_dialout ( msg_dialout_ind_t *mp );
686 void msg_dialoutnumber(msg_dialoutnumber_ind_t *mp);
687 void msg_disconnect_ind ( msg_disconnect_ind_t *mp );
688 void msg_idle_timeout_ind ( msg_idle_timeout_ind_t *mp );
689 void msg_l12stat_ind(msg_l12stat_ind_t *ml);
690 void msg_teiasg_ind(msg_teiasg_ind_t *mt);
691 void msg_proceeding_ind ( msg_proceeding_ind_t *mp );
692 const char * name_of_controller(int ctrl_type, int card_type);
693 void next_state ( cfg_entry_t *cep, int event );
694 char * print_i4b_cause( cause_t code );
695 char * printstate ( cfg_entry_t *cep );
696 int readrates ( char *filename );
697 int ret_channel_state(int controller, int channel);
698 void reopenfiles ( int dummy );
699 void rereadconfig ( int dummy );
700 void select_first_dialno ( cfg_entry_t *cep );
701 void select_next_dialno ( cfg_entry_t *cep );
702 void select_this_dialno ( cfg_entry_t *cep );
703 int sendm_alert_req ( cfg_entry_t *cep );
704 int sendm_connect_req ( cfg_entry_t *cep );
705 int sendm_connect_resp ( cfg_entry_t *cep, int cdid, int response, int cause );
706 int sendm_disconnect_req ( cfg_entry_t *cep, int cause );
707 int set_channel_busy(int controller, int channel);
708 int set_channel_idle(int controller, int channel);
709 int setup_dialout(cfg_entry_t *cep);
710 void sigchild_handler ( int sig );
711 void start_timer ( cfg_entry_t *cep, int seconds );
712 void stop_timer ( cfg_entry_t *cep );
713 void unitlen_chkupd( cfg_entry_t *cep );
714 void write_pid ( void );
715 void yyerror ( const char *msg );
717 /* montior server module */
720 void monitor_clear_rights();
721 void monitor_fixup_rights();
722 int monitor_start_rights(const char *clientspec);
723 void monitor_add_rights(int rights);
725 /* possible return codes from monitor_start_rights: */
726 #define I4BMAR_OK 0 /* rights added successfully */
727 #define I4BMAR_LENGTH 1 /* local socket name to long */
728 #define I4BMAR_DUP 2 /* entry already exists */
729 #define I4BMAR_CIDR 3 /* cidr netmask is invalid */
730 #define I4BMAR_NOIP 4 /* host/net could not be resolved */
732 int monitor_create_local_socket();
734 #ifndef I4B_NOTCPIP_MONITOR
735 int monitor_create_remote_socket(int portno);
738 void monitor_prepselect(fd_set *selset, int *max_fd);
739 void monitor_handle_input(fd_set *selset);
740 void monitor_handle_connect(int sockfd, int is_local);
741 void monitor_evnt_charge(cfg_entry_t *cep, int units, int estimated);
742 void monitor_evnt_connect(cfg_entry_t *cep);
743 void monitor_evnt_disconnect(cfg_entry_t *cep);
744 void monitor_evnt_updown(cfg_entry_t *cep, int up);
745 void monitor_evnt_log(int prio, const char * what, const char * msg);
749 int init_controller_state(int controller, int ctrl_type, int card_type, int tei);
750 void init_active_controller(void);
751 int set_controller_state(int controller, int state);
752 int get_controller_state(int controller);
753 int decr_free_channels(int controller);
754 int incr_free_channels(int controller);
755 int get_free_channels(int controller);
756 int set_channel_busy(int controller, int channel);
757 int set_channel_idle(int controller, int channel);
758 int ret_channel_state(int controller, int channel);
762 void init_alias(char *filename);
763 void free_aliases(void);
764 char *get_alias(char *number);
766 #endif /* _ISDND_H_ */