]> git.ipfire.org Git - thirdparty/hostap.git/blob - wpa_supplicant/bgscan.c
EAP: Increase the maximum number of message exchanges
[thirdparty/hostap.git] / wpa_supplicant / bgscan.c
1 /*
2 * WPA Supplicant - background scan and roaming interface
3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
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 "config_ssid.h"
14 #include "bgscan.h"
15
16
17 static const struct bgscan_ops * bgscan_modules[] = {
18 #ifdef CONFIG_BGSCAN_SIMPLE
19 &bgscan_simple_ops,
20 #endif /* CONFIG_BGSCAN_SIMPLE */
21 #ifdef CONFIG_BGSCAN_LEARN
22 &bgscan_learn_ops,
23 #endif /* CONFIG_BGSCAN_LEARN */
24 NULL
25 };
26
27
28 int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
29 const char *name)
30 {
31 const char *params;
32 size_t nlen;
33 int i;
34 const struct bgscan_ops *ops = NULL;
35
36 bgscan_deinit(wpa_s);
37
38 params = os_strchr(name, ':');
39 if (params == NULL) {
40 params = "";
41 nlen = os_strlen(name);
42 } else {
43 nlen = params - name;
44 params++;
45 }
46
47 for (i = 0; bgscan_modules[i]; i++) {
48 if (os_strncmp(name, bgscan_modules[i]->name, nlen) == 0) {
49 ops = bgscan_modules[i];
50 break;
51 }
52 }
53
54 if (ops == NULL) {
55 wpa_printf(MSG_ERROR, "bgscan: Could not find module "
56 "matching the parameter '%s'", name);
57 return -1;
58 }
59
60 wpa_s->bgscan_priv = ops->init(wpa_s, params, ssid);
61 if (wpa_s->bgscan_priv == NULL)
62 return -1;
63 wpa_s->bgscan = ops;
64 wpa_printf(MSG_DEBUG, "bgscan: Initialized module '%s' with "
65 "parameters '%s'", ops->name, params);
66
67 return 0;
68 }
69
70
71 void bgscan_deinit(struct wpa_supplicant *wpa_s)
72 {
73 if (wpa_s->bgscan && wpa_s->bgscan_priv) {
74 wpa_printf(MSG_DEBUG, "bgscan: Deinitializing module '%s'",
75 wpa_s->bgscan->name);
76 wpa_s->bgscan->deinit(wpa_s->bgscan_priv);
77 wpa_s->bgscan = NULL;
78 wpa_s->bgscan_priv = NULL;
79 }
80 }
81
82
83 int bgscan_notify_scan(struct wpa_supplicant *wpa_s,
84 struct wpa_scan_results *scan_res)
85 {
86 if (wpa_s->bgscan && wpa_s->bgscan_priv)
87 return wpa_s->bgscan->notify_scan(wpa_s->bgscan_priv,
88 scan_res);
89 return 0;
90 }
91
92
93 void bgscan_notify_beacon_loss(struct wpa_supplicant *wpa_s)
94 {
95 if (wpa_s->bgscan && wpa_s->bgscan_priv)
96 wpa_s->bgscan->notify_beacon_loss(wpa_s->bgscan_priv);
97 }
98
99
100 void bgscan_notify_signal_change(struct wpa_supplicant *wpa_s, int above,
101 int current_signal, int current_noise,
102 int current_txrate)
103 {
104 if (wpa_s->bgscan && wpa_s->bgscan_priv)
105 wpa_s->bgscan->notify_signal_change(wpa_s->bgscan_priv, above,
106 current_signal,
107 current_noise,
108 current_txrate);
109 }