forked from bakagirl/Arachne-WWW-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ATCPIP.C
196 lines (171 loc) · 4.49 KB
/
ATCPIP.C
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
// ========================================================================
// Arachne TCP/IP init
// (c)1997-1999 Michael Polak, Arachne Labs, xChaos software
// ========================================================================
#include "arachne.h"
#include "internet.h"
void errppp(void)
{
tcpip=0;
if(arachne.scriptline)
{
sprintf(GLOBAL.location,"file:%s%serr_asf.ah",sharepath,GUIPATH);
arachne.scriptline=0; //disable scripting!
}
else
{
sprintf(GLOBAL.location,"file:%s%serr_ppp.ah",sharepath,GUIPATH);
pagetime=time(NULL);
}
}
//this is missing in tcp.h header file:
void _arp_add_gateway( char *data , longword ip );
void ArachneTCPIP(void)
{
char dialer=0;
char *value=configvariable(&ARACHNEcfg,"Connection",NULL);
//!!glennmcc: Mar 06 2006
char *dns="\0", *dns1="\0", *dns2="\0";
//!!glennmcc: end
if(!value)
{
tcpip=0;
return;
}
if(value[0]=='@')
dialer=1;
if(!strncmpi(value,"READY",5))
tcpip=1;
else
if(!strncmpi(value,"HTTPSTUB",8))
httpstub=1;
else
if(!tcpip && dialer && !GLOBAL.location[0])
{
value=configvariable(&ARACHNEcfg,"DialPage",NULL);
//!!glennmcc: Begin Feb 06, 2005 -- default to ppp_init.htm
//if 'DialPage' is missing from arachne.cfg
if(!value) value="file:ppp_init.htm";
//!!glennmcc: end
if(value)
strcpy(GLOBAL.location,value);
}
if(tcpip) //inicializace TCP/IP pokud je -o, -r ...
{
outs(MSG_TCPIP);
value=configvariable(&ARACHNEcfg,"TCPconfig",NULL);
if(value)
tcp_config_file( value);
value=configvariable(&ARACHNEcfg,"IP_Address",NULL);
if(!value)
{
tcpip=0;
sprintf(GLOBAL.location,"file:%s%serr_noip.ah",sharepath,GUIPATH);
return;
}
#ifndef NOETHERPPP
if(!strncmpi(value,"PPP",3))
ipmode=MODE_PPP;
else
#endif
if(!strncmpi(value,"BOOTP",5))
ipmode=MODE_BOOTP;
else
if(!strncmpi(value,"WATTCP",5))
ipmode=MODE_WATTCP;
// _bootpon = 0;
switch(ipmode)
{
case MODE_NORMAL:
if(value[0]=='%' || value[0]=='$' )
{
char *ptr;
//enviroment
makestr(myIPstr,&value[1],19);
//vymazani zaverecneho '%'
ptr=strchr(&myIPstr[1],'%');
if(ptr)
*ptr='\0';
makestr(myIPstr,getenv(myIPstr),19);
}
else
makestr(myIPstr,value,19);
my_ip_addr = resolve( myIPstr );
break;
case MODE_BOOTP:
//_bootpon = 1;
tcp_config_file( NULL );
//!!JdS: 2003/12/7 {
// If a dial-up connection, initialize 'ppplogtime' via PPPlog().
// This allows the "Time Online" status display to function.
// Note that PPPlog() has been rewritten to avoid side-effects.
//!!JdS: 2003/12/7 }
if(dialer)
PPPlog(); //failure is tolerable here
break;
#ifndef NOETHERPPP
case MODE_PPP:
if(!PPPlog())
{
errppp();
return;
}
#endif
}
if(sock_init_noexit())
{
if(dialer)
errppp();
else
{
tcpip=0;
sprintf(GLOBAL.location,"file:%s%serr_pkt.ah",sharepath,GUIPATH);
}
return;
}
else
tcpip=1;
/*
websocket=malloc(sizeof(tcp_Socket));
if(websocket)
{
tcp_listen(websocket, 80, 0, 0, webserver , 0);
}
*/
if(ipmode==MODE_PPP)
loadrefresh=500;
if(ipmode!=MODE_WATTCP && ipmode!=MODE_BOOTP)
{
value=configvariable(&ARACHNEcfg,"Gateway",NULL);
if(value) _arp_add_gateway( value , 0L );
value=configvariable(&ARACHNEcfg,"AltGateway",NULL);
if(value) _arp_add_gateway( value , 0L );
value=configvariable(&ARACHNEcfg,"Netmask",NULL);
if(value) sin_mask = resolve( value );
}
//!!glennmcc: Mar 06 2006 -- modified entire section to use 'dns1' and 'dns2'
//instead of the original 'value' in all places
dns1=configvariable(&ARACHNEcfg,"NameServer",NULL);
//!!glennmcc: Dec 12, 2005 -- add NameServer %DNS1% capability
if(dns1 && *dns1=='%')
{
char *ptr=strchr(&dns1[1],'%');
if(ptr) *ptr='\0';
dns=getenv(&dns1[1]);
}
else strcpy(dns,dns1);
//!!glennmcc: end
if(dns) _add_server( &_last_nameserver, MAX_NAMESERVERS, def_nameservers, resolve(dns));
dns2=configvariable(&ARACHNEcfg,"AltNameServer",NULL);
//!!glennmcc: Dec 12, 2005 -- add AltNameServer %DNS2% capability
if(dns2 && *dns2=='%')
{
char *ptr=strchr(&dns2[1],'%');
if(ptr) *ptr='\0';
dns=getenv(&dns2[1]);
}
else strcpy(dns,dns2);
//!!glennmcc: end
if(dns) _add_server( &_last_nameserver, MAX_NAMESERVERS, def_nameservers, resolve(dns));
}//endif tcp/ip
}