- /* Ignore the return value - this is because the call fails on
- * BPF systems that don't have kernel malloc. And if the call
- * fails, it's no big deal, we just continue to use the standard
- * buffer size.
- */
+ /* try finding a good size for the buffer */
+ do {
+ (void) ioctl(fd, BIOCSBLEN, (caddr_t)&v);
+
+ (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+ if ((ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) &&
+ (errno != ENOBUFS)) {
+ snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s",
+ errno, device, pcap_strerror(errno));
+ goto bad;
+ }
+ v >>= 2;
+ } while (fd < 0 && errno == ENOBUFS);
+