The attached patch is an improved version of interface description support. This version provided the ability of supporting arbitrary length'ed interface description.
I have reorganized the code a little bit to make it easier to review. To summary:
- Dynamically allocate the description buffer instead of allocating it statically on the stack.
- For FreeBSD, when the buffer is not sufficient to hold the description, use the value fed back from kernel to reallocate the buffer.
- Free the buffer after use.
Note: I believe that the free() usage here is safe on FreeBSD and OpenBSD where free(NULL) is a no-op.
If this patch is accepted and if my name would be used please spell it as "Xin LI <delphij@FreeBSD.org>", thanks!
Patch for support of arbitrary interface description
My copy of the C89 standard is at home, and I'm not about to spend an additional $300(!) to get an additional machine-readable copy, but a draft I found online says
The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs.
so, in any system that implements ANSI C, free(NULL) is a no-op.
Checked into the top of the tree and pushed. This might, or might not, get into the 1.1 release.
Administrators of the "libpcap" SourceForge project have superseded this tracker item (formerly artifact 2968295, now patch 43) with issue 239 of the "libpcap" GitHub project.