This requires using the FreeBSD if_media.h (for now, anyway)
and adding a subtype_mask to the data structures. But this
does work.
Now 802.11 media will be displayed in ifconfig and Network
preferences.
I got a strange whole-system hang in file_cache_resize into this
function. Possibly the page was spuriously busy, perhaps it wasn't,
but not having function arguments on x86_64 in stack traces, I was
unable to deduce what page was actually being waited on.
In case it happens again, this should allow it to be debugged further
by placing the address of the vm_page structure in the thread wait
informations. (A string is not very useful here anyway.)
This was introduced into the main API in 2010 (d72ede75fb),
but was actually only fully used for the past month (c2a9a890f3)
when SIOCGIFMEDIA was supported for all *BSD drivers and not just WiFi.
Most userland consumers of this structure did not use it correctly,
as was the case in #17770, and only worked because in the fallback case
the network stack just treated it as if it were an ifreq.
Nothing actually used the ifm_count/ifm_ulist (though tentative APIs
were exposed for it) as noted by previous commits; and the fact that
Haiku's IFM_* declarations are so spartan makes most of the returned
values unintelligible to userland without using FreeBSD compat headers.
If, in the future, we decide to implement ifmedia listing and selection
properly, that should likely be done with separate ioctls instead of
having multi-function ones like this.
This is technically an ABI break, but in practice it should not matter:
ifmediareq::ifm_current aligns with ifreq::ifr_media, so the things
that used this structure like our in-tree code did will continue to work.
Until this past May, the only other field that was usually set was
ifm_active, but in the absence of setting ifm_status all non-Haiku
consumers should ignore it completely.
The only consumer of this ioctl that I know of out of the tree,
wpa_supplicant, still works after these changes.
* Remove unused variable.
* Use original value for IFM_AVALID, we do not need to remap this one.
(Actually we do not need to remap IFM_ACTIVE here either, but it makes
some things slightly easier to work with rather than remapping it
in a different location.)
This functionally disables most of the functionality of the BSD-style
SIOCGIFMEDIA, but it was never used in userland (because if it had,
it would have triggered SMAP violations in the compatibility layer.)
SIOCGIFMEDIA returns BSD-style media values, which mostly overlap
with Haiku ones but have a few differences still. These are taken care
of in the compat layer by ETHER_GET_LINK_STATE, which is where this
media value comes from, but are not by SIOCGIFMEDIA which just passes
back whatever the drivers do.
Fixes#17770, at least for ethernet drivers.
All the drivers that support ETHER_GET_LINK_STATE set this correctly;
and more specifically, it should actually not be set on some devices
(WiFi devices, specifically). Since SIOCGIFMEDIA has always been
passed through directly to the driver if it supports it, WiFi
devices worked anyway because this value never made it to userland.
That will soon change, hence this needed to be fixed.
We need not (in fact, must not) revalidate addresses if we are just
going to coalesce with the previous segment; otherwise, we will incorrectly
reject buffers that are more than page-aligned.
Should fix#17798 and the new KDL in #14260.
* Turn lastaddrp into a reference instead of a pointer.
* Use PAGESIZE instead of B_PAGE_SIZE for consistency.
* Rename "nsegs" variables to "seg" as it is an offset and not a count.
No functional change intended.
I got my pointer math wrong because some things in RNDIS use uint32 as
the base, but some things are in bytes. Most of the time this would result
in an offset past the end of the USB buffer, so it would just lead to
ignoring all but the first packet. But if the first packet was small enough,
it would point somewhere still in the buffer, and we would read the wrong
data.
Fixes#17775
Change-Id: I32ec0081336b1f772d4dc3099a0ac2c691aa12f0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5377
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Not sure if other phones could use another value, but it's better to
follow the spec. Also add some bounds checks with traces for now if we
see something strange.
Change-Id: I5c7bc37c4730e6a08bf0bf10fed975bf2012102e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5376
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
FreeBSD seems to do this, too, and sets BUS_SPACE_MAXSIZE appropriately
(which it seems we already do.) Fixes 32-bit builds following previous
commits.
This way sendmsg's argument will also be traced.
Change-Id: I40b44ffc732d884393f944bc2b1ced7b0a551287
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5354
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This actually has another advantage: if we can use musl sources
in the kernel POSIX support, then we can drop some of the BSD
sources that are used only in the kernel and have a different
implementation in userland (e.g. strtod) and have just one
version for both.
These are BSD extensions, not POSIX functions. They were needed
in libroot by the previous versions of the ftw/nftw implementations,
but the musl versions do not need them, and so we can move them to
libbsd.
This is a minor ABI break, but hopefully whatever was using them
in libroot also links to libbsd. If not, that's an easy enough fix.
(These were only added to libroot in 2013.)
It crashes the firmware after 40 scans. The issue has been reported to
OpenBSD, until then we can leave this disabled. The consequence is that
the wifi network list will not refresh while already connected to a
network. But at least the connection remains online.
* Do not allocate an equally-sized buffer for all scan results,
but just alloca() a buffer for a single result, and copy this
back to userland at the end of each iteration.
* Check remaining space correctly with respect to IE data.
May fix incorrect scan results or userland memory corruptions
seen with the previous code. Also should be faster since it
does not need to allocate large kernel-side temporary buffers.
In the long run it may make more sense to have Haiku-style ioctls for
this purpose, but since we are currently coexisting with FreeBSD-style
ioctls, just add this as another FreeBSD-style ioctl for now (we already
have two custom ones anyway.)
This ioctl pretty much just consists of the same parameters we pass
to wpa_supplicant using the Haiku-specific constants already, with one
notable difference: the PSK must be in proper WPA format, i.e. already
hashed. Hence we will submit this ioctl, for now, from our own code in
our wpa_supplicant port.
WPS is not implemented in this commit, but it could be if someone actually
needs to connect to WPS networks for some reason...
Tested and verified as working along with the wpa_supplicant changes.
This file contains a set of constants and flags which are already passed
between applications, net_server, and wpa_supplicant to indicate network
security, connection modes, and a variety of other things.
As the OpenBSD net80211 stack does not need wpa_supplicant for WPA2/PSK,
it only makes sense that we would pass the same information we pass
to wpa_supplicant into the stack instead. Rather than expose yet another
set of constants and flags to userland besides the FreeBSD and these
Haiku native ones, just make it so this file can be included in the kernel,
and the constants thus used directly.
* Introduce IEEE80211_IOCTLS_ABBREVIATED to FreeBSD's ieee80211_ioctl.h,
so that the FreeBSD header can be included along with the OpenBSD
net80211 stack without triggering lots of errors, so we can use
these structs in openbsd_wlan ieee80211_haiku.cpp.
* Implement basic ieee80211req handling machinery. We aren't going
to handle anything but SIOCG80211 and SIOCS80211 in this method,
so we can simplify it a bit at the same time.
* Implement IEEE80211_IOC_SCAN_RESULTS to return scan results from
the OpenBSD WiFi stack in FreeBSD ioctl format.
This change adds two minor "features" (noted with #ifdefs) to the
OpenBSD net80211 stack: one to specify what node index to return
when returning known nodes (scan results), as this way we do not
have to allocate a huge buffer to store the scan results in before
sending them back to userland, but can instead get and convert
a single one at a time.
(We store the converted values in kernel mode all at once, though,
so this is not as efficient as it could be. More improvement possible.)
* Implement IEEE80211_IOC_BSSID and IEEE80211_IOC_SSID while we are at it.
This actually may make joining open networks possible, but I didn't
really test it. (They are used with SIOCG80211 to see what network
the device is currently connecting/connected to.)
Mostly a few #ifdefs for the dmamem API, if_alloc, probe, and attach hooks.
Basically the same changes in both drivers.
The firmware name map is not really needed anymore; the OpenBSD drivers
have unique firmware names and do not generally use ".ucode" extensions.
So just use the filenames as-is and drop the map.
The stack now compiles and links. Combining this with adaptations to
the driver gets things to the point where it runs scans, but we do
not yet implement ioctls so they can be returned to userland.
OpenBSD's and FreeBSD's kernel APIs are very similar, but there are
still some differences. Fortunately these are small enough that we
can take care of most of them with a header-only shim layer.
(The files and functions implemented by this commit were implemented
and tested against the modules and drivers imported and adapted in
the following commits. Some of this took quite a bit of time to get
right, especially where the APIs have diverged in very subtle ways.)
Most of these changes however add things that FreeBSD has (with a few
exceptions noted in comments) which the OpenBSD shim layer merely needs
to make use of.
(FreeBSD used to have support for IFF_NEEDSGIANT but removed it. The
support instated here is very similar to what FreeBSD used to have.)
* Have FindPanel::AttachedToWindow check to see if a MIME type is
already selected, before it sets MIME type to the default value.
* Fixes#14946.
Change-Id: Iab3b9058bbc3ef1f055475ed54a72d4032643632
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5357
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>