summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
Unidiff
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 05513f8..1deb051 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -20,56 +20,58 @@
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* OPIE */ 31/* OPIE */
32
33#include <opie2/onetwork.h> 32#include <opie2/onetwork.h>
34#include <opie2/ostation.h> 33#include <opie2/ostation.h>
35#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35using namespace Opie::Core;
36 36
37/* QT */ 37/* QT */
38
39#include <qfile.h> 38#include <qfile.h>
40#include <qtextstream.h> 39#include <qtextstream.h>
41#include <qapplication.h> 40#include <qapplication.h>
42 41
43/* UNIX */ 42/* STD */
44
45#include <assert.h> 43#include <assert.h>
46#include <arpa/inet.h> 44#include <arpa/inet.h>
47#include <errno.h> 45#include <errno.h>
46#include <stdarg.h>
48#include <string.h> 47#include <string.h>
49#include <stdlib.h> 48#include <stdlib.h>
50#include <math.h> 49#include <math.h>
50#include <unistd.h>
51#include <net/if_arp.h>
52#include <net/ethernet.h>
51#include <sys/ioctl.h> 53#include <sys/ioctl.h>
52#include <sys/socket.h> 54#include <sys/socket.h>
53#include <sys/types.h> 55#include <sys/types.h>
54#include <unistd.h> 56#include <linux/types.h>
55#include <linux/sockios.h> 57#include <linux/sockios.h>
56#include <net/if_arp.h> 58#define u64 __u64
57#include <net/ethernet.h> 59#define u32 __u32
58#include <stdarg.h> 60#define u16 __u16
61#define u8 __u8
62#include <linux/ethtool.h>
59 63
60#ifndef NODEBUG 64#ifndef NODEBUG
61#include <opie2/odebugmapper.h> 65#include <opie2/odebugmapper.h>
62
63using namespace Opie::Core;
64using namespace Opie::Net::Internal; 66using namespace Opie::Net::Internal;
65DebugMapper* debugmapper = new DebugMapper(); 67DebugMapper* debugmapper = new DebugMapper();
66#endif 68#endif
67 69
68/*====================================================================================== 70/*======================================================================================
69 * ONetwork 71 * ONetwork
70 *======================================================================================*/ 72 *======================================================================================*/
71 73
72namespace Opie { 74namespace Opie {
73namespace Net { 75namespace Net {
74ONetwork* ONetwork::_instance = 0; 76ONetwork* ONetwork::_instance = 0;
75 77
@@ -372,48 +374,57 @@ bool ONetworkInterface::promiscuousMode() const
372{ 374{
373 ioctl( SIOCGIFFLAGS ); 375 ioctl( SIOCGIFFLAGS );
374 return _ifr.ifr_flags & IFF_PROMISC; 376 return _ifr.ifr_flags & IFF_PROMISC;
375} 377}
376 378
377 379
378bool ONetworkInterface::isWireless() const 380bool ONetworkInterface::isWireless() const
379{ 381{
380 return ioctl( SIOCGIWNAME ); 382 return ioctl( SIOCGIWNAME );
381} 383}
382 384
383 385
386ONetworkInterfaceDriverInfo ONetworkInterface::driverInfo() const
387{
388 struct ethtool_drvinfo info;
389 info.cmd = ETHTOOL_GDRVINFO;
390 _ifr.ifr_data = (caddr_t) &info;
391 return ioctl( SIOCETHTOOL ) ? ONetworkInterfaceDriverInfo( info.driver, info.version, info.fw_version, info.bus_info) : ONetworkInterfaceDriverInfo();
392}
393
384/*====================================================================================== 394/*======================================================================================
385 * OChannelHopper 395 * OChannelHopper
386 *======================================================================================*/ 396 *======================================================================================*/
387 397
388OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) 398OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
389 :QObject( 0, "Mickey's funky hopper" ), 399 :QObject( 0, "Mickey's funky hopper" ),
390 _iface( iface ), _interval( 0 ), _tid( 0 ) 400 _iface( iface ), _interval( 0 ), _tid( 0 )
391{ 401{
392 int _maxChannel = iface->channels(); 402 int _maxChannel = iface->channels();
393 // generate fancy hopping sequence honoring the device capabilities 403 // generate fancy hopping sequence honoring the device capabilities
394 if ( _maxChannel >= 1 ) _channels.append( 1 ); 404 if ( _maxChannel >= 1 ) _channels.append( 1 );
395 if ( _maxChannel >= 7 ) _channels.append( 7 ); 405 if ( _maxChannel >= 7 ) _channels.append( 7 );
396 if ( _maxChannel >= 13 ) _channels.append( 13 ); 406 if ( _maxChannel >= 13 ) _channels.append( 13 );
397 if ( _maxChannel >= 2 ) _channels.append( 2 ); 407 if ( _maxChannel >= 2 ) _channels.append( 2 );
398 if ( _maxChannel >= 8 ) _channels.append( 8 ); 408 if ( _maxChannel >= 8 ) _channels.append( 8 );
399 if ( _maxChannel >= 3 ) _channels.append( 3 ); 409 if ( _maxChannel >= 3 ) _channels.append( 3 );
400 if ( _maxChannel >= 14 ) _channels.append( 14 ); 410 if ( _maxChannel >= 14 ) _channels.append( 14 );
401 if ( _maxChannel >= 9 ) _channels.append( 9 ); 411 if ( _maxChannel >= 9 ) _channels.append( 9 );
402 if ( _maxChannel >= 4 ) _channels.append( 4 ); 412 if ( _maxChannel >= 4 ) _channels.append( 4 );
403 if ( _maxChannel >= 10 ) _channels.append( 10 ); 413 if ( _maxChannel >= 10 ) _channels.append( 10 );
404 if ( _maxChannel >= 5 ) _channels.append( 5 ); 414 if ( _maxChannel >= 5 ) _channels.append( 5 );
405 if ( _maxChannel >= 11 ) _channels.append( 11 ); 415 if ( _maxChannel >= 11 ) _channels.append( 11 );
406 if ( _maxChannel >= 6 ) _channels.append( 6 ); 416 if ( _maxChannel >= 6 ) _channels.append( 6 );
407 if ( _maxChannel >= 12 ) _channels.append( 12 ); 417 if ( _maxChannel >= 12 ) _channels.append( 12 );
418 //FIXME: Add 802.11a/g channels
408 _channel = _channels.begin(); 419 _channel = _channels.begin();
409} 420}
410 421
411 422
412OChannelHopper::~OChannelHopper() 423OChannelHopper::~OChannelHopper()
413{ 424{
414} 425}
415 426
416 427
417bool OChannelHopper::isActive() const 428bool OChannelHopper::isActive() const
418{ 429{
419 return _tid; 430 return _tid;