1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Nsock-pcap cleanup

Make the API follow the general nsock style. Report errors properly using the
nsock logging facilities.
This commit is contained in:
henri
2013-07-31 19:11:16 +00:00
parent 8352b28e55
commit 694a8fe825
6 changed files with 248 additions and 211 deletions

View File

@@ -389,8 +389,8 @@ int FPNetworkControl::unregister_caller(FPHost *oldcaller) {
/* This method gets the controller ready for packet capture. Basically it
* obtains a pcap descriptor from nsock and sets an appropriate BPF filter. */
int FPNetworkControl::setup_sniffer(const char *iface, const char *bpf_filter) {
char *errmsg = NULL;
char pcapdev[128];
int rc;
#ifdef WIN32
/* Nmap normally uses device names obtained through dnet for interfaces, but
@@ -405,8 +405,9 @@ int FPNetworkControl::setup_sniffer(const char *iface, const char *bpf_filter) {
#endif
/* Obtain a pcap descriptor */
if ((errmsg = nsock_pcap_open(this->nsp, this->pcap_nsi, pcapdev, 8192, 0, bpf_filter)) != NULL)
fatal("Error opening capture device %s --> %s\n", pcapdev, errmsg);
rc = nsock_pcap_open(this->nsp, this->pcap_nsi, pcapdev, 8192, 0, bpf_filter);
if (rc)
fatal("Error opening capture device %s\n", pcapdev);
/* Store the pcap NSI inside the pool so we can retrieve it inside a callback */
nsp_setud(this->nsp, (void *)&(this->pcap_nsi));