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 1401264779 Lines: 20 25 80.0 %
Date: 2014-05-28 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           2 : static int autoscan_periodic_get_params(struct autoscan_periodic_data *data,
      22             :                                         const char *params)
      23             : {
      24             :         int interval;
      25             : 
      26           2 :         if (params == NULL)
      27           0 :                 return -1;
      28             : 
      29           2 :         interval = atoi(params);
      30             : 
      31           2 :         if (interval < 0)
      32           0 :                 return -1;
      33             : 
      34           2 :         data->periodic_interval = interval;
      35             : 
      36           2 :         return 0;
      37             : }
      38             : 
      39             : 
      40           2 : static void * autoscan_periodic_init(struct wpa_supplicant *wpa_s,
      41             :                                      const char *params)
      42             : {
      43             :         struct autoscan_periodic_data *data;
      44             : 
      45           2 :         data = os_zalloc(sizeof(struct autoscan_periodic_data));
      46           2 :         if (data == NULL)
      47           0 :                 return NULL;
      48             : 
      49           2 :         if (autoscan_periodic_get_params(data, params) < 0) {
      50           0 :                 os_free(data);
      51           0 :                 return NULL;
      52             :         }
      53             : 
      54           2 :         wpa_printf(MSG_DEBUG, "autoscan periodic: interval is %d",
      55             :                    data->periodic_interval);
      56             : 
      57           2 :         return data;
      58             : }
      59             : 
      60             : 
      61           2 : static void autoscan_periodic_deinit(void *priv)
      62             : {
      63           2 :         struct autoscan_periodic_data *data = priv;
      64             : 
      65           2 :         os_free(data);
      66           2 : }
      67             : 
      68             : 
      69           3 : static int autoscan_periodic_notify_scan(void *priv,
      70             :                                          struct wpa_scan_results *scan_res)
      71             : {
      72           3 :         struct autoscan_periodic_data *data = priv;
      73             : 
      74           3 :         wpa_printf(MSG_DEBUG, "autoscan periodic: scan result notification");
      75             : 
      76           3 :         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