2 * WPA Supplicant - auto scan exponential module
3 * Copyright (c) 2012, Intel Corporation. All rights reserved.
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
12 #include "wpa_supplicant_i.h"
15 struct autoscan_exponential_data
{
16 struct wpa_supplicant
*wpa_s
;
24 autoscan_exponential_get_params(struct autoscan_exponential_data
*data
,
32 data
->base
= atoi(params
);
34 pos
= os_strchr(params
, ':');
39 data
->limit
= atoi(pos
);
45 static void * autoscan_exponential_init(struct wpa_supplicant
*wpa_s
,
48 struct autoscan_exponential_data
*data
;
50 data
= os_zalloc(sizeof(struct autoscan_exponential_data
));
54 if (autoscan_exponential_get_params(data
, params
) < 0) {
59 wpa_printf(MSG_DEBUG
, "autoscan exponential: base exponential is %d "
60 "and limit is %d", data
->base
, data
->limit
);
68 static void autoscan_exponential_deinit(void *priv
)
70 struct autoscan_exponential_data
*data
= priv
;
76 static int autoscan_exponential_notify_scan(void *priv
,
77 struct wpa_scan_results
*scan_res
)
79 struct autoscan_exponential_data
*data
= priv
;
81 wpa_printf(MSG_DEBUG
, "autoscan exponential: scan result "
84 if (data
->interval
>= data
->limit
)
87 if (data
->interval
<= 0)
88 data
->interval
= data
->base
;
90 data
->interval
= data
->interval
* data
->base
;
91 if (data
->interval
> data
->limit
)
95 return data
->interval
;
99 const struct autoscan_ops autoscan_exponential_ops
= {
100 .name
= "exponential",
101 .init
= autoscan_exponential_init
,
102 .deinit
= autoscan_exponential_deinit
,
103 .notify_scan
= autoscan_exponential_notify_scan
,