*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-bt-linux.c,v 1.11 2008-04-04 19:37:45 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-bt-linux.c,v 1.12 2008-04-07 03:57:32 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"Can't get Bluetooth device index from %s",
handle->opt.source);
- return -1;
+ return PCAP_ERROR;
}
/* Initialize some components of the pcap structure. */
if (handle->fd < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't create raw socket %d:%s",
errno, strerror(errno));
- return -1;
+ return PCAP_ERROR;
}
handle->buffer = malloc(handle->bufsize);
handle->md.ifindex, errno, strerror(errno));
goto close_fail;
}
+
+ if (handle->opt.buffer_size == 0) {
+ /*
+ * Set the socket buffer size to the specified value.
+ */
+ if (setsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF,
+ &handle->opt.buffer_size,
+ sizeof(handle->opt.buffer_size)) == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "SO_RCVBUF: %s", pcap_strerror(errno));
+ goto close_fail;
+ }
+ }
+
handle->selectable_fd = handle->fd;
return 0;
close_fail:
close(handle->fd);
- return -1;
+ return PCAP_ERROR;
}
static int
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.142 2008-04-07 00:31:47 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.143 2008-04-07 03:57:32 guy Exp $ (LBL)";
#endif
/*
* up and report our failure (ebuf is expected to be
* set by the functions above).
*/
+ goto fail;
+ }
- if (handle->md.device != NULL) {
- free(handle->md.device);
- handle->md.device = NULL;
+ if (handle->opt.buffer_size == 0) {
+ /*
+ * Set the socket buffer size to the specified value.
+ */
+ if (setsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF,
+ &handle->opt.buffer_size,
+ sizeof(handle->opt.buffer_size)) == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "SO_RCVBUF: %s", pcap_strerror(errno));
+ err = PCAP_ERROR;
+ goto fail;
}
- return err;
}
/* Allocate the buffer */
if (!handle->buffer) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"malloc: %s", pcap_strerror(errno));
- return PCAP_ERROR;
+ err = PCAP_ERROR;
+ goto fail;
}
/*
handle->selectable_fd = handle->fd;
return 0;
+
+fail:
+ close(handle->fd);
+ if (handle->md.device != NULL) {
+ free(handle->md.device);
+ handle->md.device = NULL;
+ }
+ return err;
}
/*
handle->bufsize = handle->snapshot;
/* Save the socket FD in the pcap structure */
- handle->fd = sock_fd;
+ handle->fd = sock_fd;
return 1;
#else
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.56 2008-04-04 19:37:45 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.57 2008-04-07 03:57:32 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
pcap_strerror(errno));
goto bad;
}
- v = 64 * 1024;
+ if (handle->opt.buffer_size != 0)
+ v = handle->opt.buffer_size;
+ else
+ v = 64 * 1024; /* default to 64K buffer size */
(void)setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&v, sizeof(v));
/*
* XXX hack - map device name to link layer type