Enable debugging for openssl port.
[wvapps.git] / wvdial / wvdialer.h
blobc20a18e0da3887a50fc48e73a76ed5f88eb77cc0
1 /*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2003 Net Integration Technologies, Inc.
5 * Definition of the WvDialer smart-dialer class.
7 */
9 #ifndef __DIALER_H
10 #define __DIALER_H
12 #include <termios.h>
14 #include "strutils.h"
15 #include "wvconfemu.h"
16 #include "wvlog.h"
17 #include "wvmodem.h"
18 #include "wvpapchap.h"
19 #include "wvdialbrain.h"
20 #include "wvpipe.h"
21 #include "wvstreamclone.h"
22 #include "wvdialmon.h"
24 #define INBUF_SIZE 1024
25 #define DEFAULT_BAUD 57600U
27 extern const char wvdial_help_text[];
28 extern const char wvdial_version_text[];
30 struct OptInfo
31 /************/
33 char * name;
34 WvString * str_member;
35 int * int_member;
36 char * str_default;
37 int int_default;
40 class WvConf;
42 class WvDialer : public WvStreamClone
43 /***********************************/
45 public:
46 WvDialer( WvConf &_cfg, WvStringList *_sect_list, bool _chat_mode = false );
47 virtual ~WvDialer();
49 bool dial();
50 void hangup();
51 void execute();
53 bool check_attempts_exceeded(int connect_attempts);
55 void pppd_watch( int w );
57 int ask_password();
59 enum Status {
60 Idle,
61 ModemError,
62 OtherError,
63 Online,
64 Dial,
65 PreDial1,
66 PreDial2,
67 WaitDial,
68 WaitAnything,
69 WaitPrompt,
70 AutoReconnectDelay
73 Status status() const
74 { return stat; }
76 time_t auto_reconnect_time() const
77 { return (auto_reconnect_at - time(NULL)); }
79 virtual bool pre_select(SelectInfo &si);
80 virtual bool isok() const;
82 int connect_attempts;
83 int dial_stat;
84 char *connect_status() const;
85 bool init_modem();
86 void del_modem();
87 WvModemBase *take_modem();
88 void give_modem(WvModemBase *_modem);
90 friend class WvDialBrain;
92 struct {
93 WvString modem;
94 int baud;
95 WvString init1;
96 WvString init2;
97 WvString init3;
98 WvString init4;
99 WvString init5;
100 WvString init6;
101 WvString init7;
102 WvString init8;
103 WvString init9;
104 WvString phnum;
105 WvString phnum1;
106 WvString phnum2;
107 WvString phnum3;
108 WvString phnum4;
109 WvString dial_prefix;
110 WvString areacode;
111 WvString dial_cmd;
112 WvString login;
113 WvString login_prompt;
114 WvString password;
115 WvString pass_prompt;
116 WvString where_pppd;
117 WvString pppd_option;
118 WvString force_addr;
119 WvString remote;
120 WvString default_reply;
121 WvString country;
122 WvString provider;
123 WvString product;
124 WvString homepage;
125 WvString dialmessage1;
126 WvString dialmessage2;
127 WvString dnstest1, dnstest2;
128 int carrier_check;
129 int stupid_mode;
130 int new_pppd;
131 int auto_reconnect;
132 int abort_on_busy;
133 int abort_on_no_dialtone;
134 int dial_attempts;
135 int compuserve;
136 int tonline;
137 int auto_dns;
138 int check_dns;
139 int check_dfr;
140 int idle_seconds;
141 int isdn;
142 int ask_password;
144 } options;
147 WvDialMon pppd_mon; // class to analyse messages of pppd
150 private:
151 WvDialBrain *brain;
152 WvConf &cfg;
153 WvStringList *sect_list;
154 WvModemBase *modem;
156 bool chat_mode;
158 bool been_online;
159 time_t connected_at;
160 time_t auto_reconnect_delay;
161 time_t auto_reconnect_at;
162 WvPipe *ppp_pipe;
164 int phnum_count;
165 int phnum_max;
167 WvLog log;
168 WvLog err;
169 WvLog modemrx;
171 Status stat;
173 time_t last_rx;
174 time_t last_execute;
175 int prompt_tries;
176 WvString prompt_response;
178 void load_options();
180 void async_dial();
181 void async_waitprompt();
183 void start_ppp();
185 // The following members are for the wait_for_modem() function.
186 int wait_for_modem( char *strs[], int timeout, bool neednewline,
187 bool verbose = true);
188 int async_wait_for_modem( char * strs[], bool neednewline,
189 bool verbose = true);
190 char buffer[ INBUF_SIZE + 1 ];
191 off_t offset;
192 void reset_offset();
194 // Called from WvDialBrain::guess_menu()
195 bool is_pending() { return( modem->select( 1000 ) ); }
197 // These are used to read the messages of pppd
198 int pppd_msgfd[2]; // two fd of the pipe
199 WvFDStream *pppd_log; // to read messages of pppd
201 // These are used to pipe the password to pppd
202 int pppd_passwdfd[2]; // two fd of the pipe
205 #endif // __DIALER_H