hrev45424 adds 2 changesets to branch 'master' old head: 15aa77139011a57c47c11ba7fe1fee3c45ec2173 new head: 4e186e6a31e32ed6a0becde0bc3187400cbceb26 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=4e186e6+%5E15aa771 ---------------------------------------------------------------------------- 18004d3: Avoid trying to set the media to Ethernet for WLAN devices. It didn't really harm, but would always try to find a corresponding media, fail and print an error. 4e186e6: Add IEEE80211_IOC_HAIKU_COMPAT_WLAN_{UP|DOWN} compat requests. They can be supplied as request type codes to SIOCS80211 are added to allow overcoming a difference between how Haiku and FreeBSD handle network drivers. In FreeBSD a device can be set into the down state but is still fully configurable using the ioctl interface. The Haiku network stack on the other hand opens and closes the driver on the transition form up to down and vice versa. This difference can become problematic with ported software that depends on the original behaviour. Therefore IEEE80211_IOC_HAIKU_COMPAT_WLAN_{UP|DOWN} provide a way to achieve the behaviour of setting and clearing IFF_UP without opening or closing the driver itself. The wpa_supplicant will use this in its BSD driver instead of actually setting the interface down and then failing all other ioctls. [ Michael Lotz <mmlr@xxxxxxxx> ] ---------------------------------------------------------------------------- 3 files changed, 53 insertions(+), 16 deletions(-) src/libs/compat/freebsd_network/device.c | 8 ++-- .../freebsd_wlan/net80211/ieee80211_haiku.cpp | 45 ++++++++++++++------ .../freebsd_wlan/net80211/ieee80211_ioctl.h | 16 +++++++ ############################################################################ Commit: 18004d3ac01f07153a6891c451f2e7e2f1ae8d3f URL: http://cgit.haiku-os.org/haiku/commit/?id=18004d3 Author: Michael Lotz <mmlr@xxxxxxxx> Date: Fri Mar 29 22:45:59 2013 UTC Avoid trying to set the media to Ethernet for WLAN devices. It didn't really harm, but would always try to find a corresponding media, fail and print an error. ---------------------------------------------------------------------------- diff --git a/src/libs/compat/freebsd_network/device.c b/src/libs/compat/freebsd_network/device.c index 2e7fb31..ec2cf94 100644 --- a/src/libs/compat/freebsd_network/device.c +++ b/src/libs/compat/freebsd_network/device.c @@ -53,11 +53,11 @@ compat_open(const char *name, uint32 flags, void **cookie) if (!HAIKU_DRIVER_REQUIRES(FBSD_WLAN)) { ifp->if_flags &= ~IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); - } - memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_media = IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0); - ifp->if_ioctl(ifp, SIOCSIFMEDIA, (caddr_t)&ifr); + memset(&ifr, 0, sizeof(ifr)); + ifr.ifr_media = IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0); + ifp->if_ioctl(ifp, SIOCSIFMEDIA, (caddr_t)&ifr); + } ifp->if_flags |= IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); ############################################################################ Revision: hrev45424 Commit: 4e186e6a31e32ed6a0becde0bc3187400cbceb26 URL: http://cgit.haiku-os.org/haiku/commit/?id=4e186e6 Author: Michael Lotz <mmlr@xxxxxxxx> Date: Fri Mar 29 22:47:21 2013 UTC Add IEEE80211_IOC_HAIKU_COMPAT_WLAN_{UP|DOWN} compat requests. They can be supplied as request type codes to SIOCS80211 are added to allow overcoming a difference between how Haiku and FreeBSD handle network drivers. In FreeBSD a device can be set into the down state but is still fully configurable using the ioctl interface. The Haiku network stack on the other hand opens and closes the driver on the transition form up to down and vice versa. This difference can become problematic with ported software that depends on the original behaviour. Therefore IEEE80211_IOC_HAIKU_COMPAT_WLAN_{UP|DOWN} provide a way to achieve the behaviour of setting and clearing IFF_UP without opening or closing the driver itself. The wpa_supplicant will use this in its BSD driver instead of actually setting the interface down and then failing all other ioctls. ---------------------------------------------------------------------------- diff --git a/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp b/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp index d4910cd..b1f936f 100644 --- a/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp +++ b/src/libs/compat/freebsd_wlan/net80211/ieee80211_haiku.cpp @@ -192,6 +192,34 @@ stop_wlan(device_t device) status_t +wlan_open(void* cookie) +{ + dprintf("wlan_open(%p)\n", cookie); + struct ifnet* ifp = (struct ifnet*)cookie; + + ifp->if_init(ifp->if_softc); + + ifp->if_flags |= IFF_UP; + ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); + + return B_OK; +} + + +status_t +wlan_close(void* cookie) +{ + dprintf("wlan_close(%p)\n", cookie); + struct ifnet* ifp = (struct ifnet*)cookie; + + ifp->if_flags &= ~IFF_UP; + ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); + + return release_sem_etc(ifp->scan_done_sem, 1, B_RELEASE_ALL); +} + + +status_t wlan_control(void* cookie, uint32 op, void* arg, size_t length) { struct ifnet* ifp = (struct ifnet*)cookie; @@ -344,6 +372,11 @@ wlan_control(void* cookie, uint32 op, void* arg, size_t length) if (user_memcpy(&request, arg, sizeof(struct ieee80211req)) != B_OK) return B_BAD_ADDRESS; + if (request.i_type == IEEE80211_IOC_HAIKU_COMPAT_WLAN_UP) + return wlan_open(cookie); + else if (request.i_type == IEEE80211_IOC_HAIKU_COMPAT_WLAN_DOWN) + return wlan_close(cookie); + TRACE("wlan_control: %ld, %d\n", op, request.i_type); status_t status = ifp->if_ioctl(ifp, op, (caddr_t)&request); if (status != B_OK) @@ -368,18 +401,6 @@ wlan_control(void* cookie, uint32 op, void* arg, size_t length) status_t -wlan_close(void* cookie) -{ - struct ifnet* ifp = (struct ifnet*)cookie; - - ifp->if_flags &= ~IFF_UP; - ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); - - return release_sem_etc(ifp->scan_done_sem, 1, B_RELEASE_ALL); -} - - -status_t wlan_if_l2com_alloc(void* data) { struct ifnet* ifp = (struct ifnet*)data; diff --git a/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.h b/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.h index f1a1dcd..551d187 100644 --- a/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.h +++ b/src/libs/compat/freebsd_wlan/net80211/ieee80211_ioctl.h @@ -719,6 +719,22 @@ struct ieee80211req { #define IEEE80211_IOC_TDMA_SLOTLEN 203 /* TDMA: slot length (usecs) */ #define IEEE80211_IOC_TDMA_BINTERVAL 204 /* TDMA: beacon intvl (slots) */ +#ifdef __HAIKU__ +/* + These are here to allow overcoming a difference between Haiku and + FreeBSD drivers. In FreeBSD a device can be set into the down state + but is still fully configurable using the ioctl interface. The Haiku + network stack on the other hand opens and closes the driver on the + transition form up to down and vice versa. This difference can become + problematic with ported software that depends on the original behaviour. + Therefore IEEE80211_IOC_HAIKU_COMPAT_WLAN_{UP|DOWN} provide a way to + achieve the behaviour of setting and clearing IFF_UP without opening + or closing the driver itself. +*/ +#define IEEE80211_IOC_HAIKU_COMPAT_WLAN_UP 0x6000 +#define IEEE80211_IOC_HAIKU_COMPAT_WLAN_DOWN 0x6001 +#endif /* __HAIKU__ */ + /* * Parameters for controlling a scan requested with * IEEE80211_IOC_SCAN_REQ.