blob: 2c93d9dff6ea488cd3493b999ff4c0cb3da66d24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <system.h>
#include <netnode.h>
#include <resources.h>
#include "networkrun.h"
State_t NetworkRun::detectState( void ) {
InterfaceInfo * II = nodeCollection()->assignedInterface();
Log(( "Interface %p : %d\n", II, (II) ? II->IsUp : 0 ));
if( II && II->IsUp ) {
// device has assigned interface
return IsUp;
}
// had no interface or interface is no longer up -> release
nodeCollection()->assignInterface( 0 );
return Unknown;
}
QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
// we handle UP and DOWN
InterfaceInfo * II = NC->assignedInterface();
if( ! II ) {
Log(( "no interface assigned." ));
return QString();
}
QStringList SL;
if( A == Up ) {
// we can bring UP if lower level is available
SL << "ifup";
} else if( A == Down ) {
SL << "ifdown";
} else {
return QString();
}
SL << QString().sprintf( "%s=%s-c%d-allowed",
II->Name.latin1(), II->Name.latin1(),
nodeCollection()->number() );
if( ! NSResources->system().runAsRoot( SL ) ) {
return QString("Cannot call %1").arg(SL.join(" "));
}
return QString();
}
|