Diffstat (limited to 'noncore/settings/networksettings2/ppp/ppprun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/ppp/ppprun.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp index 8933f85..4ac0c5a 100644 --- a/noncore/settings/networksettings2/ppp/ppprun.cpp +++ b/noncore/settings/networksettings2/ppp/ppprun.cpp | |||
@@ -1,77 +1,90 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | #include "ppprun.h" | 2 | #include "ppprun.h" |
3 | 3 | ||
4 | PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) : | ||
5 | AsConnection( NNI ), AsDevice( NNI ), Pat( "eth[0-9]" ) { | ||
6 | D = &Data; | ||
7 | } | ||
8 | |||
4 | void PPPRun::detectState( NodeCollection * NC ) { | 9 | void PPPRun::detectState( NodeCollection * NC ) { |
5 | if( isMyPPPDRunning( ) ) { | 10 | if( isMyPPPDRunning( ) ) { |
6 | if( isMyPPPUp() ) { | 11 | if( isMyPPPUp() ) { |
7 | NC->setCurrentState( IsUp ); | 12 | NC->setCurrentState( IsUp ); |
8 | } else { | 13 | } else { |
9 | NC->setCurrentState( Available ); | 14 | NC->setCurrentState( Available ); |
10 | } | 15 | } |
11 | } else { | 16 | } else { |
12 | NC->setCurrentState( Off ); // at least this | 17 | NC->setCurrentState( Off ); // at least this |
13 | // but could also be unavailable | 18 | // but could also be unavailable |
14 | netNode()->nextNode()->runtime()->detectState( NC ); | 19 | ANetNodeInstance * NNI; |
20 | RuntimeInfo * RI; | ||
21 | NNI = AsDevice::netNode(); | ||
22 | printf( "%p\n", NNI ); | ||
23 | NNI = NNI->nextNode(); | ||
24 | printf( "%p\n", NNI ); | ||
25 | RI = NNI->runtime(); | ||
26 | printf( "%p\n", RI ); | ||
27 | RI->detectState( NC ); | ||
15 | } | 28 | } |
16 | } | 29 | } |
17 | 30 | ||
18 | bool PPPRun::setState( NodeCollection * NC, Action_t A ) { | 31 | bool PPPRun::setState( NodeCollection * NC, Action_t A ) { |
19 | switch( A ) { | 32 | switch( A ) { |
20 | case Activate : | 33 | case Activate : |
21 | NC->setCurrentState( Available ); | 34 | NC->setCurrentState( Available ); |
22 | // no | 35 | // no |
23 | break; | 36 | break; |
24 | case Deactivate : | 37 | case Deactivate : |
25 | if( NC->currentState() == IsUp ) { | 38 | if( NC->currentState() == IsUp ) { |
26 | NC->state( Down ); | 39 | NC->state( Down ); |
27 | } | 40 | } |
28 | // cannot really disable | 41 | // cannot really disable |
29 | NC->setCurrentState( Available ); | 42 | NC->setCurrentState( Available ); |
30 | break; | 43 | break; |
31 | case Up : | 44 | case Up : |
32 | if( NC->currentState() != IsUp ) { | 45 | if( NC->currentState() != IsUp ) { |
33 | // start my PPPD | 46 | // start my PPPD |
34 | NC->setCurrentState( IsUp ); | 47 | NC->setCurrentState( IsUp ); |
35 | } | 48 | } |
36 | break; | 49 | break; |
37 | case Down : | 50 | case Down : |
38 | if( NC->currentState() == IsUp ) { | 51 | if( NC->currentState() == IsUp ) { |
39 | // stop my PPPD | 52 | // stop my PPPD |
40 | NC->setCurrentState( Available ); | 53 | NC->setCurrentState( Available ); |
41 | } | 54 | } |
42 | break; | 55 | break; |
43 | default : // FT | 56 | default : // FT |
44 | break; | 57 | break; |
45 | } | 58 | } |
46 | return 1; | 59 | return 1; |
47 | } | 60 | } |
48 | 61 | ||
49 | bool PPPRun::isMyPPPDRunning( void ) { | 62 | bool PPPRun::isMyPPPDRunning( void ) { |
50 | return 0; | 63 | return 0; |
51 | } | 64 | } |
52 | 65 | ||
53 | bool PPPRun::isMyPPPUp( void ) { | 66 | bool PPPRun::isMyPPPUp( void ) { |
54 | System & S = NSResources->system(); | 67 | System & S = NSResources->system(); |
55 | InterfaceInfo * best = 0, * Run; | 68 | InterfaceInfo * Run; |
56 | QRegExp R( "ppp[0-9]" ); | 69 | QRegExp R( "ppp[0-9]" ); |
57 | 70 | ||
58 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 71 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
59 | It.current(); | 72 | It.current(); |
60 | ++It ) { | 73 | ++It ) { |
61 | Run = It.current(); | 74 | Run = It.current(); |
62 | if( R.match( Run->Name ) >= 0 && | 75 | if( R.match( Run->Name ) >= 0 && |
63 | Run->IsPointToPoint | 76 | Run->IsPointToPoint |
64 | ) { | 77 | ) { |
65 | // this is a LAN card | 78 | // this is a LAN card |
66 | if( Run->assignedNode() == netNode() ) { | 79 | if( Run->assignedNode() == AsDevice::netNode() ) { |
67 | // assigned to us | 80 | // assigned to us |
68 | return 1; | 81 | return 1; |
69 | } | 82 | } |
70 | } | 83 | } |
71 | } | 84 | } |
72 | return 0; | 85 | return 0; |
73 | } | 86 | } |
74 | 87 | ||
75 | bool PPPRun::handlesInterface( const QString & S ) { | 88 | bool PPPRun::handlesInterface( const QString & S ) { |
76 | return Pat.match( S ) >= 0; | 89 | return Pat.match( S ) >= 0; |
77 | } | 90 | } |