summaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorguy <guy>2000-10-20 06:55:28 +0000
committerguy <guy>2000-10-20 06:55:28 +0000
commitedcaeb1db4168124ca0678706ac99a7abfe6f2f7 (patch)
tree104bde806e1245e5c05a3a7d936e263da474e1dd /pcap-linux.c
parentc7823f5045fd55680c8db9fd6b668fc05f75994d (diff)
downloadlibpcap-edcaeb1db4168124ca0678706ac99a7abfe6f2f7.tar.gz
Don't declare "iface_get_id()" or "iface_bind()" if
"HAVE_NETPACKET_PACKET_H" isn't defined, as we won't define them if it's not defined. If the packet buffer size, as computed from the MTU of the interface, is less than the user's requested snapshot length, set it to the user's requested snapshot length; otherwise, the "recvfrom()" call will fail, as the length specified in the call is the user's requested snapshot length, and the kernel checks whether the buffer is big enough for that much data and rejects the "recvfrom()" call if it's not.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index 1024d598..1ba7343a 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -26,7 +26,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.34 2000-10-18 23:51:48 torsten Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.35 2000-10-20 06:55:28 guy Exp $ (LBL)";
#endif
/*
@@ -89,10 +89,14 @@ static int pcap_read_packet(pcap_t *, pcap_handler, u_char *);
/*
* Wrap some ioctl calls
*/
+#ifdef HAVE_NETPACKET_PACKET_H
static int iface_get_id(int fd, const char *device, char *ebuf);
+#endif
static int iface_get_mtu(int fd, const char *device, char *ebuf);
static int iface_get_arptype(int fd, const char *device, char *ebuf);
+#ifdef HAVE_NETPACKET_PACKET_H
static int iface_bind(int fd, int ifindex, char *ebuf);
+#endif
static int iface_bind_old(int fd, const char *device, char *ebuf);
/*
@@ -607,6 +611,8 @@ live_open_new(pcap_t *handle, char *device, int promisc,
if (mtu == -1)
break;
handle->bufsize = MAX_LINKHEADER_SIZE + mtu;
+ if (handle->bufsize < handle->snapshot)
+ handle->bufsize = handle->snapshot;
/* Fill in the pcap structure */
@@ -784,6 +790,8 @@ live_open_old(pcap_t *handle, char *device, int promisc,
if (mtu == -1)
break;
handle->bufsize = MAX_LINKHEADER_SIZE + mtu;
+ if (handle->bufsize < handle->snapshot)
+ handle->bufsize = handle->snapshot;
/* All done - fill in the pcap handle */