Fix wpa_supplicant AP build after hostapd header file cleanup
[wpasupplicant] / wpa_supplicant / ap.c
1 /*
2  * WPA Supplicant - Basic AP mode support routines
3  * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2009, Atheros Communications
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * Alternatively, this software may be distributed under the terms of BSD
11  * license.
12  *
13  * See README and COPYING for more details.
14  */
15
16 #include "includes.h"
17
18 #include "common.h"
19 #include "../hostapd/hostapd.h"
20 #include "../hostapd/config.h"
21 #include "eap_common/eap_defs.h"
22 #include "eap_server/eap_methods.h"
23 #include "eap_common/eap_wsc_common.h"
24
25
26 int hostapd_reload_config(struct hostapd_iface *iface)
27 {
28         /* TODO */
29         return -1;
30 }
31
32
33 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
34                           const u8 *addr, int *vlan_id)
35 {
36         int start, end, middle, res;
37
38         start = 0;
39         end = num_entries - 1;
40
41         while (start <= end) {
42                 middle = (start + end) / 2;
43                 res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
44                 if (res == 0) {
45                         if (vlan_id)
46                                 *vlan_id = list[middle].vlan_id;
47                         return 1;
48                 }
49                 if (res < 0)
50                         start = middle + 1;
51                 else
52                         end = middle - 1;
53         }
54
55         return 0;
56 }
57
58
59 int hostapd_rate_found(int *list, int rate)
60 {
61         int i;
62
63         if (list == NULL)
64                 return 0;
65
66         for (i = 0; list[i] >= 0; i++)
67                 if (list[i] == rate)
68                         return 1;
69
70         return 0;
71 }
72
73
74 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
75 {
76         return NULL;
77 }
78
79
80 int hostapd_for_each_interface(int (*cb)(struct hostapd_iface *iface,
81                                          void *ctx), void *ctx)
82 {
83         /* TODO */
84         return 0;
85 }
86
87
88 const struct hostapd_eap_user *
89 hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
90                      size_t identity_len, int phase2)
91 {
92         struct hostapd_eap_user *user = conf->eap_user;
93
94 #ifdef CONFIG_WPS
95         if (conf->wps_state && identity_len == WSC_ID_ENROLLEE_LEN &&
96             os_memcmp(identity, WSC_ID_ENROLLEE, WSC_ID_ENROLLEE_LEN) == 0) {
97                 static struct hostapd_eap_user wsc_enrollee;
98                 os_memset(&wsc_enrollee, 0, sizeof(wsc_enrollee));
99                 wsc_enrollee.methods[0].method = eap_server_get_type(
100                         "WSC", &wsc_enrollee.methods[0].vendor);
101                 return &wsc_enrollee;
102         }
103
104         if (conf->wps_state && conf->ap_pin &&
105             identity_len == WSC_ID_REGISTRAR_LEN &&
106             os_memcmp(identity, WSC_ID_REGISTRAR, WSC_ID_REGISTRAR_LEN) == 0) {
107                 static struct hostapd_eap_user wsc_registrar;
108                 os_memset(&wsc_registrar, 0, sizeof(wsc_registrar));
109                 wsc_registrar.methods[0].method = eap_server_get_type(
110                         "WSC", &wsc_registrar.methods[0].vendor);
111                 wsc_registrar.password = (u8 *) conf->ap_pin;
112                 wsc_registrar.password_len = os_strlen(conf->ap_pin);
113                 return &wsc_registrar;
114         }
115 #endif /* CONFIG_WPS */
116
117         while (user) {
118                 if (!phase2 && user->identity == NULL) {
119                         /* Wildcard match */
120                         break;
121                 }
122
123                 if (user->phase2 == !!phase2 && user->wildcard_prefix &&
124                     identity_len >= user->identity_len &&
125                     os_memcmp(user->identity, identity, user->identity_len) ==
126                     0) {
127                         /* Wildcard prefix match */
128                         break;
129                 }
130
131                 if (user->phase2 == !!phase2 &&
132                     user->identity_len == identity_len &&
133                     os_memcmp(user->identity, identity, identity_len) == 0)
134                         break;
135                 user = user->next;
136         }
137
138         return user;
139 }