LCOV - code coverage report
Current view: top level - src/ap - bss_load.c (source / functions) Hit Total Coverage
Test: wpa_supplicant/hostapd combined for hwsim test run 1443382998 Lines: 22 26 84.6 %
Date: 2015-09-27 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :  * BSS Load Element / Channel Utilization
       3             :  * Copyright (c) 2014, Qualcomm Atheros, Inc.
       4             :  *
       5             :  * This software may be distributed under the terms of the BSD license.
       6             :  * See README for more details.
       7             :  */
       8             : 
       9             : #include "utils/includes.h"
      10             : 
      11             : #include "utils/common.h"
      12             : #include "utils/eloop.h"
      13             : #include "hostapd.h"
      14             : #include "bss_load.h"
      15             : #include "ap_drv_ops.h"
      16             : #include "beacon.h"
      17             : 
      18             : 
      19           5 : static void update_channel_utilization(void *eloop_data, void *user_data)
      20             : {
      21           5 :         struct hostapd_data *hapd = eloop_data;
      22             :         unsigned int sec, usec;
      23             :         int err;
      24             : 
      25           5 :         if (!(hapd->beacon_set_done && hapd->started))
      26           0 :                 return;
      27             : 
      28           5 :         err = hostapd_drv_get_survey(hapd, hapd->iface->freq);
      29           5 :         if (err) {
      30           0 :                 wpa_printf(MSG_ERROR, "BSS Load: Failed to get survey data");
      31           0 :                 return;
      32             :         }
      33             : 
      34           5 :         ieee802_11_set_beacon(hapd);
      35             : 
      36           5 :         sec = ((hapd->bss_load_update_timeout / 1000) * 1024) / 1000;
      37           5 :         usec = (hapd->bss_load_update_timeout % 1000) * 1024;
      38           5 :         eloop_register_timeout(sec, usec, update_channel_utilization, hapd,
      39             :                                NULL);
      40             : }
      41             : 
      42             : 
      43           1 : int bss_load_update_init(struct hostapd_data *hapd)
      44             : {
      45           1 :         struct hostapd_bss_config *conf = hapd->conf;
      46           1 :         struct hostapd_config *iconf = hapd->iconf;
      47             :         unsigned int sec, usec;
      48             : 
      49           1 :         if (!conf->bss_load_update_period || !iconf->beacon_int)
      50           0 :                 return -1;
      51             : 
      52           2 :         hapd->bss_load_update_timeout = conf->bss_load_update_period *
      53           1 :                                         iconf->beacon_int;
      54           1 :         sec = ((hapd->bss_load_update_timeout / 1000) * 1024) / 1000;
      55           1 :         usec = (hapd->bss_load_update_timeout % 1000) * 1024;
      56           1 :         eloop_register_timeout(sec, usec, update_channel_utilization, hapd,
      57             :                                NULL);
      58           1 :         return 0;
      59             : }
      60             : 
      61             : 
      62        2055 : void bss_load_update_deinit(struct hostapd_data *hapd)
      63             : {
      64        2055 :         eloop_cancel_timeout(update_channel_utilization, hapd, NULL);
      65        2055 : }

Generated by: LCOV version 1.10