mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
fix Mac OS X pcap problem, I hope
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
# Nmap Changelog ($Id$); -*-text-*-
|
||||
o Fixed (I hope) a bug related to Pcap capture on Mac OS X. Thanks to
|
||||
Christophe Thil for reporting the problem and to Kurt Grutzmacher
|
||||
and Diman Todorov for helping to track it down.
|
||||
|
||||
o Upgraded the included LibPCRE from version 6.4 to 6.7. Thanks to
|
||||
Jochen Voß (voss(a)seehuhn.de) for the suggestion (he found some bugs
|
||||
in 6.4)
|
||||
|
||||
@@ -3256,7 +3256,7 @@ static void begin_sniffer(HostOsScan *HOS, vector<Target *> &Targets) {
|
||||
}
|
||||
filterlen = 0;
|
||||
|
||||
HOS->pd = my_pcap_open_live(Targets[0]->deviceName(), 8192, (o.spoofsource)? 1 : 0, 2);
|
||||
HOS->pd = my_pcap_open_live(Targets[0]->deviceName(), 8192, (o.spoofsource)? 1 : 0, pcap_selectable_fd_valid()? 200 : 2);
|
||||
|
||||
if (doIndividual)
|
||||
len = snprintf(pcap_filter, sizeof(pcap_filter), "dst host %s and (icmp or (tcp and (%s",
|
||||
|
||||
@@ -3209,7 +3209,7 @@ static void begin_sniffer(UltraScanInfo *USI, vector<Target *> &Targets) {
|
||||
}
|
||||
filterlen = 0;
|
||||
|
||||
USI->pd = my_pcap_open_live(Targets[0]->deviceName(), 100, (o.spoofsource)? 1 : 0, 2);
|
||||
USI->pd = my_pcap_open_live(Targets[0]->deviceName(), 100, (o.spoofsource)? 1 : 0, pcap_selectable_fd_valid()? 200 : 2);
|
||||
|
||||
if (USI->tcp_scan || USI->udp_scan) {
|
||||
if (doIndividual)
|
||||
|
||||
@@ -1579,7 +1579,7 @@ static void massping(Target *hostbatch[], int num_hosts,
|
||||
16 bytes of the TCP header
|
||||
---
|
||||
= 104 byte snaplen */
|
||||
pd = my_pcap_open_live(hostbatch[0]->deviceName(), 104, o.spoofsource, 20);
|
||||
pd = my_pcap_open_live(hostbatch[0]->deviceName(), 104, o.spoofsource, pcap_selectable_fd_valid()? 200 : 15);
|
||||
|
||||
snprintf(filter, sizeof(filter), "(icmp and dst host %s) or ((tcp or udp) and dst host %s and ( dst port %d or dst port %d or dst port %d or dst port %d or dst port %d))",
|
||||
inet_ntoa(hostbatch[0]->v4source()),
|
||||
|
||||
20
tcpip.cc
20
tcpip.cc
@@ -1844,12 +1844,9 @@ if (!pd) fatal("NULL packet device passed to readip_pcap");
|
||||
gettimeofday(&tv_start, NULL);
|
||||
}
|
||||
|
||||
// Add other systems here if they don't support select()able pcap descriptors
|
||||
#ifdef WIN32
|
||||
pcap_descriptor = -1;
|
||||
#else
|
||||
if (pcap_selectable_fd_valid())
|
||||
pcap_descriptor = pcap_get_selectable_fd(pd);
|
||||
#endif
|
||||
|
||||
do {
|
||||
#ifdef WIN32
|
||||
@@ -1951,6 +1948,16 @@ if (timedout) {
|
||||
return alignedbuf;
|
||||
}
|
||||
|
||||
// Returns whether the system supports pcap_get_selectable_fd() properly
|
||||
bool pcap_selectable_fd_valid() {
|
||||
#if defined(WIN32) || defined(MACOSX)
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Returns whether the packet receive time value obtained from libpcap
|
||||
// (and thus by readip_pcap()) should be considered valid. When
|
||||
// invalid (Windows and Amiga), readip_pcap returns the time you called it.
|
||||
@@ -2069,12 +2076,9 @@ int read_arp_reply_pcap(pcap_t *pd, u8 *sendermac, struct in_addr *senderIP,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Add other systems here if they don't support select()able pcap descriptors
|
||||
#ifdef WIN32
|
||||
pcap_descriptor = -1;
|
||||
#else
|
||||
if (pcap_selectable_fd_valid())
|
||||
pcap_descriptor = pcap_get_selectable_fd(pd);
|
||||
#endif
|
||||
|
||||
p = NULL;
|
||||
if (pcap_descriptor != -1) {
|
||||
|
||||
5
tcpip.h
5
tcpip.h
@@ -617,6 +617,11 @@ int send_udp_raw_decoys( int sd, struct eth_nfo *eth,
|
||||
So a valid pcap_t will always be returned. */
|
||||
pcap_t *my_pcap_open_live(const char *device, int snaplen, int promisc,
|
||||
int to_ms);
|
||||
|
||||
// Returns whether the system supports pcap_get_selectable_fd() properly
|
||||
bool pcap_selectable_fd_valid();
|
||||
|
||||
|
||||
// Returns whether the packet receive time value obtaned from libpcap
|
||||
// (and thus by readip_pcap()) should be considered valid. When
|
||||
// invalid (Windows and Amiga), readip_pcap returns the time you called it.
|
||||
|
||||
Reference in New Issue
Block a user