author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (unidiff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/network/networkrun.cpp | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2 |
CONTROL files : changed version string
NS2 many changes and first release of OT2
Diffstat (limited to 'noncore/settings/networksettings2/network/networkrun.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/network/networkrun.cpp | 89 |
1 files changed, 31 insertions, 58 deletions
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index 3e24c5f..c17aa7f 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp | |||
@@ -1,26 +1,24 @@ | |||
1 | #include <system.h> | 1 | #include <system.h> |
2 | #include <asdevice.h> | 2 | #include <netnode.h> |
3 | #include <resources.h> | ||
3 | #include "networkrun.h" | 4 | #include "networkrun.h" |
4 | 5 | ||
5 | void NetworkRun::detectState( NodeCollection * NC ) { | 6 | State_t NetworkRun::detectState( void ) { |
6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 7 | InterfaceInfo * II = nodeCollection()->assignedInterface(); |
7 | AsDevice * Next = RI->asDevice(); | ||
8 | InterfaceInfo * II = Next->assignedInterface(); | ||
9 | 8 | ||
10 | if( II ) { | 9 | Log(( "Interface %p : %d\n", II, (II) ? II->IsUp : 0 )); |
10 | if( II && II->IsUp ) { | ||
11 | // device has assigned interface | 11 | // device has assigned interface |
12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); | 12 | return IsUp; |
13 | return; | ||
14 | } | 13 | } |
15 | 14 | ||
16 | Log(( "%s not ! UP or ava\n", NC->name().latin1() )); | 15 | // had no interface or interface is no longer up -> release |
17 | // has no interface -> delegate | 16 | nodeCollection()->assignInterface( 0 ); |
18 | RI->detectState( NC ); | 17 | |
18 | return Unknown; | ||
19 | } | 19 | } |
20 | 20 | ||
21 | bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { | 21 | QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) { |
22 | // we handle UP and DOWN | 22 | // we handle UP and DOWN |
23 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 23 | InterfaceInfo * II = NC->assignedInterface(); |
24 | AsDevice * Next = RI->asDevice(); | ||
25 | InterfaceInfo * II = Next->assignedInterface(); | ||
26 | 24 | ||
@@ -28,51 +26,26 @@ bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { | |||
28 | // we can bring UP if lower level is available | 26 | // we can bring UP if lower level is available |
29 | if( NC->currentState() == Available || Force ) { | 27 | QStringList SL; |
30 | QString S; | 28 | SL << "ifup" |
31 | S.sprintf( "ifup %s=%s-c%d-allowed", | 29 | << QString().sprintf( "%s=%s-c%d-allowed", |
32 | II->Name.latin1(), II->Name.latin1(), | ||
33 | connection()->number() ); | ||
34 | NSResources->system().runAsRoot( S ); | ||
35 | } | ||
36 | return 1; | ||
37 | } else if( A == Down ) { | ||
38 | QString S; | ||
39 | if( Force ) { | ||
40 | Log(("Force mode %d\n", Force )); | ||
41 | for( int i = 0; | ||
42 | i < RI->netNode()->nodeClass()->instanceCount(); | ||
43 | i ++ ) { | ||
44 | S.sprintf( "ifdown %s", | ||
45 | RI->netNode()->nodeClass()->genNic( i ).latin1() ); | ||
46 | NSResources->system().runAsRoot( S ); | ||
47 | } | ||
48 | } else { | ||
49 | if( NC->currentState() == IsUp ) { | ||
50 | S.sprintf( "ifdown %s=%s-c%d-allowed", | ||
51 | II->Name.latin1(), II->Name.latin1(), | 30 | II->Name.latin1(), II->Name.latin1(), |
52 | connection()->number() ); | 31 | nodeCollection()->number() ); |
53 | NSResources->system().runAsRoot( S ); | 32 | if( ! NSResources->system().runAsRoot( SL ) ) { |
54 | } | 33 | return QString("Cannot call %1").arg(SL.join(" ")); |
55 | } | ||
56 | return 1; | ||
57 | } | 34 | } |
58 | // delegate | 35 | return QString(); |
59 | return RI->setState( NC, A, Force ); | ||
60 | } | 36 | } |
61 | 37 | ||
62 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { | 38 | if( A == Down ) { |
63 | // we handle UP and DOWN | 39 | QStringList SL; |
64 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 40 | if( II ) { |
65 | 41 | SL << "ifdown" | |
66 | if( A == Up ) { | 42 | << II->Name.latin1(); |
67 | return ( Curr == Available ); | 43 | if( ! NSResources->system().runAsRoot( SL ) ) { |
68 | } else if( A == Down ) { | 44 | return QString( "Cannot call %1" ).arg( SL.join( " " )); |
69 | return ( Curr == IsUp ); | ||
70 | } | 45 | } |
71 | // delegate | 46 | } else { |
72 | return RI->canSetState( Curr, A ); | 47 | Log(( "no interface assigned." )); |
73 | } | 48 | } |
74 | 49 | } | |
75 | bool NetworkRun::handlesInterface( const QString & S ) { | 50 | return QString(); |
76 | // donno -> pass deeper | ||
77 | return netNode()->nextNode()->runtime()->handlesInterface(S); | ||
78 | } | 51 | } |