2 hostapd/driver_devicescape.c | 111 +++++++++++++++++++++++++++++++------------
3 1 file changed, 82 insertions(+), 29 deletions(-)
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;
12 + unsigned int beacon_set:1;
16 @@ -908,37 +910,44 @@ static int i802_bss_remove(void *priv, c
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)
25 struct i802_driver_data *drv = priv;
26 - struct prism2_hostapd_param *param;
29 + u8 cmd = NL80211_CMD_NEW_BEACON;
32 - param = os_zalloc(sizeof(*param) + head_len + tail_len);
33 - if (param == NULL) {
34 - printf("Failed to alloc memory for beacon ioctl\n");
37 - len = (¶m->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(¶m->u.beacon.data[0], head, head_len);
42 - memcpy(¶m->u.beacon.data[0] + head_len, tail, tail_len);
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 "
50 - ifname, head, head_len, tail, tail_len, param->cmd);
53 + msg = nlmsg_alloc();
58 + if (drv->beacon_set)
59 + cmd = NL80211_CMD_SET_BEACON;
61 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 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);
68 + if (!drv->dtim_period)
69 + drv->dtim_period = 2;
70 + NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
72 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
73 + nl_wait_for_ack(drv->nl_handle) < 0)
78 + drv->beacon_set = 1;
86 @@ -985,15 +994,59 @@ static int i802_set_internal_bridge(void
87 static int i802_set_beacon_int(void *priv, int value)
89 struct i802_driver_data *drv = priv;
90 - return hostap_ioctl_prism2param(drv, PRISM2_PARAM_BEACON_INT, value);
94 + msg = nlmsg_alloc();
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));
102 + NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, value);
104 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
105 + nl_wait_for_ack(drv->nl_handle) < 0)
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)
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;
126 + msg = nlmsg_alloc();
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));
134 + drv->dtim_period = value;
135 + NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, drv->dtim_period);
137 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
138 + nl_wait_for_ack(drv->nl_handle) < 0)