00001 /* 00002 =. This file is part of the Opie Project 00003 .=l. Copyright (C) 2004 Opie Team <opie-devel@handhelds.org> 00004 .>+-= 00005 _;:, .> :=|. This library is free software; you can 00006 .> <`_, > . <= redistribute it and/or modify it under 00007 :`=1 )Y*s>-.-- : the terms of the GNU Library General Public 00008 .="- .-=="i, .._ License as published by the Free Software 00009 - . .-<_> .<> Foundation; either version 2 of the License, 00010 ._= =} : or (at your option) any later version. 00011 .%`+i> _;_. 00012 .i_,=:_. -<s. This library is distributed in the hope that 00013 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 00014 : .. .:, . . . without even the implied warranty of 00015 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 00016 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 00017 ..}^=.= = ; Library General Public License for more 00018 ++= -. .` .: details. 00019 : = ...= . :.=- 00020 -. .:....=;==+<; You should have received a copy of the GNU 00021 -_. . . )=. = Library General Public License along with 00022 -- :-=` this library; see the file COPYING.LIB. 00023 If not, write to the Free Software Foundation, 00024 Inc., 59 Temple Place - Suite 330, 00025 Boston, MA 02111-1307, USA. 00026 00027 */ 00028 00029 /* OPIE */ 00030 #include <opie2/onetwork.h> 00031 #include <opie2/ostation.h> 00032 #include <opie2/omanufacturerdb.h> 00033 #include <opie2/odebug.h> 00034 00035 /* STD */ 00036 #include <unistd.h> 00037 00038 using namespace Opie::Net; 00039 00040 int main( int argc, char** argv ) 00041 { 00042 odebug << "OPIE Network Demo" << oendl; 00043 00044 ONetwork* net = ONetwork::instance(); 00045 00046 ONetwork::InterfaceIterator it = net->iterator(); 00047 00048 while ( it.current() ) 00049 { 00050 odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; 00051 ONetworkInterfaceDriverInfo info = it.current()->driverInfo(); 00052 odebug << "DEMO: DriverName reported as '" << info.name() << "'" << oendl; 00053 odebug << "DEMO: DriverVersion reported as '" << info.version() << "'" << oendl; 00054 odebug << "DEMO: DriverFirmware reported as '" << info.firmware() << "'" << oendl; 00055 odebug << "DEMO: DriverBus reported as '" << info.bus() << "'" << oendl; 00056 odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; 00057 odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; 00058 odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; 00059 odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; 00060 odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; 00061 odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; 00062 odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address().toString() << "'" << oendl; 00063 if ( it.current()->isWireless() ) 00064 { 00065 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); 00066 odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; 00067 odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; 00068 odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; 00069 00070 //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) 00071 //{ 00072 //odebug << "DEMO: Associated AP has MAC Address '" << iface->associatedAP().toString() << "'" << oendl; 00073 //} 00074 00075 /* 00076 00077 // nickname 00078 odebug << "DEMO: Current NickName is '" << iface->nickName() << "'" << oendl; 00079 iface->setNickName( "MyNickName" ); 00080 if ( iface->nickName() != "MyNickName" ) 00081 odebug << "DEMO: Warning! Can't change nickname" << oendl; 00082 else 00083 odebug << "DEMO: Nickname change successful." << oendl; 00084 00085 /* 00086 00087 // operation mode 00088 odebug << "DEMO: Current OperationMode is '" << iface->mode() << "'" << oendl; 00089 iface->setMode( "adhoc" ); 00090 if ( iface->mode() != "adhoc" ) 00091 odebug << "DEMO: Warning! Can't change operation mode" << oendl; 00092 else 00093 odebug << "DEMO: Operation Mode change successful." << oendl; 00094 00095 // RF channel 00096 odebug << "DEMO: Current Channel is '" << iface->channel() << "'" << oendl; 00097 iface->setChannel( 1 ); 00098 if ( iface->channel() != 1 ) 00099 odebug << "DEMO: Warning! Can't change RF channel" << oendl; 00100 else 00101 odebug << "DEMO: RF channel change successful." << oendl; 00102 00103 iface->setMode( "managed" ); 00104 00105 */ 00106 00107 /* 00108 00109 // network scan 00110 00111 OStationList* stations = iface->scanNetwork(); 00112 if ( stations ) 00113 { 00114 odebug << "DEMO: # of stations around = " << stations->count() << "" << oendl; 00115 OStation* station; 00116 for ( station = stations->first(); station != 0; station = stations->next() ) 00117 { 00118 odebug << "DEMO: station dump following..." << oendl; 00119 station->dump(); 00120 } 00121 } 00122 00123 else 00124 { 00125 odebug << "DEMO: Warning! Scan didn't work!" << oendl; 00126 } 00127 00128 /* 00129 00130 // first some wrong calls to check if this is working 00131 iface->setPrivate( "seppel", 10 ); 00132 iface->setPrivate( "monitor", 0 ); 00133 00134 // now the real deal 00135 iface->setPrivate( "monitor", 2, 2, 3 ); 00136 00137 // trying to set hw address to 12:34:56:AB:CD:EF 00138 00139 /* 00140 00141 OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); 00142 iface->setUp( false ); 00143 iface->setMacAddress( addr ); 00144 iface->setUp( true ); 00145 odebug << "DEMO: MAC Address now is '" << iface->macAddress().toString() << "'" << oendl; 00146 00147 */ 00148 00149 // monitor test 00150 00151 00152 00153 odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; 00154 iface->setMode( "monitor" ); 00155 odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; 00156 00157 sleep( 1 ); 00158 00159 iface->setChannel( 1 ); 00160 iface->setMode( "managed" ); 00161 00162 //sleep( 1 ); 00163 odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; 00164 00165 /*iface->setMode( "adhoc" ); 00166 sleep( 1 ); 00167 odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; 00168 iface->setMode( "managed" ); 00169 sleep( 1 ); 00170 odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; 00171 iface->setMode( "master" ); 00172 sleep( 1 ); 00173 odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; */ 00174 00175 } 00176 ++it; 00177 } 00178 00179 return 0; 00180 00181 }
1.4.2