include: cmake: pass toolchain directory to default root find path as well
[openwrt/svn-archive/archive.git] / package / network / services / hostapd / patches / 710-wds-wep-fix.patch
1 --- a/src/ap/ap_drv_ops.c
2 +++ b/src/ap/ap_drv_ops.c
3 @@ -296,19 +296,19 @@ int hostapd_vlan_if_remove(struct hostap
4 }
5
6
7 -int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid,
8 - int val)
9 +int hostapd_set_wds_sta(struct hostapd_data *hapd, char *ifname_wds,
10 + const u8 *addr, int aid, int val)
11 {
12 const char *bridge = NULL;
13
14 if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
15 - return 0;
16 + return -1;
17 if (hapd->conf->wds_bridge[0])
18 bridge = hapd->conf->wds_bridge;
19 else if (hapd->conf->bridge[0])
20 bridge = hapd->conf->bridge;
21 return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val,
22 - bridge);
23 + bridge, ifname_wds);
24 }
25
26
27 --- a/src/ap/ap_drv_ops.h
28 +++ b/src/ap/ap_drv_ops.h
29 @@ -31,8 +31,8 @@ int hostapd_set_drv_ieee8021x(struct hos
30 int enabled);
31 int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname);
32 int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname);
33 -int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid,
34 - int val);
35 +int hostapd_set_wds_sta(struct hostapd_data *hapd, char *ifname_wds,
36 + const u8 *addr, int aid, int val);
37 int hostapd_sta_add(struct hostapd_data *hapd,
38 const u8 *addr, u16 aid, u16 capability,
39 const u8 *supp_rates, size_t supp_rates_len,
40 --- a/src/ap/ieee802_11.c
41 +++ b/src/ap/ieee802_11.c
42 @@ -1846,6 +1846,29 @@ static void handle_auth_cb(struct hostap
43 }
44 }
45
46 +static void hostapd_set_wds_encryption(struct hostapd_data *hapd,
47 + struct sta_info *sta,
48 + char *ifname_wds)
49 +{
50 + int i, idx;
51 + struct hostapd_ssid *ssid = sta->ssid;
52 +
53 + if (hapd->conf->ieee802_1x || hapd->conf->wpa)
54 + return;
55 +
56 + for (i = 0; i < 4; i++) {
57 + if (ssid->wep.key[i] &&
58 + hostapd_drv_set_key(ifname_wds, hapd, WPA_ALG_WEP, NULL, i,
59 + i == ssid->wep.idx, NULL, 0,
60 + ssid->wep.key[i],
61 + ssid->wep.len[i])) {
62 + wpa_printf(MSG_WARNING,
63 + "Could not set WEP keys for WDS interface; %s",
64 + ifname_wds);
65 + break;
66 + }
67 + }
68 +}
69
70 static void handle_assoc_cb(struct hostapd_data *hapd,
71 const struct ieee80211_mgmt *mgmt,
72 @@ -1949,8 +1972,15 @@ static void handle_assoc_cb(struct hosta
73 goto fail;
74 }
75
76 - if (sta->flags & WLAN_STA_WDS)
77 - hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1);
78 + if (sta->flags & WLAN_STA_WDS) {
79 + int ret;
80 + char ifname_wds[IFNAMSIZ + 1];
81 +
82 + ret = hostapd_set_wds_sta(hapd, ifname_wds, sta->addr,
83 + sta->aid, 1);
84 + if (!ret)
85 + hostapd_set_wds_encryption(hapd, sta, ifname_wds);
86 + }
87
88 if (sta->eapol_sm == NULL) {
89 /*
90 @@ -2191,11 +2221,18 @@ void ieee802_11_rx_from_unknown(struct h
91 return;
92
93 if (wds && !(sta->flags & WLAN_STA_WDS)) {
94 + int ret;
95 + char ifname_wds[IFNAMSIZ + 1];
96 +
97 wpa_printf(MSG_DEBUG, "Enable 4-address WDS mode for "
98 "STA " MACSTR " (aid %u)",
99 MAC2STR(sta->addr), sta->aid);
100 sta->flags |= WLAN_STA_WDS;
101 - hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1);
102 + ret = hostapd_set_wds_sta(hapd, ifname_wds,
103 + sta->addr, sta->aid, 1);
104 + if (!ret)
105 + hostapd_set_wds_encryption(hapd, sta,
106 + ifname_wds);
107 }
108 return;
109 }
110 --- a/src/ap/sta_info.c
111 +++ b/src/ap/sta_info.c
112 @@ -129,7 +129,7 @@ void ap_free_sta(struct hostapd_data *ha
113 ap_sta_set_authorized(hapd, sta, 0);
114
115 if (sta->flags & WLAN_STA_WDS)
116 - hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 0);
117 + hostapd_set_wds_sta(hapd, NULL, sta->addr, sta->aid, 0);
118
119 if (!(sta->flags & WLAN_STA_PREAUTH))
120 hostapd_drv_sta_remove(hapd, sta->addr);
121 --- a/src/drivers/driver.h
122 +++ b/src/drivers/driver.h
123 @@ -2057,10 +2057,12 @@ struct wpa_driver_ops {
124 * @val: 1 = bind to 4-address WDS; 0 = unbind
125 * @bridge_ifname: Bridge interface to use for the WDS station or %NULL
126 * to indicate that bridge is not to be used
127 + * @ifname_wds: Buffer to return the interface name for the new WDS
128 + * station.
129 * Returns: 0 on success, -1 on failure
130 */
131 int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val,
132 - const char *bridge_ifname);
133 + const char *bridge_ifname, char *ifname_wds);
134
135 /**
136 * send_action - Transmit an Action frame
137 --- a/src/drivers/driver_nl80211.c
138 +++ b/src/drivers/driver_nl80211.c
139 @@ -8744,13 +8744,16 @@ static int have_ifidx(struct wpa_driver_
140
141
142 static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val,
143 - const char *bridge_ifname)
144 + const char *bridge_ifname, char *ifname_wds)
145 {
146 struct i802_bss *bss = priv;
147 struct wpa_driver_nl80211_data *drv = bss->drv;
148 char name[IFNAMSIZ + 1];
149
150 os_snprintf(name, sizeof(name), "%s.sta%d", bss->ifname, aid);
151 + if (ifname_wds)
152 + os_strlcpy(ifname_wds, name, IFNAMSIZ + 1);
153 +
154 wpa_printf(MSG_DEBUG, "nl80211: Set WDS STA addr=" MACSTR
155 " aid=%d val=%d name=%s", MAC2STR(addr), aid, val, name);
156 if (val) {