src/adapters/net_iw.cpp
/**
   * Query for device driver quality values
   */
Query for device driver quality values
Query for device driver quality values
void wireless_network::query_quality(const int& socket_fd) {
    iwrange range{};
    iwstats stats{};
    if (iw_get_range_info(socket_fd, m_interface.c_str(), &range) == -1) {
      return;
    }
    if (iw_get_stats(socket_fd, m_interface.c_str(), &stats, &range, 1) == -1) {
      return;
    }
    if (stats.qual.updated & IW_QUAL_QUAL_INVALID) {
      return;
    }
    if (stats.qual.updated & IW_QUAL_LEVEL_INVALID) {
      return;
    }
    if (stats.qual.updated & IW_QUAL_QUAL_UPDATED) {
      m_linkquality.val = stats.qual.qual;
      m_linkquality.max = range.max_qual.qual;
    }
    if (stats.qual.updated & IW_QUAL_LEVEL_UPDATED) {
      m_signalstrength.val = stats.qual.level;
      m_signalstrength.max = range.max_qual.level;
      if (stats.qual.level > range.max_qual.level) {
        m_signalstrength.val -= 0x100;
        m_signalstrength.max = (stats.qual.level - range.max_qual.level) - 0x100;
      }
    }
  }
void wireless_network :: query_quality ( const int & socket_fd ) { iwrange range { } ; iwstats stats { } ; if ( iw_get_range_info ( socket_fd , m_interface . c_str ( ) , & range ) == -1 ) { return ; } if ( iw_get_stats ( socket_fd , m_interface . c_str ( ) , & stats , & range , 1 ) == -1 ) { return ; } if ( stats . qual . updated & IW_QUAL_QUAL_INVALID ) { return ; } if ( stats . qual . updated & IW_QUAL_LEVEL_INVALID ) { return ; } if ( stats . qual . updated & IW_QUAL_QUAL_UPDATED ) { m_linkquality . val = stats . qual . qual ; m_linkquality . max = range . max_qual . qual ; } if ( stats . qual . updated & IW_QUAL_LEVEL_UPDATED ) { m_signalstrength . val = stats . qual . level ; m_signalstrength . max = range . max_qual . level ; if ( stats . qual . level > range . max_qual . level ) { m_signalstrength . val -= 0x100 ; m_signalstrength . max = ( stats . qual . level - range . max_qual . level ) - 0x100 ; } } }
Query for device driver quality values
Query for device driver quality values
// Fill range // Fill stats // Check if the driver supplies the quality value // Check if the driver supplies the quality level value // Check if the link quality has been updated // Check if the signal strength has been updated // Check if the values are defined in dBm