12fbdc86b7ed57ab82503771b47a1a6900d01404
[openwrt/openwrt.git] / package / hostapd / patches / 380-ap_isolate.patch
1 --- a/hostapd/config_file.c
2 +++ b/hostapd/config_file.c
3 @@ -1266,6 +1266,8 @@ struct hostapd_config * hostapd_config_r
4 }
5 } else if (os_strcmp(buf, "wds_sta") == 0) {
6 bss->wds_sta = atoi(pos);
7 + } else if (os_strcmp(buf, "ap_isolate") == 0) {
8 + bss->isolate = atoi(pos);
9 } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
10 bss->ap_max_inactivity = atoi(pos);
11 } else if (os_strcmp(buf, "country_code") == 0) {
12 --- a/src/ap/ap_config.h
13 +++ b/src/ap/ap_config.h
14 @@ -199,6 +199,7 @@ struct hostapd_bss_config {
15 struct mac_acl_entry *deny_mac;
16 int num_deny_mac;
17 int wds_sta;
18 + int isolate;
19
20 int auth_algs; /* bitfield of allowed IEEE 802.11 authentication
21 * algorithms, WPA_AUTH_ALG_{OPEN,SHARED,LEAP} */
22 --- a/src/drivers/driver.h
23 +++ b/src/drivers/driver.h
24 @@ -1626,6 +1626,14 @@ struct wpa_driver_ops {
25 const char *bridge_ifname);
26
27 /**
28 + * set_ap_isolate - Enable/disable AP isolation
29 + * @priv: private driver interface data
30 + * @val: 1 = enabled; 0 = disabled
31 + * Returns: 0 on success, -1 on failure
32 + */
33 + int (*set_ap_isolate)(void *priv, int val);
34 +
35 + /**
36 * send_action - Transmit an Action frame
37 * @priv: Private driver interface data
38 * @freq: Frequency (in MHz) of the channel
39 --- a/src/drivers/driver_nl80211.c
40 +++ b/src/drivers/driver_nl80211.c
41 @@ -4339,6 +4339,29 @@ static int i802_set_rate_sets(void *priv
42 return -ENOBUFS;
43 }
44
45 +static int i802_set_ap_isolate(void *priv, int val)
46 +{
47 + struct i802_bss *bss = priv;
48 + struct wpa_driver_nl80211_data *drv = bss->drv;
49 + struct nl_msg *msg;
50 + int i;
51 +
52 + msg = nlmsg_alloc();
53 + if (!msg)
54 + return -ENOMEM;
55 +
56 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
57 + NL80211_CMD_SET_BSS, 0);
58 +
59 + NLA_PUT_U8(msg, NL80211_ATTR_AP_ISOLATE, !!val);
60 +
61 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(bss->ifname));
62 +
63 + return send_and_recv_msgs(drv, msg, NULL, NULL);
64 + nla_put_failure:
65 + return -ENOBUFS;
66 +}
67 +
68 #endif /* HOSTAPD */
69
70
71 @@ -5448,6 +5471,7 @@ const struct wpa_driver_ops wpa_driver_n
72 .set_tx_queue_params = i802_set_tx_queue_params,
73 .set_sta_vlan = i802_set_sta_vlan,
74 .set_wds_sta = i802_set_wds_sta,
75 + .set_ap_isolate = i802_set_ap_isolate,
76 #endif /* HOSTAPD */
77 .set_freq = i802_set_freq,
78 .send_action = wpa_driver_nl80211_send_action,
79 --- a/src/ap/ap_drv_ops.c
80 +++ b/src/ap/ap_drv_ops.c
81 @@ -180,6 +180,14 @@ static int hostapd_set_radius_acl_expire
82 }
83
84
85 +static int hostapd_set_ap_isolate(struct hostapd_data *hapd, int value)
86 +{
87 + if (hapd->driver == NULL || hapd->driver->set_ap_isolate == NULL)
88 + return 0;
89 + hapd->driver->set_ap_isolate(hapd->drv_priv, value);
90 +}
91 +
92 +
93 static int hostapd_set_bss_params(struct hostapd_data *hapd,
94 int use_protection)
95 {
96 @@ -229,6 +237,12 @@ static int hostapd_set_bss_params(struct
97 "driver");
98 ret = -1;
99 }
100 + if (hostapd_set_ap_isolate(hapd, hapd->conf->isolate) &&
101 + !hapd->conf->isolate) {
102 + wpa_printf(MSG_ERROR, "Could not enable AP isolation in "
103 + "kernel driver");
104 + ret = -1;
105 + }
106
107 return ret;
108 }