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