summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/ppp/ppp_NNI.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp152
1 files changed, 83 insertions, 69 deletions
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
index ba639de..9e3bb64 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
@@ -16,12 +16,21 @@ APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
16 Data.Auth.Server = "*"; 16 Data.Auth.Server = "*";
17 Data.Auth.Secret = ""; 17 Data.Auth.Secret = "";
18 18
19 Data.IP.IPAutomatic = 1; 19 Data.IP.LocalAddress = "10.0.0.1";
20 Data.IP.IPAddress = ""; 20 Data.IP.RemoteAddress = "10.0.0.2";
21 Data.IP.IPSubMask = ""; 21 Data.IP.LocalOverrule = 1;
22 Data.IP.RemoteOverrule = 1;
23
22 Data.IP.GWAutomatic = 1; 24 Data.IP.GWAutomatic = 1;
23 Data.IP.GWAddress = ""; 25 Data.IP.GWAddress = "";
24 Data.IP.GWIsDefault = 1; 26 Data.IP.GWIsDefault = 1;
27 Data.IP.GWIfNotSet = 1;
28
29 Data.Run.PreConnect = "";
30 Data.Run.PostConnect = "";
31 Data.Run.PreDisconnect = "";
32 Data.Run.PostDisconnect = "";
33
25 GUI = 0; 34 GUI = 0;
26 RT = 0; 35 RT = 0;
27 36
@@ -59,19 +68,33 @@ void APPP::setSpecificAttribute( QString & A, QString & V ) {
59 Data.Auth.Secret = V; 68 Data.Auth.Secret = V;
60 } 69 }
61 } else if( A.startsWith( "ip" ) ) { 70 } else if( A.startsWith( "ip" ) ) {
62 if( A == "ipautomatic" ) { 71 if( A == "iplocaloverrule" ) {
63 Data.IP.IPAutomatic = (V == "yes"); 72 Data.IP.LocalOverrule = (V == "yes");
64 } else if( A == "gwautomatic" ) { 73 } else if( A == "ipremoteoverrule" ) {
74 Data.IP.RemoteOverrule = (V == "yes");
75 } else if( A == "ipgwautomatic" ) {
65 Data.IP.GWAutomatic = (V == "yes"); 76 Data.IP.GWAutomatic = (V == "yes");
66 } else if( A == "gwisdefault" ) { 77 } else if( A == "ipgwisdefault" ) {
67 Data.IP.GWIsDefault = (V == "yes"); 78 Data.IP.GWIsDefault = (V == "yes");
68 } else if( A == "ipaddress" ) { 79 } else if( A == "ipgwifnotset" ) {
69 Data.IP.IPAddress = V; 80 Data.IP.GWIfNotSet = (V == "yes");
70 } else if( A == "ipsubmask" ) { 81 } else if( A == "iplocaladdress" ) {
71 Data.IP.IPSubMask = V; 82 Data.IP.LocalAddress = V;
72 } else if( A == "gwaddress" ) { 83 } else if( A == "ipremoteaddress" ) {
84 Data.IP.RemoteAddress = V;
85 } else if( A == "ipgwaddress" ) {
73 Data.IP.GWAddress = V; 86 Data.IP.GWAddress = V;
74 } 87 }
88 } else if( A.startsWith( "run" ) ) {
89 if( A == "runpreconnect" ) {
90 Data.Run.PreConnect = V;
91 } else if( A == "runpostconnect" ) {
92 Data.Run.PostConnect = V;
93 } else if( A == "runpredisconnect" ) {
94 Data.Run.PreDisconnect = V;
95 } else if( A == "runpostdisconnect" ) {
96 Data.Run.PostDisconnect = V;
97 }
75 } 98 }
76} 99}
77 100
@@ -91,12 +114,20 @@ void APPP::saveSpecificAttribute( QTextStream & TS ) {
91 TS << "authclient=" << Data.Auth.Client << endl; 114 TS << "authclient=" << Data.Auth.Client << endl;
92 TS << "authserver=" << Data.Auth.Server << endl; 115 TS << "authserver=" << Data.Auth.Server << endl;
93 TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; 116 TS << "authsecret=" << quote( Data.Auth.Secret ) << endl;
94 TS << "ipautomatic=" << ( ( Data.IP.IPAutomatic ) ? "yes" : "no" ) << endl; 117 TS << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl;
95 TS << "gwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; 118 TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl;
96 TS << "gwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; 119 TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl;
97 TS << "ipaddress=" << Data.IP.IPAddress << endl; 120 TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl;
98 TS << "ipsubmask=" << Data.IP.IPSubMask << endl; 121 TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl;
99 TS << "gwaddress=" << Data.IP.GWAddress << endl; 122 TS << "iplocaladdress=" << Data.IP.LocalAddress << endl;
123 TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl;
124 TS << "ipgwaddress=" << Data.IP.GWAddress << endl;
125
126 TS << "runpreconnect=" << Data.Run.PreConnect << endl;
127 TS << "runpostconnect=" << Data.Run.PostConnect << endl;
128 TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl;
129 TS << "runpostdisconnect=" << Data.Run.PostDisconnect << endl;
130
100} 131}
101 132
102QWidget * APPP::edit( QWidget * parent ) { 133QWidget * APPP::edit( QWidget * parent ) {
@@ -115,51 +146,33 @@ void APPP::commit( void ) {
115 } 146 }
116} 147}
117 148
118QFile * APPP::openFile( const QString & ID ) { 149bool APPP::openFile( SystemFile & SF ) {
119 QFile * F = 0; 150 if( SF.name() == "peers" ) {
120 QString S; 151 SF.setPath( removeSpaces(
121 152 QString( "/tmp/ppp/peers/" ) + connection()->name() ) );
122 if( ID == "peers" ) { 153 return 1;
123 S = removeSpaces( QString("/tmp/") + connection()->name() ); 154 } else if ( SF.name() == "chatscripts" ) {
124 155 SF.setPath( removeSpaces(
125 F = new QFile( S ); 156 QString( "/tmp/chatscripts/" ) + connection()->name() ) );
126 157 return 1;
127 if( ! F->open( IO_WriteOnly ) ) {
128 Log(("Cannot open file %s\n", S.latin1() ));
129 return 0;
130 } 158 }
131 } else if ( ID == "chatscripts" ) {
132 S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" );
133 F = new QFile( S );
134
135 if( ! F->open( IO_WriteOnly ) ) {
136 Log(("Cannot open file %s\n", S.latin1() ));
137 return 0; 159 return 0;
138 } 160 }
139 }
140 if( F ) {
141 Log(("Generate proper file %s = %s\n",
142 ID.latin1(), F->name().latin1()));
143 }
144 return F;
145}
146 161
147short APPP::generateFile( const QString & ID, 162short APPP::generateFile( SystemFile & SF, long DevNr ) {
148 const QString & Path,
149 QTextStream & TS,
150 long DevNr ) {
151 short rvl, rvd; 163 short rvl, rvd;
152 164
153 rvl = 1; 165 rvl = 1;
154 rvd = 1; 166 rvd = 1;
155 167
156 if( ID == "pap-secrets" ) { 168 if( SF.name() == "pap-secrets" ) {
157 Log(("Generate PPP for %s\n", ID.latin1() )); 169 Log(("Generate PPP for %s\n", SF.name().latin1() ));
170
158 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) { 171 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) {
159 TS << "# secrets for " 172 SF << "# secrets for "
160 << connection()->name().latin1() 173 << connection()->name().latin1()
161 << endl; 174 << endl;
162 TS << Data.Auth.Client 175 SF << Data.Auth.Client
163 << " " 176 << " "
164 << Data.Auth.Server 177 << Data.Auth.Server
165 << " " 178 << " "
@@ -167,16 +180,16 @@ short APPP::generateFile( const QString & ID,
167 << endl; 180 << endl;
168 rvl = 0; 181 rvl = 0;
169 rvd = connection()->getToplevel()->generateFileEmbedded( 182 rvd = connection()->getToplevel()->generateFileEmbedded(
170 ID, Path, TS, DevNr ); 183 SF, DevNr );
171 } 184 }
172 } else if( ID == "chap-secrets" ) { 185 } else if( SF.name() == "chap-secrets" ) {
173 Log(("Generate PPP for %s\n", ID.latin1() )); 186 Log(("Generate PPP for %s\n", SF.name().latin1() ));
174 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) { 187 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) {
175 // used for both EAP and Chap 188 // used for both EAP and Chap
176 TS << "# secrets for " 189 SF << "# secrets for "
177 << connection()->name().latin1() 190 << connection()->name().latin1()
178 << endl; 191 << endl;
179 TS << Data.Auth.Client 192 SF << Data.Auth.Client
180 << " " 193 << " "
181 << Data.Auth.Server 194 << Data.Auth.Server
182 << " " 195 << " "
@@ -185,35 +198,36 @@ short APPP::generateFile( const QString & ID,
185 198
186 rvl = 0; 199 rvl = 0;
187 rvd = connection()->getToplevel()->generateFileEmbedded( 200 rvd = connection()->getToplevel()->generateFileEmbedded(
188 ID, Path, TS, DevNr ); 201 SF, DevNr );
189 } 202 }
190 } else if ( ID == "peers" ) { 203 } else if ( SF.name() == "peers" ) {
191 QFileInfo FI(Path); 204
192 Log(("Generate PPP for %s\n", ID.latin1() )); 205 QFileInfo FI(SF.path());
206 Log(("Generate PPP for %s\n", SF.name().latin1() ));
193 207
194 TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/" 208 SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/"
195 << FI.baseName() 209 << FI.baseName()
196 << ".chat\"" 210 << "\""
197 << endl; 211 << endl;
198 212
199 if( Data.IP.GWIsDefault ) { 213 if( Data.IP.GWIsDefault ) {
200 TS << "defaultroute" 214 SF << "defaultroute"
201 << endl; 215 << endl;
202 } 216 }
203 217
204 TS << "linkname " 218 SF << "linkname "
205 << removeSpaces( ID.latin1() ) 219 << removeSpaces( SF.name().latin1() )
206 << endl; 220 << endl;
207 221
208 // insert other data here 222 // insert other data here
209 rvl = 0; 223 rvl = 0;
210 rvd = connection()->getToplevel()->generateFileEmbedded( 224 rvd = connection()->getToplevel()->generateFileEmbedded(
211 ID, Path, TS, DevNr ); 225 SF, DevNr );
212 } else if ( ID == "chatscripts" ) { 226 } else if ( SF.name() == "chatscripts" ) {
213 Log(("Generate PPP for %s\n", ID.latin1() )); 227 Log(("Generate PPP for %s\n", SF.name().latin1() ));
214 rvl = 0; 228 rvl = 0;
215 rvd = connection()->getToplevel()->generateFileEmbedded( 229 rvd = connection()->getToplevel()->generateFileEmbedded(
216 ID, Path, TS, DevNr ); 230 SF, DevNr );
217 } 231 }
218 232
219 return (rvd == 2 || rvl == 2 ) ? 2 : 233 return (rvd == 2 || rvl == 2 ) ? 2 :