34fa841d61c9e845b046bd4699847e5ecda999b1
[openwrt.git] / package / hostapd / patches / 003-use-nl80211-for-beacons.patch
1 ---
2 hostapd/driver_devicescape.c | 111 +++++++++++++++++++++++++++++++------------
3 1 file changed, 82 insertions(+), 29 deletions(-)
4
5 --- hostap.orig/hostapd/driver_devicescape.c 2007-11-09 13:41:13.000000000 +0100
6 +++ hostap/hostapd/driver_devicescape.c 2007-11-09 13:41:13.000000000 +0100
7 @@ -68,6 +68,8 @@ struct i802_driver_data {
8 struct nl_handle *nl_handle;
9 struct nl_cache *nl_cache;
10 struct genl_family *nl80211;
11 + int dtim_period;
12 + unsigned int beacon_set:1;
13 };
14
15
16 @@ -908,37 +910,44 @@ static int i802_bss_remove(void *priv, c
17 }
18
19
20 -static int i802_set_beacon(const char *ifname, void *priv,
21 +static int i802_set_beacon(const char *iface, void *priv,
22 u8 *head, size_t head_len,
23 u8 *tail, size_t tail_len)
24 {
25 struct i802_driver_data *drv = priv;
26 - struct prism2_hostapd_param *param;
27 - int len, ret = 0;
28 + struct nl_msg *msg;
29 + u8 cmd = NL80211_CMD_NEW_BEACON;
30 + int ret = -1;
31
32 - param = os_zalloc(sizeof(*param) + head_len + tail_len);
33 - if (param == NULL) {
34 - printf("Failed to alloc memory for beacon ioctl\n");
35 - return -1;
36 - }
37 - len = (&param->u.beacon.data[0] - (u8 *) param) + head_len + tail_len;
38 - param->cmd = PRISM2_HOSTAPD_SET_BEACON;
39 - param->u.beacon.head_len = head_len;
40 - param->u.beacon.tail_len = tail_len;
41 - memcpy(&param->u.beacon.data[0], head, head_len);
42 - memcpy(&param->u.beacon.data[0] + head_len, tail, tail_len);
43 -
44 - if (len < (int) sizeof(*param))
45 - len = sizeof(*param);
46 - if (hostapd_ioctl_iface(ifname, drv, param, len)) {
47 - printf("Could not set beacon data to kernel driver.\n");
48 - printf("ifname='%s' head=%p head_len=%d tail=%p tail_len=%d "
49 - "cmd=%d\n",
50 - ifname, head, head_len, tail, tail_len, param->cmd);
51 - ret = -1;
52 - }
53 + msg = nlmsg_alloc();
54 + if (!msg)
55 + goto out;
56
57 - free(param);
58 + if (drv->beacon_set)
59 + cmd = NL80211_CMD_SET_BEACON;
60 +
61 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
62 + 0, cmd, 0);
63 + NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, head_len, head);
64 + NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
65 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
66 + NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, 1000);
67 +
68 + if (!drv->dtim_period)
69 + drv->dtim_period = 2;
70 + NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
71 +
72 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
73 + nl_wait_for_ack(drv->nl_handle) < 0)
74 + goto out;
75 +
76 + ret = 0;
77 +
78 + drv->beacon_set = 1;
79 +
80 + out:
81 + nla_put_failure:
82 + nlmsg_free(msg);
83 return ret;
84 }
85
86 @@ -985,15 +994,59 @@ static int i802_set_internal_bridge(void
87 static int i802_set_beacon_int(void *priv, int value)
88 {
89 struct i802_driver_data *drv = priv;
90 - return hostap_ioctl_prism2param(drv, PRISM2_PARAM_BEACON_INT, value);
91 + struct nl_msg *msg;
92 + int ret = -1;
93 +
94 + msg = nlmsg_alloc();
95 + if (!msg)
96 + goto out;
97 +
98 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
99 + 0, NL80211_CMD_SET_BEACON, 0);
100 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
101 +
102 + NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, value);
103 +
104 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
105 + nl_wait_for_ack(drv->nl_handle) < 0)
106 + goto out;
107 +
108 + ret = 0;
109 +
110 + out:
111 + nla_put_failure:
112 + nlmsg_free(msg);
113 + return ret;
114 }
115
116
117 -static int i802_set_dtim_period(const char *ifname, void *priv, int value)
118 +static int i802_set_dtim_period(const char *iface, void *priv, int value)
119 {
120 struct i802_driver_data *drv = priv;
121 - return hostap_ioctl_prism2param_iface(ifname, drv,
122 - PRISM2_PARAM_DTIM_PERIOD, value);
123 + struct nl_msg *msg;
124 + int ret = -1;
125 +
126 + msg = nlmsg_alloc();
127 + if (!msg)
128 + goto out;
129 +
130 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
131 + 0, NL80211_CMD_SET_BEACON, 0);
132 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
133 +
134 + drv->dtim_period = value;
135 + NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
136 +
137 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
138 + nl_wait_for_ack(drv->nl_handle) < 0)
139 + goto out;
140 +
141 + ret = 0;
142 +
143 + out:
144 + nla_put_failure:
145 + nlmsg_free(msg);
146 + return ret;
147 }
148
149
This page took 0.041414 seconds and 3 git commands to generate.