summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index f4bdbe0..05513f8 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -524,27 +524,26 @@ void OWirelessNetworkInterface::buildInformation()
524 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate 524 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate
525 //ML: _too much_ space. This is damn shitty crap *sigh* 525 //ML: _too much_ space. This is damn shitty crap *sigh*
526 //ML: We allocate a large memory region in RAM and check whether the 526 //ML: We allocate a large memory region in RAM and check whether the
527 //ML: driver pollutes this extra space. The complaint will be made on stdout, 527 //ML: driver pollutes this extra space. The complaint will be made on stdout,
528 //ML: so please forward this... 528 //ML: so please forward this...
529 529
530 struct iwreq wrq; 530 struct iwreq wrq;
531 int len = sizeof( struct iw_range )*2; 531 int len = sizeof( struct iw_range )*2;
532 char *buffer = (char*) malloc( len ); 532 char buffer[len];
533 //FIXME: Validate if we actually got the memory block
534 memset( buffer, 0, len ); 533 memset( buffer, 0, len );
535 memcpy( wrq.ifr_name, name(), IFNAMSIZ); 534 memcpy( wrq.ifr_name, name(), IFNAMSIZ);
536 wrq.u.data.pointer = (caddr_t) buffer; 535 wrq.u.data.pointer = (caddr_t) buffer;
537 wrq.u.data.length = sizeof( struct iw_range ); 536 wrq.u.data.length = sizeof buffer;
538 wrq.u.data.flags = 0; 537 wrq.u.data.flags = 0;
539 538
540 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) 539 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 )
541 { 540 {
542 owarn << "OWirelessNetworkInterface::buildInformation(): Can't get channel information - using default values." << oendl; 541 owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl;
543 _channels.insert( 2412, 1 ); // 2.412 GHz 542 _channels.insert( 2412, 1 ); // 2.412 GHz
544 _channels.insert( 2417, 2 ); // 2.417 GHz 543 _channels.insert( 2417, 2 ); // 2.417 GHz
545 _channels.insert( 2422, 3 ); // 2.422 GHz 544 _channels.insert( 2422, 3 ); // 2.422 GHz
546 _channels.insert( 2427, 4 ); // 2.427 GHz 545 _channels.insert( 2427, 4 ); // 2.427 GHz
547 _channels.insert( 2432, 5 ); // 2.432 GHz 546 _channels.insert( 2432, 5 ); // 2.432 GHz
548 _channels.insert( 2437, 6 ); // 2.437 GHz 547 _channels.insert( 2437, 6 ); // 2.437 GHz
549 _channels.insert( 2442, 7 ); // 2.442 GHz 548 _channels.insert( 2442, 7 ); // 2.442 GHz
550 _channels.insert( 2447, 8 ); // 2.447 GHz 549 _channels.insert( 2447, 8 ); // 2.447 GHz
@@ -577,17 +576,16 @@ void OWirelessNetworkInterface::buildInformation()
577 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); 576 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
578 odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; 577 odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl;
579 _channels.insert( freq, i+1 ); 578 _channels.insert( freq, i+1 );
580 } 579 }
581 } 580 }
582 581
583 memcpy( &_range, buffer, sizeof( struct iw_range ) ); 582 memcpy( &_range, buffer, sizeof( struct iw_range ) );
584 odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; 583 odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl;
585 free(buffer);
586} 584}
587 585
588 586
589short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const 587short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const
590{ 588{
591 return _range.we_version_compiled; 589 return _range.we_version_compiled;
592} 590}
593 591
@@ -599,17 +597,17 @@ void OWirelessNetworkInterface::buildPrivateList()
599 struct iw_priv_args priv[IW_MAX_PRIV_DEF]; 597 struct iw_priv_args priv[IW_MAX_PRIV_DEF];
600 598
601 _iwr.u.data.pointer = (char*) &priv; 599 _iwr.u.data.pointer = (char*) &priv;
602 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself 600 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself
603 _iwr.u.data.flags = 0; 601 _iwr.u.data.flags = 0;
604 602
605 if ( !wioctl( SIOCGIWPRIV ) ) 603 if ( !wioctl( SIOCGIWPRIV ) )
606 { 604 {
607 owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information." << oendl; 605 owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information (" << strerror( errno ) << ")." << oendl;
608 return; 606 return;
609 } 607 }
610 608
611 for ( int i = 0; i < _iwr.u.data.length; ++i ) 609 for ( int i = 0; i < _iwr.u.data.length; ++i )
612 { 610 {
613 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); 611 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
614 } 612 }
615 odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; 613 odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl;
@@ -1153,23 +1151,23 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
1153 odebug << "SIOCGIWESSID" << oendl; 1151 odebug << "SIOCGIWESSID" << oendl;
1154 we->u.essid.length = '\0'; // make sure it is zero terminated 1152 we->u.essid.length = '\0'; // make sure it is zero terminated
1155 stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer); 1153 stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer);
1156 odebug << "ESSID: " << stations->last()->ssid << oendl; 1154 odebug << "ESSID: " << stations->last()->ssid << oendl;
1157 break; 1155 break;
1158 } 1156 }
1159 case IWEVQUAL: 1157 case IWEVQUAL:
1160 { 1158 {
1161 odebug << "IWEVQUAL" << oendl; 1159 odebug << "IWEVQUAL" << oendl;
1162 stations->last()->level = static_cast<int>(we->u.qual.level); 1160 stations->last()->level = static_cast<int>(we->u.qual.level);
1163 break; /* Quality part of statistics (scan) */ 1161 break; /* Quality part of statistics (scan) */
1164 } 1162 }
1165 case SIOCGIWENCODE: 1163 case SIOCGIWENCODE:
1166 { 1164 {
1167 odebug << "SIOCGIWENCODE" << oendl; 1165 odebug << "SIOCGIWENCODE" << oendl;
1168 stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED); 1166 stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED);
1169 break; 1167 break;
1170 } 1168 }
1171 1169
1172 case SIOCGIWRATE: 1170 case SIOCGIWRATE:
1173 { 1171 {
1174 odebug << "SIOCGIWRATE" << oendl; 1172 odebug << "SIOCGIWRATE" << oendl;
1175 stations->last()->rates.append(we->u.bitrate.value); 1173 stations->last()->rates.append(we->u.bitrate.value);