Hi,
Here is a patch that reflects the modified SIOCGIFDESCR API on FreeBSD.
There is a problem with the previous interface which tries to return ENAMETOOLONG. On FreeBSD, an underlying ioctl() handler returning an error would prevent ioctl(2) interface to copyout the request structure back to userland, defeating the length feedback feature.
The latest FreeBSD API uses NULL in buffer field to indicate such case. The new code checks the buffer pointer against the supplied one to determine this situation.
This code works on older kernels as well, since they will return ENAMETOOLONG, the description buffer would be considered as invalid.
Patch
So the code that results from the patch will work on *all* released versions of FreeBSD that support SIOCGIFDESCR?
Yes.
For older kernel, patched version would ignore the result from kernel (ENAMETOOLONG handled by if (ioctl(...) == 0) would hit else case where we just stop, if the description is too long to fit the buffer.
Note that released FreeBSD versions does not have SIOCGIFDESCR anyways. We expect to have the first release with this API in July and I'll merge this change back.
Hi,
Just FYI, all FreeBSD development branches with SIOCGIFDESCR has been changed to this way and there is no released version with the old API.
I've checked in and pushed a modified version to the main and 1.1 branches. The loop won't work on OpenBSD, as, unlike FreeBSD, it doesn't tell you how big the buffer should be if it's not big enough. It's also not necessary, as you know the maximum description size on OpenBSD.
Administrators of the "libpcap" SourceForge project have superseded this tracker item (formerly artifact 2987413, now bug 133) with issue 135 of the "libpcap" GitHub project.