summaryrefslogtreecommitdiff
path: root/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
blob: b010ac5adc1ac7adccc6fd8102d31c7a19f6220d (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
#include <opie2/onetwork.h>

int main( int argc, char** argv )
{
    qDebug( "OPIE Network Demo" );

    ONetwork* net = ONetwork::instance();

    ONetwork::InterfaceIterator it = net->iterator();

    while ( it.current() )
    {
        qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() );
        qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() );
        qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() );
        if ( it.current()->isWireless() )
        {
            OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() );
            qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() );
            qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() );
            qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() );
            qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() );

            //if ( iface->mode() == OWirelessNetworkInterface::adhoc )
            //{
                qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() );
            //}

            // try to set monitor mode

            // first some wrong calls to check if this is working
            iface->setPrivate( "seppel", 10 );
            iface->setPrivate( "monitor", 0 );

            // now the real deal
            iface->setPrivate( "monitor", 2, 2, 3 );
        }
        ++it;
    }

    return 0;

}