There's no point to allow this setting via wext in the kernel because it's not usable w/o hostapd anyway. Hence, hostapd needs to set the mode with nl80211. Signed-off-by: Johannes Berg --- hostapd/driver_nl80211.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) --- hostap.orig/hostapd/driver_nl80211.c 2007-12-24 12:14:15.000000000 +0100 +++ hostap/hostapd/driver_nl80211.c 2007-12-24 12:14:23.000000000 +0100 @@ -1974,12 +1974,37 @@ static int nl80211_create_monitor_interf return -1; } +static int nl80211_set_master_mode(struct i802_driver_data *drv, + const char *ifname) +{ + struct nl_msg *msg; + + msg = nlmsg_alloc(); + if (!msg) + return -1; + + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, + 0, NL80211_CMD_SET_INTERFACE, 0); + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, + if_nametoindex(ifname)); + NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_AP); + + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 || + nl_wait_for_ack(drv->nl_handle) < 0) { + nla_put_failure: + printf("Failed to set interface %s to master mode.\n", ifname); + nlmsg_free(msg); + return -1; + } + + nlmsg_free(msg); + + return 0; +} static int i802_init_sockets(struct i802_driver_data *drv, const u8 *bssid) { - struct hostapd_data *hapd = drv->hapd; struct ifreq ifr; - struct iwreq iwr; drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); if (drv->ioctl_sock < 0) { @@ -2034,14 +2059,8 @@ static int i802_init_sockets(struct i802 if (nl80211_create_monitor_interface(drv)) return -1; - memset(&iwr, 0, sizeof(iwr)); - os_strlcpy(iwr.ifr_name, hapd->conf->iface, IFNAMSIZ); - iwr.u.mode = IW_MODE_MASTER; - - if (ioctl(drv->ioctl_sock, SIOCSIWMODE, &iwr) < 0) { - perror("ioctl[SIOCSIWMODE]"); + if (nl80211_set_master_mode(drv, drv->iface)) return -1; - } if (hostapd_set_iface_flags(drv, drv->iface, 1)) return -1; --