summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/network/network_NNI.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/network/network_NNI.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp47
1 files changed, 34 insertions, 13 deletions
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 054385a..3e368a2 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -88,65 +88,86 @@ QWidget * ANetwork::edit( QWidget * parent ) {
88 GUI = new NetworkEdit( parent ); 88 GUI = new NetworkEdit( parent );
89 GUI->showData( Data ); 89 GUI->showData( Data );
90 return GUI; 90 return GUI;
91} 91}
92 92
93QString ANetwork::acceptable( void ) { 93QString ANetwork::acceptable( void ) {
94 return ( GUI ) ? GUI->acceptable( ) : QString(); 94 return ( GUI ) ? GUI->acceptable( ) : QString();
95} 95}
96 96
97void ANetwork::commit( void ) { 97void ANetwork::commit( void ) {
98 if( GUI && GUI->commit( Data ) ) 98 if( GUI && GUI->commit( Data ) )
99 setModified( 1 ); 99 setModified( 1 );
100} 100}
101 101
102bool ANetwork::hasDataFor( const QString & S ) { 102bool ANetwork::hasDataFor( const QString & S ) {
103 return S == "interfaces"; 103 return S == "interfaces";
104} 104}
105 105
106bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { 106bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
107 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 107 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
108 108
109 if( S.name() == "interfaces" ) { 109 if( S.name() == "interfaces" ) {
110 // we can safely call from here since device item is deeper 110 // we can safely call from here since device item is deeper
111 if( Data.UseDHCP ) { 111 if( Data.UseDHCP ) {
112 S << "iface " << NIC << "-c" << connection()->number() << 112 S << "iface "
113 "-allowed inet dhcp" << endl; 113 << NIC
114 S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << 114 << "-c"
115 ".up" << Data.IPAddress << endl; 115 << connection()->number()
116 << "-allowed inet dhcp"
117 << endl;
118 S << " up echo \""
119 << NIC
120 << "\" > /tmp/profile-"
121 << connection()->number()
122 << ".up"
123 << endl;
116 if( Data.SendHostname ) { 124 if( Data.SendHostname ) {
117 S << " hostname "<< Data.Hostname << endl; 125 S << " hostname "
126 << Data.Hostname
127 << endl;
118 } 128 }
119 129
120 S << " down rm -f /tmp/profile-" << connection()->number() << 130 S << " down rm -f /tmp/profile-"
121 ".up" << Data.IPAddress << endl; 131 << connection()->number()
132 << ".up"
133 << endl;
122 } else { 134 } else {
123 S << "iface " << NIC << "-c" << connection()->number() << 135 S << "iface "
124 "-allowed inet static" << endl; 136 << NIC << "-c"
125 S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << 137 << connection()->number()
126 ".up" << Data.IPAddress << endl; 138 << "-allowed inet static"
127 S << " down rm -f /tmp/profile-" << connection()->number() << 139 << endl;
128 ".up" << Data.IPAddress << endl; 140 S << " up echo \""
141 << NIC
142 << "\" > /tmp/profile-"
143 << connection()->number()
144 << ".up"
145 << endl;
146 S << " down rm -f /tmp/profile-"
147 << connection()->number()
148 << ".up"
149 << endl;
129 S << " address " << Data.IPAddress << endl; 150 S << " address " << Data.IPAddress << endl;
130 S << " broadcast " << Data.Broadcast << endl; 151 S << " broadcast " << Data.Broadcast << endl;
131 S << " netmask " << Data.NetMask << endl; 152 S << " netmask " << Data.NetMask << endl;
132 153
133 // derive network address = IPAddress & netmask 154 // derive network address = IPAddress & netmask
134 { QString NW; 155 { QString NW;
135 QStringList ipal = QStringList::split( '.', Data.IPAddress ); 156 QStringList ipal = QStringList::split( '.', Data.IPAddress );
136 QStringList nmal = QStringList::split( '.', Data.NetMask ); 157 QStringList nmal = QStringList::split( '.', Data.NetMask );
137 158
138 NW = QString( "%1.%2.%3.%4" ). 159 NW = QString( "%1.%2.%3.%4" ).
139 arg( ipal[0].toShort() & nmal[0].toShort() ). 160 arg( ipal[0].toShort() & nmal[0].toShort() ).
140 arg( ipal[1].toShort() & nmal[1].toShort() ). 161 arg( ipal[1].toShort() & nmal[1].toShort() ).
141 arg( ipal[2].toShort() & nmal[2].toShort() ). 162 arg( ipal[2].toShort() & nmal[2].toShort() ).
142 arg( ipal[3].toShort() & nmal[3].toShort() ); 163 arg( ipal[3].toShort() & nmal[3].toShort() );
143 S << " network " << NW << endl; 164 S << " network " << NW << endl;
144 } 165 }
145 } 166 }
146 for ( QStringList::Iterator it = Data.PreUp_SL.begin(); 167 for ( QStringList::Iterator it = Data.PreUp_SL.begin();
147 it != Data.PreUp_SL.end(); 168 it != Data.PreUp_SL.end();
148 ++it ) { 169 ++it ) {
149 S << " pre-up " << (*it) << endl; 170 S << " pre-up " << (*it) << endl;
150 } 171 }
151 for ( QStringList::Iterator it = Data.PostUp_SL.begin(); 172 for ( QStringList::Iterator it = Data.PostUp_SL.begin();
152 it != Data.PostUp_SL.end(); 173 it != Data.PostUp_SL.end();