LCOV - code coverage report
Current view: top level - wpa_supplicant - autoscan_periodic.c (source / functions) Hit Total Coverage
Test: wpa_supplicant/hostapd combined for hwsim test run 1443382998 Lines: 20 25 80.0 %
Date: 2015-09-27 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*
       2             :  * WPA Supplicant - auto scan periodic module
       3             :  * Copyright (c) 2012, Intel Corporation. All rights reserved.
       4             :  *
       5             :  * This software may be distributed under the terms of the BSD license.
       6             :  * See README for more details.
       7             :  */
       8             : 
       9             : #include "includes.h"
      10             : 
      11             : #include "common.h"
      12             : #include "wpa_supplicant_i.h"
      13             : #include "autoscan.h"
      14             : 
      15             : 
      16             : struct autoscan_periodic_data {
      17             :         int periodic_interval;
      18             : };
      19             : 
      20             : 
      21           5 : static int autoscan_periodic_get_params(struct autoscan_periodic_data *data,
      22             :                                         const char *params)
      23             : {
      24             :         int interval;
      25             : 
      26           5 :         if (params == NULL)
      27           0 :                 return -1;
      28             : 
      29           5 :         interval = atoi(params);
      30             : 
      31           5 :         if (interval < 0)
      32           0 :                 return -1;
      33             : 
      34           5 :         data->periodic_interval = interval;
      35             : 
      36           5 :         return 0;
      37             : }
      38             : 
      39             : 
      40           5 : static void * autoscan_periodic_init(struct wpa_supplicant *wpa_s,
      41             :                                      const char *params)
      42             : {
      43             :         struct autoscan_periodic_data *data;
      44             : 
      45           5 :         data = os_zalloc(sizeof(struct autoscan_periodic_data));
      46           5 :         if (data == NULL)
      47           0 :                 return NULL;
      48             : 
      49           5 :         if (autoscan_periodic_get_params(data, params) < 0) {
      50           0 :                 os_free(data);
      51           0 :                 return NULL;
      52             :         }
      53             : 
      54           5 :         wpa_printf(MSG_DEBUG, "autoscan periodic: interval is %d",
      55             :                    data->periodic_interval);
      56             : 
      57           5 :         return data;
      58             : }
      59             : 
      60             : 
      61           5 : static void autoscan_periodic_deinit(void *priv)
      62             : {
      63           5 :         struct autoscan_periodic_data *data = priv;
      64             : 
      65           5 :         os_free(data);
      66           5 : }
      67             : 
      68             : 
      69           4 : static int autoscan_periodic_notify_scan(void *priv,
      70             :                                          struct wpa_scan_results *scan_res)
      71             : {
      72           4 :         struct autoscan_periodic_data *data = priv;
      73             : 
      74           4 :         wpa_printf(MSG_DEBUG, "autoscan periodic: scan result notification");
      75             : 
      76           4 :         return data->periodic_interval;
      77             : }
      78             : 
      79             : 
      80             : const struct autoscan_ops autoscan_periodic_ops = {
      81             :         .name = "periodic",
      82             :         .init = autoscan_periodic_init,
      83             :         .deinit = autoscan_periodic_deinit,
      84             :         .notify_scan = autoscan_periodic_notify_scan,
      85             : };

Generated by: LCOV version 1.10