Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/network/network_NNI.cpp | 47 | ||||
-rw-r--r-- | noncore/settings/networksettings2/network/networkrun.cpp | 4 |
2 files changed, 36 insertions, 15 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 | ||
93 | QString ANetwork::acceptable( void ) { | 93 | QString ANetwork::acceptable( void ) { |
94 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 94 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
95 | } | 95 | } |
96 | 96 | ||
97 | void ANetwork::commit( void ) { | 97 | void 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 | ||
102 | bool ANetwork::hasDataFor( const QString & S ) { | 102 | bool ANetwork::hasDataFor( const QString & S ) { |
103 | return S == "interfaces"; | 103 | return S == "interfaces"; |
104 | } | 104 | } |
105 | 105 | ||
106 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 106 | bool 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(); |
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index ddb9a5f..c19235a 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp | |||
@@ -9,58 +9,58 @@ void NetworkRun::detectState( NodeCollection * NC ) { | |||
9 | 9 | ||
10 | if( II ) { | 10 | if( II ) { |
11 | // device has assigned interface | 11 | // device has assigned interface |
12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); | 12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); |
13 | return; | 13 | return; |
14 | } | 14 | } |
15 | 15 | ||
16 | // has no interface -> delegate | 16 | // has no interface -> delegate |
17 | RI->detectState( NC ); | 17 | RI->detectState( NC ); |
18 | } | 18 | } |
19 | 19 | ||
20 | bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { | 20 | bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { |
21 | // we handle UP and DOWN | 21 | // we handle UP and DOWN |
22 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 22 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
23 | AsDevice * Next = RI->asDevice(); | 23 | AsDevice * Next = RI->asDevice(); |
24 | InterfaceInfo * II = Next->assignedInterface(); | 24 | InterfaceInfo * II = Next->assignedInterface(); |
25 | 25 | ||
26 | if( A == Up ) { | 26 | if( A == Up ) { |
27 | // we can bring UP if lower level is available | 27 | // we can bring UP if lower level is available |
28 | if( NC->currentState() == Available ) { | 28 | if( NC->currentState() == Available ) { |
29 | QString S; | 29 | QString S; |
30 | S.sprintf( "ifup %s=%s-c%d-allowed", | 30 | S.sprintf( "ifup %s=%s-c%d-allowed", |
31 | II->Name.latin1(), II->Name.latin1(), | 31 | II->Name.latin1(), II->Name.latin1(), |
32 | connection()->number() ); | 32 | connection()->number() ); |
33 | NSResources->system().execute( S ); | 33 | NSResources->system().runAsRoot( S ); |
34 | } | 34 | } |
35 | return 1; | 35 | return 1; |
36 | } else if( A == Down ) { | 36 | } else if( A == Down ) { |
37 | if( NC->currentState() == IsUp ) { | 37 | if( NC->currentState() == IsUp ) { |
38 | QString S; | 38 | QString S; |
39 | S.sprintf( "ifdown %s=%s-c%d-allowed", | 39 | S.sprintf( "ifdown %s=%s-c%d-allowed", |
40 | II->Name.latin1(), II->Name.latin1(), | 40 | II->Name.latin1(), II->Name.latin1(), |
41 | connection()->number() ); | 41 | connection()->number() ); |
42 | NSResources->system().execute( S ); | 42 | NSResources->system().runAsRoot( S ); |
43 | } | 43 | } |
44 | return 1; | 44 | return 1; |
45 | } | 45 | } |
46 | // delegate | 46 | // delegate |
47 | return RI->setState( NC, A ); | 47 | return RI->setState( NC, A ); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { | 50 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { |
51 | // we handle UP and DOWN | 51 | // we handle UP and DOWN |
52 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 52 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
53 | 53 | ||
54 | if( A == Up ) { | 54 | if( A == Up ) { |
55 | return ( Curr == Available ); | 55 | return ( Curr == Available ); |
56 | } else if( A == Down ) { | 56 | } else if( A == Down ) { |
57 | return ( Curr == IsUp ); | 57 | return ( Curr == IsUp ); |
58 | } | 58 | } |
59 | // delegate | 59 | // delegate |
60 | return RI->canSetState( Curr, A ); | 60 | return RI->canSetState( Curr, A ); |
61 | } | 61 | } |
62 | 62 | ||
63 | bool NetworkRun::handlesInterface( const QString & S ) { | 63 | bool NetworkRun::handlesInterface( const QString & S ) { |
64 | // donno -> pass deeper | 64 | // donno -> pass deeper |
65 | return netNode()->nextNode()->runtime()->handlesInterface(S); | 65 | return netNode()->nextNode()->runtime()->handlesInterface(S); |
66 | } | 66 | } |