This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
wvdialer.h
207 lines (169 loc) · 4.62 KB
/
wvdialer.h
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
/*
* Worldvisions Weaver Software:
* Copyright (C) 1997-2003 Net Integration Technologies, Inc.
*
* Definition of the WvDialer smart-dialer class.
*
*/
#ifndef __DIALER_H
#define __DIALER_H
#include <termios.h>
#include "strutils.h"
#include "wvconfemu.h"
#include "wvlog.h"
#include "wvmodem.h"
#include "wvpapchap.h"
#include "wvdialbrain.h"
#include "wvpipe.h"
#include "wvstreamclone.h"
#include "wvdialmon.h"
#define INBUF_SIZE 1024
#define DEFAULT_BAUD 57600U
extern const char wvdial_help_text[];
extern const char wvdial_version_text[];
struct OptInfo
/************/
{
const char * name;
WvString * str_member;
int * int_member;
const char * str_default;
int int_default;
};
class WvConf;
class WvDialer : public WvStreamClone
/***********************************/
{
public:
WvDialer( WvConf &_cfg, WvStringList *_sect_list, bool _chat_mode = false );
virtual ~WvDialer();
bool dial();
void hangup();
void execute();
bool check_attempts_exceeded(int connect_attempts);
void pppd_watch( int w );
int ask_password();
enum Status {
Idle,
ModemError,
OtherError,
Online,
Dial,
PreDial1,
PreDial2,
WaitDial,
WaitAnything,
WaitPrompt,
AutoReconnectDelay
};
Status status() const
{ return stat; }
time_t auto_reconnect_time() const
{ return (auto_reconnect_at - time(NULL)); }
virtual void pre_select(SelectInfo &si);
virtual bool post_select(SelectInfo &si);
virtual bool isok() const;
int connect_attempts;
int dial_stat;
char *connect_status() const;
bool init_modem();
void del_modem();
WvModemBase *take_modem();
void give_modem(WvModemBase *_modem);
friend class WvDialBrain;
struct {
WvString modem;
int baud;
WvString init1;
WvString init2;
WvString init3;
WvString init4;
WvString init5;
WvString init6;
WvString init7;
WvString init8;
WvString init9;
WvString phnum;
WvString phnum1;
WvString phnum2;
WvString phnum3;
WvString phnum4;
WvString dial_prefix;
WvString areacode;
WvString dial_cmd;
WvString login;
WvString login_prompt;
WvString password;
WvString pass_prompt;
WvString where_pppd;
WvString pppd_option;
WvString force_addr;
WvString remote;
WvString default_reply;
WvString country;
WvString provider;
WvString product;
WvString homepage;
WvString dialmessage1;
WvString dialmessage2;
WvString dnstest1, dnstest2;
int carrier_check;
int stupid_mode;
int new_pppd;
int auto_reconnect;
int abort_on_busy;
int abort_on_no_dialtone;
int dial_attempts;
int compuserve;
int tonline;
int auto_dns;
int check_dns;
int check_dfr;
int idle_seconds;
int isdn;
int ask_password;
int dial_timeout;
} options;
WvDialMon pppd_mon; // class to analyse messages of pppd
private:
WvDialBrain *brain;
WvConf &cfg;
WvStringList *sect_list;
WvModemBase *modem;
bool chat_mode;
bool been_online;
time_t connected_at;
time_t auto_reconnect_delay;
time_t auto_reconnect_at;
WvPipe *ppp_pipe;
int phnum_count;
int phnum_max;
WvLog log;
WvLog err;
WvLog modemrx;
Status stat;
time_t last_rx;
time_t last_execute;
int prompt_tries;
WvString prompt_response;
void load_options();
void async_dial();
void async_waitprompt();
void start_ppp();
// The following members are for the wait_for_modem() function.
int wait_for_modem( const char *strs[], int timeout, bool neednewline,
bool verbose = true);
int async_wait_for_modem( const char * strs[], bool neednewline,
bool verbose = true);
char buffer[ INBUF_SIZE + 1 ];
off_t offset;
void reset_offset();
// Called from WvDialBrain::guess_menu()
bool is_pending() { return( modem->select( 1000 ) ); }
// These are used to read the messages of pppd
int pppd_msgfd[2]; // two fd of the pipe
WvFDStream *pppd_log; // to read messages of pppd
// These are used to pipe the password to pppd
int pppd_passwdfd[2]; // two fd of the pipe
};
#endif // __DIALER_H