summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/ppp/ppp_NNI.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp154
1 files changed, 84 insertions, 70 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
@@ -18,5 +18,7 @@ APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
- Data.IP.IPAutomatic = 1;
- Data.IP.IPAddress = "";
- Data.IP.IPSubMask = "";
+ Data.IP.LocalAddress = "10.0.0.1";
+ Data.IP.RemoteAddress = "10.0.0.2";
+ Data.IP.LocalOverrule = 1;
+ Data.IP.RemoteOverrule = 1;
+
Data.IP.GWAutomatic = 1;
@@ -24,2 +26,9 @@ APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
Data.IP.GWIsDefault = 1;
+ Data.IP.GWIfNotSet = 1;
+
+ Data.Run.PreConnect = "";
+ Data.Run.PostConnect = "";
+ Data.Run.PreDisconnect = "";
+ Data.Run.PostDisconnect = "";
+
GUI = 0;
@@ -61,15 +70,29 @@ void APPP::setSpecificAttribute( QString & A, QString & V ) {
} else if( A.startsWith( "ip" ) ) {
- if( A == "ipautomatic" ) {
- Data.IP.IPAutomatic = (V == "yes");
- } else if( A == "gwautomatic" ) {
+ if( A == "iplocaloverrule" ) {
+ Data.IP.LocalOverrule = (V == "yes");
+ } else if( A == "ipremoteoverrule" ) {
+ Data.IP.RemoteOverrule = (V == "yes");
+ } else if( A == "ipgwautomatic" ) {
Data.IP.GWAutomatic = (V == "yes");
- } else if( A == "gwisdefault" ) {
+ } else if( A == "ipgwisdefault" ) {
Data.IP.GWIsDefault = (V == "yes");
- } else if( A == "ipaddress" ) {
- Data.IP.IPAddress = V;
- } else if( A == "ipsubmask" ) {
- Data.IP.IPSubMask = V;
- } else if( A == "gwaddress" ) {
+ } else if( A == "ipgwifnotset" ) {
+ Data.IP.GWIfNotSet = (V == "yes");
+ } else if( A == "iplocaladdress" ) {
+ Data.IP.LocalAddress = V;
+ } else if( A == "ipremoteaddress" ) {
+ Data.IP.RemoteAddress = V;
+ } else if( A == "ipgwaddress" ) {
Data.IP.GWAddress = V;
}
+ } else if( A.startsWith( "run" ) ) {
+ if( A == "runpreconnect" ) {
+ Data.Run.PreConnect = V;
+ } else if( A == "runpostconnect" ) {
+ Data.Run.PostConnect = V;
+ } else if( A == "runpredisconnect" ) {
+ Data.Run.PreDisconnect = V;
+ } else if( A == "runpostdisconnect" ) {
+ Data.Run.PostDisconnect = V;
+ }
}
@@ -93,8 +116,16 @@ void APPP::saveSpecificAttribute( QTextStream & TS ) {
TS << "authsecret=" << quote( Data.Auth.Secret ) << endl;
- TS << "ipautomatic=" << ( ( Data.IP.IPAutomatic ) ? "yes" : "no" ) << endl;
- TS << "gwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl;
- TS << "gwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl;
- TS << "ipaddress=" << Data.IP.IPAddress << endl;
- TS << "ipsubmask=" << Data.IP.IPSubMask << endl;
- TS << "gwaddress=" << Data.IP.GWAddress << endl;
+ TS << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl;
+ TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl;
+ TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl;
+ TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl;
+ TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl;
+ TS << "iplocaladdress=" << Data.IP.LocalAddress << endl;
+ TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl;
+ TS << "ipgwaddress=" << Data.IP.GWAddress << endl;
+
+ TS << "runpreconnect=" << Data.Run.PreConnect << endl;
+ TS << "runpostconnect=" << Data.Run.PostConnect << endl;
+ TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl;
+ TS << "runpostdisconnect=" << Data.Run.PostDisconnect << endl;
+
}
@@ -117,35 +148,16 @@ void APPP::commit( void ) {
-QFile * APPP::openFile( const QString & ID ) {
- QFile * F = 0;
- QString S;
-
- if( ID == "peers" ) {
- S = removeSpaces( QString("/tmp/") + connection()->name() );
-
- F = new QFile( S );
-
- if( ! F->open( IO_WriteOnly ) ) {
- Log(("Cannot open file %s\n", S.latin1() ));
- return 0;
- }
- } else if ( ID == "chatscripts" ) {
- S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" );
- F = new QFile( S );
-
- if( ! F->open( IO_WriteOnly ) ) {
- Log(("Cannot open file %s\n", S.latin1() ));
- return 0;
- }
+bool APPP::openFile( SystemFile & SF ) {
+ if( SF.name() == "peers" ) {
+ SF.setPath( removeSpaces(
+ QString( "/tmp/ppp/peers/" ) + connection()->name() ) );
+ return 1;
+ } else if ( SF.name() == "chatscripts" ) {
+ SF.setPath( removeSpaces(
+ QString( "/tmp/chatscripts/" ) + connection()->name() ) );
+ return 1;
}
- if( F ) {
- Log(("Generate proper file %s = %s\n",
- ID.latin1(), F->name().latin1()));
- }
- return F;
+ return 0;
}
-short APPP::generateFile( const QString & ID,
- const QString & Path,
- QTextStream & TS,
- long DevNr ) {
+short APPP::generateFile( SystemFile & SF, long DevNr ) {
short rvl, rvd;
@@ -155,9 +167,10 @@ short APPP::generateFile( const QString & ID,
- if( ID == "pap-secrets" ) {
- Log(("Generate PPP for %s\n", ID.latin1() ));
+ if( SF.name() == "pap-secrets" ) {
+ Log(("Generate PPP for %s\n", SF.name().latin1() ));
+
if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) {
- TS << "# secrets for "
+ SF << "# secrets for "
<< connection()->name().latin1()
<< endl;
- TS << Data.Auth.Client
+ SF << Data.Auth.Client
<< " "
@@ -169,12 +182,12 @@ short APPP::generateFile( const QString & ID,
rvd = connection()->getToplevel()->generateFileEmbedded(
- ID, Path, TS, DevNr );
+ SF, DevNr );
}
- } else if( ID == "chap-secrets" ) {
- Log(("Generate PPP for %s\n", ID.latin1() ));
+ } else if( SF.name() == "chap-secrets" ) {
+ Log(("Generate PPP for %s\n", SF.name().latin1() ));
if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) {
// used for both EAP and Chap
- TS << "# secrets for "
+ SF << "# secrets for "
<< connection()->name().latin1()
<< endl;
- TS << Data.Auth.Client
+ SF << Data.Auth.Client
<< " "
@@ -187,11 +200,12 @@ short APPP::generateFile( const QString & ID,
rvd = connection()->getToplevel()->generateFileEmbedded(
- ID, Path, TS, DevNr );
+ SF, DevNr );
}
- } else if ( ID == "peers" ) {
- QFileInfo FI(Path);
- Log(("Generate PPP for %s\n", ID.latin1() ));
+ } else if ( SF.name() == "peers" ) {
+
+ QFileInfo FI(SF.path());
+ Log(("Generate PPP for %s\n", SF.name().latin1() ));
- TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/"
+ SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/"
<< FI.baseName()
- << ".chat\""
+ << "\""
<< endl;
@@ -199,3 +213,3 @@ short APPP::generateFile( const QString & ID,
if( Data.IP.GWIsDefault ) {
- TS << "defaultroute"
+ SF << "defaultroute"
<< endl;
@@ -203,4 +217,4 @@ short APPP::generateFile( const QString & ID,
- TS << "linkname "
- << removeSpaces( ID.latin1() )
+ SF << "linkname "
+ << removeSpaces( SF.name().latin1() )
<< endl;
@@ -210,8 +224,8 @@ short APPP::generateFile( const QString & ID,
rvd = connection()->getToplevel()->generateFileEmbedded(
- ID, Path, TS, DevNr );
- } else if ( ID == "chatscripts" ) {
- Log(("Generate PPP for %s\n", ID.latin1() ));
+ SF, DevNr );
+ } else if ( SF.name() == "chatscripts" ) {
+ Log(("Generate PPP for %s\n", SF.name().latin1() ));
rvl = 0;
rvd = connection()->getToplevel()->generateFileEmbedded(
- ID, Path, TS, DevNr );
+ SF, DevNr );
}