1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
/*
* Copyright (c) 1997, 1999 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.
*
*---------------------------------------------------------------------------
*
* i4b daemon - main header file
* -----------------------------
*
* $FreeBSD$
*
* last edit-date: [Thu May 20 14:44:18 1999]
*
*---------------------------------------------------------------------------*/
#ifndef _ISDND_H_
#define _ISDND_H_
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#include <ctype.h>
#include <syslog.h>
#include <regex.h>
#ifdef USE_CURSES
#include <curses.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#ifdef USE_RTPRIO
#include <sys/rtprio.h>
#endif
#include <machine/i4b_ioctl.h>
#include <machine/i4b_cause.h>
#include "config.h" /* compile time configuration */
#include "pathnames.h" /* location of files */
#include "alias.h" /* alias file processing */
/*---------------------------------------------------------------------------*
* some general definitions
*---------------------------------------------------------------------------*/
#define GOOD 0 /* general "good" or "ok" return*/
#define ERROR (-1) /* general error return */
#define WARNING (-2) /* warning return */
#define INVALID (-1) /* an invalid integer */
/*---------------------------------------------------------------------------*
* misc
*---------------------------------------------------------------------------*/
#define RTPRIO_NOTUSED (-1) /* rtprio is not used for isdnd */
/*---------------------------------------------------------------------------*
* debug flag bits
*---------------------------------------------------------------------------*/
#define DL_MSG 0x0001 /* general debug messages */
#define DL_RATES 0x0002 /* messages related to rates */
#define DL_TIME 0x0004 /* messages related to timing */
#define DL_STATE 0x0008 /* messages related to states changes */
#define DL_RCVRY 0x0010 /* messages related to dial recovery */
#define DL_DIAL 0x0020 /* messages related to dial recovery */
#define DL_PROC 0x0040 /* messages related to process handling */
#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 */
#ifdef DEBUG
#define DBGL(cond, dolog) if(cond & debug_flags) dolog
#else
#define DBGL(cond, dolog)
#endif
/*---------------------------------------------------------------------------*
* curses fullscreen display definitions
*---------------------------------------------------------------------------*/
/* window dimensions */
#define UPPER_B 2 /* upper window start */
/* horizontal positions for upper window */
#define H_CNTL 0 /* controller */
#define H_TEI 2 /* TEI */
#define H_CHAN (H_TEI+4) /* channel */
#define H_TELN (H_CHAN+2) /* telephone number */
#define H_IFN (H_TELN+23) /* interfacename */
#define H_IO (H_IFN+7) /* incoming or outgoing */
#define H_OUT (H_IO+4) /* # of bytes out */
#define H_OUTBPS (H_OUT+11) /* bytes per second out */
#define H_IN (H_OUTBPS+5) /* # of bytes in */
#define H_INBPS (H_IN+11) /* bytes per second in */
#define H_UNITS (H_INBPS+6) /* # of charging units */
/* fullscreen mode menu window */
#define WMENU_LEN 35 /* width of menu window */
#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 WMENU_HGT (WMITEMS + 4) /* menu window height */
#define WREFRESH 0
#define WHANGUP 1
#define WREREAD 2
#define WQUIT 3
#define WMTIMEOUT 5 /* timeout in seconds */
/*---------------------------------------------------------------------------*
* charging rates
*---------------------------------------------------------------------------*/
#define NDAYS 7 /* number of days in a week */
#define NRATES 4 /* number of rate structures supported */
/* struct for rates - each day has one or more */
struct rates
{
int start_time; /* hour and min at which this rate starts, e.g. 12:20 12*60+20*/
int end_time; /* hour and min at which this rate ends, e.g. 19:10 19*60+10*/
int rate; /* how long can I telephone at this price, seconds */
struct rates *next;
};
/*---------------------------------------------------------------------------*
* the internal identifiers for isdnd log levels. CAUTION: this has to stay
* in sync with the loglevel to text and sysloglevel table in log.c !!
*---------------------------------------------------------------------------*/
enum logids
{
LL_ERR, /* error conditions - everything which caused an error */
LL_WRN, /* warning conditions - nonfatal abnormal conditions */
LL_DMN, /* normal but significant condition - status of daemon */
LL_CHD, /* informational - everything regarding call handling */
LL_DBG /* debug messages - everything which helps debugging */
};
/*---------------------------------------------------------------------------*
* state machine events
*---------------------------------------------------------------------------*/
enum events
{
/* incoming messages */
EV_MCI, /* MSG_CONNECT_IND */
EV_MCAI, /* MSG_CONNECT_ACTIVE_IND */
EV_MDI, /* MSG_DISCONNECT_IND */
EV_MDO, /* MSG_DIALOUT */
/* local requests */
EV_TIMO, /* timer expired */
EV_DRQ, /* disconnect request */
EV_CBRQ, /* callback request */
EV_ALRT, /* alerting request */
/* illegal */
EV_ILL /* illegal event */
};
#define N_EVENTS (EV_ILL+1) /* no of possible events */
/*---------------------------------------------------------------------------*
* this struct describes the numbers to try to dial out
*---------------------------------------------------------------------------*/
typedef struct {
char number[TELNO_MAX]; /* remote number to dial */
int flag; /* usage flag */
#define RNF_IDLE 0
#define RNF_SUCC 1 /* last dial was ok */
} remote_number_t;
/*---------------------------------------------------------------------------*
* this struct describes numbers allowed to dial in
*---------------------------------------------------------------------------*/
typedef struct {
char number[TELNO_MAX]; /* calling party number */
} incoming_number_t;
/*---------------------------------------------------------------------------*
* this structure describes a prematurely aborted called-back dialout
*---------------------------------------------------------------------------*/
typedef struct {
int cdid; /* call handle */
int controller; /* the controller used to dial out */
int channel; /* the channel assigned to the outgoing call */
/* XXX - timeout handling and error recovery? */
} phantom_t;
/*---------------------------------------------------------------------------*
* this struct describes one complete configuration entry
*---------------------------------------------------------------------------*/
typedef struct cfg_entry {
/* ====== filled in at startup configuration, then static ===========*/
char name[32]; /* id for this entry */
int isdncontroller; /* controller to use 0 ... n */
int isdnchannel; /* channel to use */
int isdntxdelin; /* tx delay, incoming connections */
int isdntxdelout; /* tx delay, outgoing connections */
int usrdevicename; /* userland device to use */
int usrdeviceunit; /* userland unit to use */
int remote_numbers_count; /* number of remote numbers */
#define MAXRNUMBERS 8 /* max remote numbers */
remote_number_t remote_numbers[MAXRNUMBERS]; /* remote numbers to dial */
int remote_numbers_handling; /* how to handle the remote dialing */
#define RNH_NEXT 0 /* use next number after last successfull */
#define RNH_LAST 1 /* use last successfull for next call */
#define RNH_FIRST 2 /* always use first number for next call */
char local_phone_dialout[TELNO_MAX]; /* our number to tell remote*/
char local_phone_incoming[TELNO_MAX]; /* answer calls for this local number */
#define MAX_INCOMING 8
int incoming_numbers_count; /* number of incoming allowed numbers */
incoming_number_t remote_phone_incoming[MAX_INCOMING]; /* answer calls from this remote machine */
int dialin_reaction; /* what to do with incoming calls */
#define REACT_ACCEPT 0
#define REACT_REJECT 1
#define REACT_IGNORE 2
#define REACT_ANSWER 3
#define REACT_CALLBACK 4
int b1protocol; /* hdlc / raw */
int idle_time_in; /* max idle time incoming calls */
int idle_time_out; /* max idle time outgoing calls */
int shorthold_algorithm; /* shorthold algorithm */
int unitlength; /* length of a charging unit */
#define UNITLENGTH_DEFAULT 60 /* last resort unit length */
int earlyhangup; /* time in seconds to hangup */
/* before the next expected */
/* charging unit */
#define EARLYHANGUP_DEFAULT 5
int ratetype; /* type of rate */
#define NO_RATE (NRATES+1)
#define INVALID_RATE (-1)
int unitlengthsrc; /* where we get the unit length from */
#define ULSRC_NONE 0 /* nowhere specified */
#define ULSRC_CMDL 1 /* specified on commandline */
#define ULSRC_CMDLMIN 5 /* minimum value from cmdl */
#define ULSRC_CMDLMAX 3600 /* minimum value from cmdl */
#define ULSRC_CONF 2 /* get it from config file */
#define ULSRC_RATE 3 /* get it dynamic from ratesfile*/
#define ULSRC_DYN 4 /* dynamic calculated from AOCD */
char *answerprog; /* program to use for answering */
char *connectprog; /* program run after negotiation finished */
char *disconnectprog; /* program run after shutdown is complete */
int callbackwait; /* time to wait before calling back */
#define CALLBACKWAIT_MIN 1
int calledbackwait; /* time to wait for remote callback */
#define CALLEDBACKWAIT_MIN 2
int dialretries; /* no. of dial tries */
#define DIALRETRIES_DEF 1
int recoverytime; /* time between 2 dial tries */
#define RECOVERYTIME_MIN 1
int dialrandincr; /* use random dial time incr */
int usedown; /* set interface down yes/no */
int downtries; /* retries before i/f is set down */
#define DOWN_TRIES_MIN 2
#define DOWN_TRIES_MAX 20
int downtime; /* time i/f is down */
#define DOWN_TIME_MIN 10 /* 10 seconds */
#define DOWN_TIME_MAX 3600 /* 1 hour */
int dialouttype; /* type of outgoing connection */
#define DIALOUT_NORMAL 0 /* normal dialout behaviour */
#define DIALOUT_CALLEDBACK 1 /* remote is expected to callback */
int alert; /* alert time in sec if nonzero */
#define MINALERT 5 /* 5 secs min */
#define MAXALERT (3*60) /* 3 minutes max */
int inout; /* in/out, in-only or out-only */
#define DIR_INOUT 0
#define DIR_INONLY 1
#define DIR_OUTONLY 2
/*===========================================================================*/
/*============ filled in after start, then dynamic ==========================*/
/*===========================================================================*/
int cdid; /* cdid for call */
#define CDID_RESERVED (-1)
int isdncontrollerused; /* the one we are using */
int isdnchannelused; /* the one we are using */
int fs_position; /* fullscreen position */
int state; /* state of connection */
#define ST_IDLE 0 /* connection is idle / disconnected */
/* normal dial out to remote */
#define ST_DIAL 1 /* dialing */
#define ST_DIALRTMRCHD 2 /* wait for dial retry time reached */
#define ST_DIALRETRY 3 /* last/first dialing failed, retry */
/* PCB: passive callback, i'm being called back */
#define ST_PCB_DIAL 4 /* dialing, trigger a callback */
#define ST_PCB_DIALFAIL 5 /* dialing failed triggering a callbk */
#define ST_PCB_WAITCALL 6 /* waiting for callback from remote */
/* ACB: active callback, i'm calling back */
#define ST_ACB_WAITDISC 7 /* got call, wait for disconnect */
#define ST_ACB_WAITDIAL 8 /* wait until allowed to callback */
#define ST_ACB_DIAL 9 /* callback to remote */
#define ST_ACB_DIALFAIL 10 /* callback to remote failed */
/* normal non-dialling states */
#define ST_ACCEPTED 11 /* remote accepted */
#define ST_CONNECTED 12 /* connected with remote */
#define ST_WAITDISCI 13 /* tx disc req, wait for disc ind */
#define ST_DOWN 14 /* interface is down */
#define ST_ALERT 15 /* interface is waiting for alert time*/
/* illegal and pseudo states */
#define ST_ILL 16 /* illegal state */
#define ST_SUSE 17 /* subroutine sets new state */
#define N_STATES (ST_ILL+1) /* max number of states */
int disc_cause; /* cause from disconnect */
int local_disconnect; /* flag, who disconnected */
#define DISCON_LOC 0
#define DISCON_REM 1
int timerval; /* value for timer, 0 if inactive */
int timerremain; /* remaining time */
int hangup; /* flag, hangup connection asap */
char real_phone_incoming[TELNO_MAX]; /* real remote telno in case of wildcard */
int last_remote_number; /* index of last used dialout number*/
char remote_phone_dialout[TELNO_MAX]; /* used remote number to dial */
int direction; /* incoming or outgoing */
#define DIR_IN 0
#define DIR_OUT 1
int charge; /* charge in units */
int last_charge; /* last charge in units */
int inbytes; /* # of bytes from remote */
int iinbytes; /* # of bytes from remote on the line */
int inbps; /* bytes/sec from remote */
int outbytes; /* # of bytes to remote */
int ioutbytes; /* # of bytes to remote on the line */
int outbps; /* bytes/sec to remote */
time_t connect_time; /* time connection was established */
time_t aoc_last; /* last AOCD timestamp */
time_t aoc_now; /* current AOCD timestamp */
time_t aoc_diff; /* current unit length */
time_t aoc_lastdiff; /* last charge unit length */
int aoc_valid; /* flag: time diff is valid */
#define AOC_INVALID 0 /* aoc_diff is NOT valid */
#define AOC_VALID 1 /* aoc_diff is valid */
time_t last_dial_time; /* time of last dialing */
time_t last_release_time; /* time of last hangup */
int dial_count; /* number of dialout tries */
int randomtime; /* random() part of recoverytime*/
#define RANDOM_MASK 0x04 /* bits used from randomtime */
int down_retry_count; /* retry cycle count for usedown*/
time_t went_down_time; /* time i/f went down */
phantom_t saved_call; /* outgoing call state if called
back too early */
int alert_time; /* count down of alert time */
char display[DISPLAY_MAX];
} cfg_entry_t;
/*---------------------------------------------------------------------------*
* this struct describes state of controller with 2 b channels
*---------------------------------------------------------------------------*/
typedef struct isdn_ctrl_state {
int ctrl_type; /* type: active/passive */
int card_type; /* manufacturer (CARD_XXXX) */
int state; /* controller state */
#define CTRL_DOWN 0 /* controller inoparable */
#define CTRL_UP 1 /* controller may be used */
int stateb1; /* B-channel 1 */
int stateb2; /* B-channel 2 */
#define CHAN_IDLE 0 /* channel is free for usage */
#define CHAN_RUN 1 /* channel is occupied */
int freechans; /* number of unused channels */
#define MAX_CHANCTRL 2 /* free channels per controller */
int tei; /* tei or -1 if invalid */
} isdn_ctrl_state_t;
/*---------------------------------------------------------------------------*
* this struct describes a logging regular expression
*---------------------------------------------------------------------------*/
struct rarr {
int re_flg; /* valid entry flag */
char *re_expr; /* plain text expression */
regex_t re; /* compiled expression */
char *re_prog; /* the program to be executed */
};
#ifdef I4B_EXTERNAL_MONITOR
/* for each rights entry we keep one of this structures around: */
struct monitor_rights {
char name[FILENAME_MAX]; /* net/host spec or filename */
int rights; /* bitmask of allowed acces rights */
u_int32_t net; /* net/host address (host byte order!) */
u_int32_t mask; /* bitmask 1 = network, 0 = host (host byte order!) */
int local; /* zero if remote access via tcp/ip */
};
#endif
/*---------------------------------------------------------------------------*
* global variables, storage allocation
*---------------------------------------------------------------------------*/
#ifdef MAIN
int isdnfd; /* file handle, /dev/i4b */
char *configfile = CONFIG_FILE_DEF; /* configuration filename */
int config_error_flag = 0; /* error counter */
#ifdef DEBUG
int do_debug = 0; /* debug mode flag */
int debug_flags = 0; /* debug options */
int debug_noscreen = 0; /* not on fullscreen */
#endif
int do_bell = 0; /* bell on connect/disconnect */
int do_fork = 1; /* run as daemon/foreground */
int do_ttytype = 0; /* got new terminal type */
char *ttype = ""; /* termcap entry name string */
int do_rdev = 0; /* redirect output */
char *rdev = ""; /* new device string */
int do_print = 0; /* config file printout */
int got_unitlen = 0; /* flag, got length of a unit */
time_t unit_length; /* length of a unit */
cfg_entry_t cfg_entry_tab[CFG_ENTRY_MAX]; /* configuration table */
isdn_ctrl_state_t isdn_ctrl_tab[ISDN_CTRL_MAX]; /* controller states table */
int ncontroller = 0; /* # of controllers available */
int nentries = 0; /* # of entries in config tab */
int uselogfile = 0; /* flag, use a logfile */
char logfile[MAXPATHLEN] = LOG_FILE_DEF; /* log filename */
FILE *logfp = NULL; /* log file pointer */
int logfacility = LOG_LOCAL0; /* the syslog facility used */
int nregex = 0; /* number of reg expr */
struct rarr rarr[MAX_RE]; /* regexpr & progs table */
char ratesfile[MAXPATHLEN] = RATES_FILE_DEF; /* rates filename */
char *rate_error = NULL; /* errorcase: error string */
int got_rate = 0; /* flag, ratesfile found */
struct rates *rates[NRATES][NDAYS]; /* the rates structure */
int useacctfile = 0; /* flag, write accounting */
char acctfile[MAXPATHLEN] = ACCT_FILE_DEF; /* accounting filename */
FILE *acctfp = NULL; /* accounting file pointer */
int acct_all = 1; /* account all connections */
int aliasing = 0; /* enable alias processing */
char aliasfile[MAXPATHLEN] = ALIASFILE; /* alias file location */
int do_fullscreen = 0; /* fullscreen log */
int curses_ready = 0; /* curses initialized */
#ifdef USE_CURSES
WINDOW *upper_w; /* curses upper window pointer */
WINDOW *mid_w; /* curses mid window pointer */
WINDOW *lower_w; /* curses lower window pointer */
#endif
int rt_prio = RTPRIO_NOTUSED; /* realtime priority */
/* monitor via network */
int do_monitor = 0;
int inhibit_monitor = 0;
#ifdef I4B_EXTERNAL_MONITOR
int monitorport = DEF_MONPORT;
#else
int monitorport = -1;
#endif
int accepted = 0;
int isdntime = 0; /* flag, log time from exchange */
char tinainitprog[MAXPATHLEN] = TINA_FILE_DEF;
char rotatesuffix[MAXPATHLEN] = "";
#else /* !MAIN */
int isdnfd;
char *configfile;
int config_error_flag;
#ifdef DEBUG
int do_debug;
int debug_flags;
int debug_noscreen;
#endif
int do_bell;
int do_fork;
int do_ttytype;
char *ttype;
int do_rdev;
char *rdev;
int do_print;
int got_unitlen;
time_t unit_length;
cfg_entry_t cfg_entry_tab[CFG_ENTRY_MAX]; /* configuration table */
isdn_ctrl_state_t isdn_ctrl_tab[ISDN_CTRL_MAX]; /* controller states table */
int ncontroller;
int nentries;
int uselogfile;
char logfile[MAXPATHLEN];
int logfacility;
int nregex;
struct rarr rarr[MAX_RE];
char ratesfile[MAXPATHLEN];
char *rate_error;
int got_rate;
struct rates *rates[NRATES][NDAYS];
int useacctfile;
char acctfile[MAXPATHLEN];
FILE *acctfp;
int acct_all;
int aliasing;
char aliasfile[MAXPATHLEN];
int do_fullscreen;
int curses_ready;
#ifdef USE_CURSES
WINDOW *upper_w;
WINDOW *mid_w;
WINDOW *lower_w;
#endif
int rt_prio;
int do_monitor;
int inhibit_monitor;
int monitorport;
int accepted;
int isdntime;
char tinainitprog[MAXPATHLEN];
char rotatesuffix[MAXPATHLEN];
#endif /* MAIN */
char * bdrivername ( int drivertype );
void cfg_setval ( int keyword );
void check_and_kill ( cfg_entry_t *cep );
void check_pid ( void );
void close_allactive ( void );
void configure ( char *filename, int reread );
void daemonize ( void );
void dialresponse(cfg_entry_t *cep, int dstat);
void display_acct ( cfg_entry_t *cep );
void display_bell ( void );
void display_ccharge ( cfg_entry_t *cep, int units );
void display_chans ( void );
void display_charge ( cfg_entry_t *cep );
void display_connect ( cfg_entry_t *cep );
void display_disconnect ( cfg_entry_t *cep );
void display_l12stat(int controller, int layer, int state);
void display_tei(int controller, int tei);
void display_updown ( cfg_entry_t *cep, int updown );
void hangup_channel ( int channel );
void do_exit ( int exitval );
void do_menu ( void );
int exec_answer ( cfg_entry_t *cep );
int exec_connect_prog ( cfg_entry_t *cep, const char *prog, int link_down );
pid_t exec_prog ( char *prog, char **arglist );
cfg_entry_t * find_by_device_for_dialout ( int drivertype, int driverunit );
cfg_entry_t *find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, char *cmd);
cfg_entry_t * find_matching_entry_incoming ( msg_connect_ind_t *mp );
cfg_entry_t * find_active_entry_by_driver ( int drivertype, int driverunit );
void finish_log ( void );
char * getlogdatetime ( void );
int get_cdid ( void );
cfg_entry_t * get_cep_by_cc ( int ctrlr, int chan );
cfg_entry_t * get_cep_by_driver ( int drivertype, int driverunit );
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 if_up(cfg_entry_t *cep);
void if_down(cfg_entry_t *cep);
void init_controller ( void );
void init_log ( void );
void init_screen ( void );
void log ( int what, const char *fmt, ... );
int main ( int argc, char **argv );
void msg_accounting ( msg_accounting_ind_t *mp );
void msg_alert_ind ( msg_alert_ind_t *mp );
void msg_charging_ind ( msg_charging_ind_t *mp );
void msg_connect_active_ind ( msg_connect_active_ind_t *mp );
void msg_connect_ind ( msg_connect_ind_t *mp );
void msg_pdeact_ind(msg_pdeact_ind_t *md);
void msg_negcomplete_ind(msg_negcomplete_ind_t *ind);
void msg_ifstatechg_ind(msg_ifstatechg_ind_t *ind);
void msg_drvrdisc_req(msg_drvrdisc_req_t *mp);
void msg_dialout ( msg_dialout_ind_t *mp );
void msg_dialoutnumber(msg_dialoutnumber_ind_t *mp);
void msg_disconnect_ind ( msg_disconnect_ind_t *mp );
void msg_idle_timeout_ind ( msg_idle_timeout_ind_t *mp );
void msg_l12stat_ind(msg_l12stat_ind_t *ml);
void msg_teiasg_ind(msg_teiasg_ind_t *mt);
void msg_proceeding_ind ( msg_proceeding_ind_t *mp );
const char * name_of_controller(int ctrl_type, int card_type);
void next_state ( cfg_entry_t *cep, int event );
char * print_i4b_cause( cause_t code );
char * printstate ( cfg_entry_t *cep );
int readrates ( char *filename );
int ret_channel_state(int controller, int channel);
void reopenfiles ( int dummy );
void rereadconfig ( int dummy );
void select_first_dialno ( cfg_entry_t *cep );
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 set_channel_busy(int controller, int channel);
int set_channel_idle(int controller, int channel);
int setup_dialout(cfg_entry_t *cep);
void sigchild_handler ( int sig );
void start_timer ( cfg_entry_t *cep, int seconds );
void stop_timer ( cfg_entry_t *cep );
void unitlen_chkupd( cfg_entry_t *cep );
void write_pid ( void );
void yyerror ( const char *msg );
/* montior server module */
void monitor_init();
void monitor_exit();
void monitor_clear_rights();
void monitor_fixup_rights();
int monitor_start_rights(const char *clientspec);
void monitor_add_rights(int rights);
/* possible return codes from monitor_start_rights: */
#define I4BMAR_OK 0 /* rights added successfully */
#define I4BMAR_LENGTH 1 /* local socket name to long */
#define I4BMAR_DUP 2 /* entry already exists */
#define I4BMAR_CIDR 3 /* cidr netmask is invalid */
#define I4BMAR_NOIP 4 /* host/net could not be resolved */
int monitor_create_local_socket();
#ifndef I4B_NOTCPIP_MONITOR
int monitor_create_remote_socket(int portno);
#endif
void monitor_prepselect(fd_set *selset, int *max_fd);
void monitor_handle_input(fd_set *selset);
void monitor_handle_connect(int sockfd, int is_local);
void monitor_evnt_charge(cfg_entry_t *cep, int units, int estimated);
void monitor_evnt_connect(cfg_entry_t *cep);
void monitor_evnt_disconnect(cfg_entry_t *cep);
void monitor_evnt_updown(cfg_entry_t *cep, int up);
void monitor_evnt_log(int prio, const char * what, const char * msg);
/* controller.c */
int init_controller_state(int controller, int ctrl_type, int card_type, int tei);
void init_active_controller(void);
int set_controller_state(int controller, int state);
int get_controller_state(int controller);
int decr_free_channels(int controller);
int incr_free_channels(int controller);
int get_free_channels(int controller);
int set_channel_busy(int controller, int channel);
int set_channel_idle(int controller, int channel);
int ret_channel_state(int controller, int channel);
/* alias.c */
void init_alias(char *filename);
void free_aliases(void);
char *get_alias(char *number);
#endif /* _ISDND_H_ */
|